Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -174,37 +174,33 @@ def generate_output(context, query):
|
|
174 |
except Exception as e:
|
175 |
return f"Error generating output: {str(e)}"
|
176 |
|
177 |
-
def complete_workflow(query):
|
178 |
-
|
179 |
-
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
results = {
|
186 |
-
"results": [
|
187 |
-
{
|
188 |
-
"natural_language_output": generate_output(doc["relevant_text"], query),
|
189 |
-
"doc_id": doc["doc_id"],
|
190 |
-
"chunk_id": doc["chunk_id"],
|
191 |
-
"title": doc["title"],
|
192 |
-
"relevant_text": doc["relevant_text"],
|
193 |
-
"page_number": doc["page_number"],
|
194 |
-
"score": doc["score"],
|
195 |
-
}
|
196 |
-
for doc in context_data
|
197 |
-
]
|
198 |
-
}
|
199 |
-
|
200 |
-
return results, formatted_titles # Return results and formatted document titles
|
201 |
-
except Exception as e:
|
202 |
-
return {"results": []}, f"Error in workflow: {str(e)}"
|
203 |
-
|
204 |
-
|
205 |
-
import os
|
206 |
-
from langchain_openai import ChatOpenAI
|
207 |
-
from langchain.schema import HumanMessage
|
208 |
|
209 |
def complete_workflow(query):
|
210 |
try:
|
|
|
174 |
except Exception as e:
|
175 |
return f"Error generating output: {str(e)}"
|
176 |
|
177 |
+
# def complete_workflow(query):
|
178 |
+
# try:
|
179 |
+
# context_data, combined_context = search_documents(query)
|
180 |
|
181 |
+
# document_titles = list({os.path.basename(doc["title"]) for doc in context_data}) # Get only file names
|
182 |
+
|
183 |
+
# formatted_titles = " " + "\n".join(document_titles)
|
184 |
+
|
185 |
+
# results = {
|
186 |
+
# "results": [
|
187 |
+
# {
|
188 |
+
# "natural_language_output": generate_output(doc["relevant_text"], query),
|
189 |
+
# "doc_id": doc["doc_id"],
|
190 |
+
# "chunk_id": doc["chunk_id"],
|
191 |
+
# "title": doc["title"],
|
192 |
+
# "relevant_text": doc["relevant_text"],
|
193 |
+
# "page_number": doc["page_number"],
|
194 |
+
# "score": doc["score"],
|
195 |
+
# }
|
196 |
+
# for doc in context_data
|
197 |
+
# ]
|
198 |
+
# }
|
199 |
+
|
200 |
+
# return results, formatted_titles # Return results and formatted document titles
|
201 |
+
# except Exception as e:
|
202 |
+
# return {"results": []}, f"Error in workflow: {str(e)}"
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
def complete_workflow(query):
|
206 |
try:
|