Update app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,7 @@ class GenAIQASystem:
|
|
| 107 |
vectorstore.save_local("faiss_index")
|
| 108 |
|
| 109 |
llm = ChatOpenAI(
|
| 110 |
-
|
| 111 |
temperature=0,
|
| 112 |
callbacks=[self.callback_handler]
|
| 113 |
)
|
|
@@ -154,7 +154,9 @@ def set_api_key(api_key):
|
|
| 154 |
return message
|
| 155 |
|
| 156 |
def respond(message, history):
|
| 157 |
-
|
|
|
|
|
|
|
| 158 |
|
| 159 |
def view_logs():
|
| 160 |
return qa_system.get_logs()
|
|
@@ -165,11 +167,7 @@ with gr.Blocks(title="Generative AI Q/A System") as demo:
|
|
| 165 |
gr.Markdown("Ask questions about Generative AI using this LangChain-based Q/A system.")
|
| 166 |
|
| 167 |
with gr.Tab("Chat"):
|
| 168 |
-
|
| 169 |
-
msg = gr.Textbox(label="Your Question")
|
| 170 |
-
clear = gr.Button("Clear")
|
| 171 |
-
msg.submit(respond, [msg, chatbot], [chatbot])
|
| 172 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
| 173 |
|
| 174 |
with gr.Tab("System Logs"):
|
| 175 |
logs_output = gr.Textbox(label="System Logs", lines=20)
|
|
@@ -185,14 +183,14 @@ with gr.Blocks(title="Generative AI Q/A System") as demo:
|
|
| 185 |
gr.Markdown("## About")
|
| 186 |
gr.Markdown("""
|
| 187 |
This Q/A system uses LangChain and OpenAI to answer questions based on the Wikipedia page about Generative AI.
|
| 188 |
-
|
| 189 |
Features:
|
| 190 |
- Caching mechanism to avoid repeating work
|
| 191 |
- Callback logging to track processing
|
| 192 |
- Persistent vector database (FAISS)
|
| 193 |
-
|
| 194 |
Created by Anjali Haryani (Modified for Hugging Face deployment)
|
| 195 |
""")
|
| 196 |
|
| 197 |
if __name__ == "__main__":
|
| 198 |
-
demo.launch()
|
|
|
|
| 107 |
vectorstore.save_local("faiss_index")
|
| 108 |
|
| 109 |
llm = ChatOpenAI(
|
| 110 |
+
model_name="gpt-3.5-turbo",
|
| 111 |
temperature=0,
|
| 112 |
callbacks=[self.callback_handler]
|
| 113 |
)
|
|
|
|
| 154 |
return message
|
| 155 |
|
| 156 |
def respond(message, history):
|
| 157 |
+
response = qa_system.process_query(message)
|
| 158 |
+
history.append((message, response))
|
| 159 |
+
return history
|
| 160 |
|
| 161 |
def view_logs():
|
| 162 |
return qa_system.get_logs()
|
|
|
|
| 167 |
gr.Markdown("Ask questions about Generative AI using this LangChain-based Q/A system.")
|
| 168 |
|
| 169 |
with gr.Tab("Chat"):
|
| 170 |
+
chat_interface = gr.ChatInterface(fn=respond)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
with gr.Tab("System Logs"):
|
| 173 |
logs_output = gr.Textbox(label="System Logs", lines=20)
|
|
|
|
| 183 |
gr.Markdown("## About")
|
| 184 |
gr.Markdown("""
|
| 185 |
This Q/A system uses LangChain and OpenAI to answer questions based on the Wikipedia page about Generative AI.
|
| 186 |
+
|
| 187 |
Features:
|
| 188 |
- Caching mechanism to avoid repeating work
|
| 189 |
- Callback logging to track processing
|
| 190 |
- Persistent vector database (FAISS)
|
| 191 |
+
|
| 192 |
Created by Anjali Haryani (Modified for Hugging Face deployment)
|
| 193 |
""")
|
| 194 |
|
| 195 |
if __name__ == "__main__":
|
| 196 |
+
demo.launch()
|