TheoLvs commited on
Commit
86de0ab
β€’
1 Parent(s): 1a96034

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -130,13 +130,12 @@ def chat(
130
  messages = history + [{"role": "user", "content": query}]
131
 
132
  if docs:
133
- sources = "\n\n".join(
134
- [f"query used for retrieval:\n{reformulated_query}"]
135
- + [
136
- f"""πŸ“ƒ doc {i}: {d.meta['file_name']} page {d.meta['page_number']}\n{d.content.replace("\r\n","")}"""
137
- for i, d in enumerate(docs, 1)
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(