Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -284,7 +284,7 @@ class ResearchWorkflow:
|
|
284 |
|
285 |
response = self.processor.process_query(validation_prompt)
|
286 |
return {
|
287 |
-
"messages": [AIMessage(content=analysis + f"\n\nValidation: {response.get('choices', [{}])[0].get('message', {}).get('content', '')}"
|
288 |
}
|
289 |
|
290 |
def refine_results(self, state: AgentState) -> Dict:
|
@@ -398,41 +398,55 @@ class ResearchInterface:
|
|
398 |
self._execute_analysis(query)
|
399 |
|
400 |
def _execute_analysis(self, query: str):
|
401 |
-
|
402 |
-
|
403 |
results = self.workflow.app.stream(
|
404 |
{"messages": [HumanMessage(content=query)], "context": {}, "metadata": {}}
|
405 |
)
|
406 |
|
407 |
-
container = st.container()
|
408 |
for event in results:
|
409 |
-
self._render_event(event
|
410 |
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
|
420 |
-
def _render_event(self, event: Dict
|
421 |
if 'ingest' in event:
|
422 |
-
with container:
|
423 |
st.success("β
Query Ingested")
|
|
|
424 |
elif 'retrieve' in event:
|
425 |
-
with container:
|
426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
elif 'analyze' in event:
|
428 |
-
with container
|
429 |
-
|
|
|
|
|
|
|
430 |
elif 'validate' in event:
|
431 |
-
with container:
|
432 |
-
|
|
|
433 |
st.success("β
Validation Passed")
|
|
|
|
|
434 |
else:
|
435 |
st.warning("β οΈ Validation Issues Detected")
|
|
|
|
|
436 |
|
437 |
if __name__ == "__main__":
|
438 |
ResearchInterface()
|
|
|
284 |
|
285 |
response = self.processor.process_query(validation_prompt)
|
286 |
return {
|
287 |
+
"messages": [AIMessage(content=analysis + f"\n\nValidation: {response.get('choices', [{}])[0].get('message', {}).get('content', '')}"]
|
288 |
}
|
289 |
|
290 |
def refine_results(self, state: AgentState) -> Dict:
|
|
|
398 |
self._execute_analysis(query)
|
399 |
|
400 |
def _execute_analysis(self, query: str):
|
401 |
+
try:
|
402 |
+
with st.spinner("Initializing Quantum Analysis..."):
|
403 |
results = self.workflow.app.stream(
|
404 |
{"messages": [HumanMessage(content=query)], "context": {}, "metadata": {}}
|
405 |
)
|
406 |
|
|
|
407 |
for event in results:
|
408 |
+
self._render_event(event)
|
409 |
|
410 |
+
st.success("β
Analysis Completed Successfully")
|
411 |
+
except Exception as e:
|
412 |
+
st.error(f"""**Analysis Failed**
|
413 |
+
{str(e)}
|
414 |
+
Potential issues:
|
415 |
+
- Complex query structure
|
416 |
+
- Document correlation failure
|
417 |
+
- Temporal processing constraints""")
|
418 |
|
419 |
+
def _render_event(self, event: Dict):
|
420 |
if 'ingest' in event:
|
421 |
+
with st.container():
|
422 |
st.success("β
Query Ingested")
|
423 |
+
|
424 |
elif 'retrieve' in event:
|
425 |
+
with st.container():
|
426 |
+
docs = event['retrieve']['context']['documents']
|
427 |
+
st.info(f"π Retrieved {len(docs)} documents")
|
428 |
+
with st.expander("View Retrieved Documents", expanded=False):
|
429 |
+
for i, doc in enumerate(docs, 1):
|
430 |
+
st.markdown(f"**Document {i}**")
|
431 |
+
st.code(doc.page_content, language='text')
|
432 |
+
|
433 |
elif 'analyze' in event:
|
434 |
+
with st.container():
|
435 |
+
content = event['analyze']['messages'][0].content
|
436 |
+
with st.expander("Technical Analysis Report", expanded=True):
|
437 |
+
st.markdown(content)
|
438 |
+
|
439 |
elif 'validate' in event:
|
440 |
+
with st.container():
|
441 |
+
content = event['validate']['messages'][0].content
|
442 |
+
if "VALID" in content:
|
443 |
st.success("β
Validation Passed")
|
444 |
+
with st.expander("View Validated Analysis", expanded=True):
|
445 |
+
st.markdown(content.split("Validation:")[0])
|
446 |
else:
|
447 |
st.warning("β οΈ Validation Issues Detected")
|
448 |
+
with st.expander("View Validation Details", expanded=True):
|
449 |
+
st.markdown(content)
|
450 |
|
451 |
if __name__ == "__main__":
|
452 |
ResearchInterface()
|