Nelly-43 commited on
Commit
3f5dbb6
·
verified ·
1 Parent(s): bfcd904

Update app_web.py

Browse files
Files changed (1) hide show
  1. app_web.py +13 -2
app_web.py CHANGED
@@ -6,7 +6,7 @@ import streamlit as st
6
  from src.config_loader import load_config, get_api_key
7
  from src.ingest import get_chroma_collection, ingest_documents
8
  from src.kb_meta import load_kb_meta_brief
9
- from src.query_engine import understand_query, categorize_query
10
  from src.retriever import clear_collection_cache, retrieve
11
  from src.verifier import verify_and_respond
12
  from src.llm import list_models
@@ -219,12 +219,23 @@ def render_chat():
219
  for m in prior_messages[-max_history:]
220
  ]
221
  try:
 
 
 
 
 
 
 
 
 
 
 
222
  qcat_result = categorize_query(combined_cat, cfg, history)
223
  except Exception:
224
  qcat_result = {"category": "general", "action": "continue"}
225
 
226
  print("unresolved: ", unresolved)
227
- print("result: ", qcat_result)
228
  print("combined: ", combined_cat)
229
  # if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "contact":
230
  # with st.chat_message("assistant"):
 
6
  from src.config_loader import load_config, get_api_key
7
  from src.ingest import get_chroma_collection, ingest_documents
8
  from src.kb_meta import load_kb_meta_brief
9
+ from src.query_engine import understand_query, categorize_query, init_query
10
  from src.retriever import clear_collection_cache, retrieve
11
  from src.verifier import verify_and_respond
12
  from src.llm import list_models
 
219
  for m in prior_messages[-max_history:]
220
  ]
221
  try:
222
+ qinit_result = init_query(combined_cat, cfg, history)
223
+ if qinit_result.get("country", None) is None:
224
+
225
+ with st.chat_message("assistant"):
226
+ st.markdown("Please specify the country for which you'd like to run a PERI analysis")
227
+ return
228
+ if qinit_result.get("value_chain", None) is None and qinit_result.get("investment", None) is None:
229
+
230
+ with st.chat_message("assistant"):
231
+ st.markdown(f"Please specify the value chain or investment area in {qinit_result.get("country", None)} for which you'd like to run a PERI analysis")
232
+ return
233
  qcat_result = categorize_query(combined_cat, cfg, history)
234
  except Exception:
235
  qcat_result = {"category": "general", "action": "continue"}
236
 
237
  print("unresolved: ", unresolved)
238
+ print("result: ", qinit_result)
239
  print("combined: ", combined_cat)
240
  # if qcat_result.get("category") == "contact_and_info" and qcat_result.get("action") == "contact":
241
  # with st.chat_message("assistant"):