remove unused code
Browse files
app.py
CHANGED
@@ -130,11 +130,7 @@ async def chat(query,history,audience,sources,reports,current_graphs):
|
|
130 |
|
131 |
inputs = {"user_input": query,"audience": audience_prompt,"sources":sources}
|
132 |
result = agent.astream_events(inputs,version = "v1")
|
133 |
-
|
134 |
-
# path_reformulation = "/logs/reformulation/final_output"
|
135 |
-
# path_keywords = "/logs/keywords/final_output"
|
136 |
-
# path_retriever = "/logs/find_documents/final_output"
|
137 |
-
# path_answer = "/logs/answer/streamed_output_str/-"
|
138 |
|
139 |
docs = []
|
140 |
docs_used = True
|
@@ -196,15 +192,6 @@ async def chat(query,history,audience,sources,reports,current_graphs):
|
|
196 |
elif event["name"] in ["retrieve_graphs", "retrieve_graphs_ai"] and event["event"] == "on_chain_end":
|
197 |
try:
|
198 |
recommended_content = event["data"]["output"]["recommended_content"]
|
199 |
-
# graphs = [
|
200 |
-
# {
|
201 |
-
# "embedding": x.metadata["returned_content"],
|
202 |
-
# "metadata": {
|
203 |
-
# "source": x.metadata["source"],
|
204 |
-
# "category": x.metadata["category"]
|
205 |
-
# }
|
206 |
-
# } for x in recommended_content if x.metadata["source"] == "OWID"
|
207 |
-
# ]
|
208 |
|
209 |
unique_graphs = []
|
210 |
seen_embeddings = set()
|
@@ -279,42 +266,6 @@ async def chat(query,history,audience,sources,reports,current_graphs):
|
|
279 |
print(f"Error logging on Azure Blob Storage: {e}")
|
280 |
raise gr.Error(f"ClimateQ&A Error: {str(e)[:100]} - The error has been noted, try another question and if the error remains, you can contact us :)")
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
# image_dict = {}
|
286 |
-
# for i,doc in enumerate(docs):
|
287 |
-
|
288 |
-
# if doc.metadata["chunk_type"] == "image":
|
289 |
-
# try:
|
290 |
-
# key = f"Image {i+1}"
|
291 |
-
# image_path = doc.metadata["image_path"].split("documents/")[1]
|
292 |
-
# img = get_image_from_azure_blob_storage(image_path)
|
293 |
-
|
294 |
-
# # Convert the image to a byte buffer
|
295 |
-
# buffered = BytesIO()
|
296 |
-
# img.save(buffered, format="PNG")
|
297 |
-
# img_str = base64.b64encode(buffered.getvalue()).decode()
|
298 |
-
|
299 |
-
# # Embedding the base64 string in Markdown
|
300 |
-
# markdown_image = f"![Alt text](data:image/png;base64,{img_str})"
|
301 |
-
# image_dict[key] = {"img":img,"md":markdown_image,"short_name": doc.metadata["short_name"],"figure_code":doc.metadata["figure_code"],"caption":doc.page_content,"key":key,"figure_code":doc.metadata["figure_code"], "img_str" : img_str}
|
302 |
-
# except Exception as e:
|
303 |
-
# print(f"Skipped adding image {i} because of {e}")
|
304 |
-
|
305 |
-
# if len(image_dict) > 0:
|
306 |
-
|
307 |
-
# gallery = [x["img"] for x in list(image_dict.values())]
|
308 |
-
# img = list(image_dict.values())[0]
|
309 |
-
# img_md = img["md"]
|
310 |
-
# img_caption = img["caption"]
|
311 |
-
# img_code = img["figure_code"]
|
312 |
-
# if img_code != "N/A":
|
313 |
-
# img_name = f"{img['key']} - {img['figure_code']}"
|
314 |
-
# else:
|
315 |
-
# img_name = f"{img['key']}"
|
316 |
-
|
317 |
-
# history.append(ChatMessage(role="assistant", content = f"\n\n{img_md}\n<p class='chatbot-caption'><b>{img_name}</b> - {img_caption}</p>"))
|
318 |
|
319 |
docs_figures = [d for d in docs if d.metadata["chunk_type"] == "image"]
|
320 |
for i, doc in enumerate(docs_figures):
|
|
|
130 |
|
131 |
inputs = {"user_input": query,"audience": audience_prompt,"sources":sources}
|
132 |
result = agent.astream_events(inputs,version = "v1")
|
133 |
+
|
|
|
|
|
|
|
|
|
134 |
|
135 |
docs = []
|
136 |
docs_used = True
|
|
|
192 |
elif event["name"] in ["retrieve_graphs", "retrieve_graphs_ai"] and event["event"] == "on_chain_end":
|
193 |
try:
|
194 |
recommended_content = event["data"]["output"]["recommended_content"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
unique_graphs = []
|
197 |
seen_embeddings = set()
|
|
|
266 |
print(f"Error logging on Azure Blob Storage: {e}")
|
267 |
raise gr.Error(f"ClimateQ&A Error: {str(e)[:100]} - The error has been noted, try another question and if the error remains, you can contact us :)")
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
docs_figures = [d for d in docs if d.metadata["chunk_type"] == "image"]
|
271 |
for i, doc in enumerate(docs_figures):
|