Jether commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
|
| 48 |
-
|
| 49 |
demo = gr.ChatInterface(
|
| 50 |
respond,
|
| 51 |
additional_inputs=[
|
|
@@ -62,8 +62,23 @@ demo = gr.ChatInterface(
|
|
| 62 |
],
|
| 63 |
|
| 64 |
)
|
|
|
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
demo = gr.ChatInterface(
|
| 69 |
answer,
|
|
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
|
| 48 |
+
|
| 49 |
demo = gr.ChatInterface(
|
| 50 |
respond,
|
| 51 |
additional_inputs=[
|
|
|
|
| 62 |
],
|
| 63 |
|
| 64 |
)
|
| 65 |
+
|
| 66 |
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def answer(message, history):
|
| 71 |
+
files = []
|
| 72 |
+
for msg in history:
|
| 73 |
+
if msg['role'] == "user" and isinstance(msg['content'], tuple):
|
| 74 |
+
files.append(msg['content'][0])
|
| 75 |
+
for file in message["files"]:
|
| 76 |
+
files.append(file)
|
| 77 |
+
|
| 78 |
+
documents = SimpleDirectoryReader(input_files=files).load_data()
|
| 79 |
+
index = VectorStoreIndex.from_documents(documents)
|
| 80 |
+
query_engine = index.as_query_engine()
|
| 81 |
+
return str(query_engine.query(message["text"]))
|
| 82 |
|
| 83 |
demo = gr.ChatInterface(
|
| 84 |
answer,
|