Spaces:
Sleeping
Sleeping
Update app_web.py
Browse files- app_web.py +4 -13
app_web.py
CHANGED
|
@@ -126,25 +126,16 @@ def render_landing_page():
|
|
| 126 |
status.update(label=f'Preparing investment area metadata...')
|
| 127 |
investments = analyze_investments()
|
| 128 |
|
| 129 |
-
# ββ Query understanding βββββββββββββββββββββββββββββββββββββββββ
|
| 130 |
-
qu_cfg = cfg.get("query_understanding", {})
|
| 131 |
-
qu_enabled = qu_cfg.get("enabled", True)
|
| 132 |
-
max_history = qu_cfg.get("max_history", 6)
|
| 133 |
-
|
| 134 |
-
prior_messages = st.session_state.messages[:-1]
|
| 135 |
-
history = [
|
| 136 |
-
{"role": m["role"], "content": m["content"]}
|
| 137 |
-
for m in prior_messages[-max_history:]
|
| 138 |
-
]
|
| 139 |
-
|
| 140 |
c2vc = {}
|
| 141 |
for vc in pol_geo_ref["value_chain"].unique():
|
| 142 |
status.update(label=f'Analyzing committment to {vc} production...')
|
| 143 |
prompt = f"Look up and retrieve all relevant information on {vc} production in {country} from the knowledgebase."
|
|
|
|
| 144 |
|
| 145 |
-
|
|
|
|
| 146 |
|
| 147 |
-
retrieval_result = retrieve(
|
| 148 |
st.session_state.last_retrieval = retrieval_result
|
| 149 |
|
| 150 |
output = verify_and_respond(
|
|
|
|
| 126 |
status.update(label=f'Preparing investment area metadata...')
|
| 127 |
investments = analyze_investments()
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
c2vc = {}
|
| 130 |
for vc in pol_geo_ref["value_chain"].unique():
|
| 131 |
status.update(label=f'Analyzing committment to {vc} production...')
|
| 132 |
prompt = f"Look up and retrieve all relevant information on {vc} production in {country} from the knowledgebase."
|
| 133 |
+
qu_result = understand_query(prompt, cfg)
|
| 134 |
|
| 135 |
+
search_query = qu_result.get("search_query", combined)
|
| 136 |
+
sql_query = qu_result.get("sql_query")
|
| 137 |
|
| 138 |
+
retrieval_result = retrieve(search_query, cfg, route="both", sql_query=sql_query)
|
| 139 |
st.session_state.last_retrieval = retrieval_result
|
| 140 |
|
| 141 |
output = verify_and_respond(
|