Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import os
|
|
3 |
from langchain.chains import VectorDBQAWithSourcesChain
|
4 |
import gradio as gr
|
5 |
import langchain
|
6 |
-
import weaviate
|
7 |
from langchain.vectorstores import Weaviate
|
8 |
import faiss
|
9 |
import pickle
|
@@ -62,6 +61,8 @@ def chat(inp, history, paper_arxiv_url, api_key, agent):
|
|
62 |
output = agent({"question": inp})
|
63 |
answer = output["answer"]
|
64 |
sources = output["sources"]
|
|
|
|
|
65 |
history.append((inp, answer))
|
66 |
history.append(("Sources?", sources))
|
67 |
print(history)
|
@@ -119,11 +120,11 @@ with block:
|
|
119 |
# )
|
120 |
|
121 |
gr.HTML(
|
122 |
-
"""
|
123 |
)
|
124 |
|
125 |
gr.HTML(
|
126 |
-
"<center>
|
127 |
)
|
128 |
|
129 |
submit.click(chat, inputs=[message, state, paper_arxiv_url, openai_api_key_textbox, agent_state], outputs=[chatbot, state])
|
|
|
3 |
from langchain.chains import VectorDBQAWithSourcesChain
|
4 |
import gradio as gr
|
5 |
import langchain
|
|
|
6 |
from langchain.vectorstores import Weaviate
|
7 |
import faiss
|
8 |
import pickle
|
|
|
61 |
output = agent({"question": inp})
|
62 |
answer = output["answer"]
|
63 |
sources = output["sources"]
|
64 |
+
sources = sources.split(", ")
|
65 |
+
sources = ", ".join([s.title() for s in sources])
|
66 |
history.append((inp, answer))
|
67 |
history.append(("Sources?", sources))
|
68 |
print(history)
|
|
|
120 |
# )
|
121 |
|
122 |
gr.HTML(
|
123 |
+
"""Ask questions of any arXiv paper and get factual answers with sources"""
|
124 |
)
|
125 |
|
126 |
gr.HTML(
|
127 |
+
"<center>By <a href='https://twitter.com/0xjasper'>Jasper</a>, powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a></center>"
|
128 |
)
|
129 |
|
130 |
submit.click(chat, inputs=[message, state, paper_arxiv_url, openai_api_key_textbox, agent_state], outputs=[chatbot, state])
|