Spaces:
GIZ
/
Running on CPU Upgrade

leavoigt commited on
Commit
5cfa298
·
1 Parent(s): e4bca55

make changes

Browse files
app.py CHANGED
@@ -69,15 +69,18 @@ async def chat_response(query, history, method, country, uploaded_file):
69
  # Handle "Talk to Reports"
70
  else:
71
  try:
72
- response = f"Based on EUDR reports for {country}, I can help you understand deforestation patterns and compliance requirements. Your question: '{query}' is being analyzed..."
73
  retrieved_paragraphs = retrieve_paragraphs(query)
74
- response = generate(query=query, context=retrieve_paragraphs)
 
 
75
 
76
  except Exception as e:
77
  response = f"Error retrieving information: {str(e)}"
78
 
79
  # Stream response word by word into the chat
80
  words = response.split()
 
81
  for i in range(len(words)):
82
  history[-1] = (query, " ".join(words[:i+1]))
83
  yield history, "**Sources:** Sample source documents would appear here..."
 
69
  # Handle "Talk to Reports"
70
  else:
71
  try:
72
+ # response = f"Based on EUDR reports for {country}, I can help you understand deforestation patterns and compliance requirements. Your question: '{query}' is being analyzed..."
73
  retrieved_paragraphs = retrieve_paragraphs(query)
74
+ print("RETRIEVED", retrieved_paragraphs)
75
+ response = await generate(query=query, context=retrieve_paragraphs)
76
+ print(response)
77
 
78
  except Exception as e:
79
  response = f"Error retrieving information: {str(e)}"
80
 
81
  # Stream response word by word into the chat
82
  words = response.split()
83
+
84
  for i in range(len(words)):
85
  history[-1] = (query, " ".join(words[:i+1]))
86
  yield history, "**Sources:** Sample source documents would appear here..."
utils/__pycache__/generator.cpython-310.pyc CHANGED
Binary files a/utils/__pycache__/generator.cpython-310.pyc and b/utils/__pycache__/generator.cpython-310.pyc differ
 
utils/__pycache__/retriever.cpython-310.pyc CHANGED
Binary files a/utils/__pycache__/retriever.cpython-310.pyc and b/utils/__pycache__/retriever.cpython-310.pyc differ
 
utils/generator.py CHANGED
@@ -244,7 +244,7 @@ async def generate(query: str, context: Union[str, List[Dict[str, Any]]]) -> str
244
  # Process the retrieval results
245
  processed_results = extract_relevant_fields(context)
246
  formatted_context = format_context_from_results(processed_results)
247
-
248
  if not formatted_context.strip():
249
  return "Error: No valid content found in retrieval results"
250
 
 
244
  # Process the retrieval results
245
  processed_results = extract_relevant_fields(context)
246
  formatted_context = format_context_from_results(processed_results)
247
+
248
  if not formatted_context.strip():
249
  return "Error: No valid content found in retrieval results"
250
 
utils/retriever.py CHANGED
@@ -15,13 +15,8 @@ def retrieve_paragraphs(query):
15
  year_filter="",
16
  api_name="/retrieve"
17
  )
18
- print(result)
19
- return (
20
- result,
21
- gr.update(visible=True), # Keep status visible
22
- gr.update(visible=False) # Always hide results table
23
- )
24
-
25
  except Exception as e:
26
  error_msg = f"Error retrieving paragraphs: {str(e)}"
27
  return (
 
15
  year_filter="",
16
  api_name="/retrieve"
17
  )
18
+ return result
19
+
 
 
 
 
 
20
  except Exception as e:
21
  error_msg = f"Error retrieving paragraphs: {str(e)}"
22
  return (