Update app.py
Browse files
app.py
CHANGED
|
@@ -130,13 +130,12 @@ def chat(
|
|
| 130 |
messages = history + [{"role": "user", "content": query}]
|
| 131 |
|
| 132 |
if docs:
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
)
|
| 140 |
messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}\n\nAnswer in {language}:"})
|
| 141 |
|
| 142 |
response = openai.Completion.create(
|
|
|
|
| 130 |
messages = history + [{"role": "user", "content": query}]
|
| 131 |
|
| 132 |
if docs:
|
| 133 |
+
|
| 134 |
+
docs_string = []
|
| 135 |
+
for i,d in enumerate(docs,1):
|
| 136 |
+
content = d.content.replace("\r\n","")
|
| 137 |
+
docs_string.append(f"π doc {i}: {d.meta['file_name']} page {d.meta['page_number']}\n{content}")
|
| 138 |
+
sources = "\n\n".join([f"Query used for retrieval:\n{reformulated_query}"]+docs_string
|
|
|
|
| 139 |
messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}\n\nAnswer in {language}:"})
|
| 140 |
|
| 141 |
response = openai.Completion.create(
|