Spaces:
Runtime error
Runtime error
Sharathhebbar24
commited on
Commit
•
783dbaa
1
Parent(s):
0a9b85c
Update app.py
Browse files
app.py
CHANGED
@@ -82,7 +82,7 @@ class LLM_Langchain():
|
|
82 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.getenv("HF_KEY")
|
83 |
|
84 |
|
85 |
-
def generate_response(self, input_text):
|
86 |
|
87 |
template = f"<|system|>\nYou are a intelligent chatbot.</s>\n<|user|>\n{input_text}.\n<|assistant|>"
|
88 |
llm = HuggingFaceHub(
|
@@ -96,7 +96,7 @@ class LLM_Langchain():
|
|
96 |
|
97 |
result = llm_chain.run({
|
98 |
"question": input_text,
|
99 |
-
|
100 |
})
|
101 |
# return llm(input_text)
|
102 |
return result
|
@@ -155,6 +155,11 @@ class LLM_Langchain():
|
|
155 |
for message in st.session_state.messages:
|
156 |
with st.chat_message(message.get('role')):
|
157 |
st.write(message.get("content"))
|
|
|
|
|
|
|
|
|
|
|
158 |
text = st.chat_input(disabled=text_input_visibility)
|
159 |
|
160 |
if text:
|
@@ -173,7 +178,7 @@ class LLM_Langchain():
|
|
173 |
if self.selected_option == 'FineTune':
|
174 |
result = similarity(self.pdf_file_path, self.model_name, self.model_kwargs, text)
|
175 |
else:
|
176 |
-
result = self.generate_response(text)
|
177 |
st.session_state.messages.append(
|
178 |
{
|
179 |
"role": "assistant",
|
|
|
82 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.getenv("HF_KEY")
|
83 |
|
84 |
|
85 |
+
def generate_response(self, input_text, context):
|
86 |
|
87 |
template = f"<|system|>\nYou are a intelligent chatbot.</s>\n<|user|>\n{input_text}.\n<|assistant|>"
|
88 |
llm = HuggingFaceHub(
|
|
|
96 |
|
97 |
result = llm_chain.run({
|
98 |
"question": input_text,
|
99 |
+
"context": context
|
100 |
})
|
101 |
# return llm(input_text)
|
102 |
return result
|
|
|
155 |
for message in st.session_state.messages:
|
156 |
with st.chat_message(message.get('role')):
|
157 |
st.write(message.get("content"))
|
158 |
+
|
159 |
+
context = st.sidebar.text_input(
|
160 |
+
label="Context",
|
161 |
+
help="Context lets you know on what the answer should be generated"
|
162 |
+
)
|
163 |
text = st.chat_input(disabled=text_input_visibility)
|
164 |
|
165 |
if text:
|
|
|
178 |
if self.selected_option == 'FineTune':
|
179 |
result = similarity(self.pdf_file_path, self.model_name, self.model_kwargs, text)
|
180 |
else:
|
181 |
+
result = self.generate_response(text, context)
|
182 |
st.session_state.messages.append(
|
183 |
{
|
184 |
"role": "assistant",
|