Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# ------------------------------
|
2 |
-
# Enhanced NeuroResearch AI System with Refinement Counter
|
3 |
# ------------------------------
|
4 |
import logging
|
5 |
import os
|
@@ -9,7 +9,6 @@ import json
|
|
9 |
import time
|
10 |
import sys
|
11 |
from datetime import datetime
|
12 |
-
import chromadb
|
13 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
14 |
from typing import List, Dict, Any, Optional, Sequence
|
15 |
|
@@ -27,7 +26,7 @@ from langgraph.graph.message import add_messages
|
|
27 |
from typing_extensions import TypedDict, Annotated
|
28 |
from langchain.tools.retriever import create_retriever_tool
|
29 |
|
30 |
-
#
|
31 |
sys.setrecursionlimit(10000)
|
32 |
|
33 |
# ------------------------------
|
@@ -368,7 +367,6 @@ class ResearchWorkflow:
|
|
368 |
current_count = state["context"].get("refine_count", 0)
|
369 |
state["context"]["refine_count"] = current_count + 1
|
370 |
logger.info(f"Refinement iteration: {state['context']['refine_count']}")
|
371 |
-
|
372 |
refinement_prompt = (
|
373 |
f"Refine this analysis:\n{state['messages'][-1].content}\n\n"
|
374 |
"Improve:\n1. Technical precision\n2. Empirical grounding\n3. Theoretical coherence"
|
@@ -494,11 +492,12 @@ class ResearchInterface:
|
|
494 |
def _execute_analysis(self, query: str) -> None:
|
495 |
try:
|
496 |
with st.spinner("Initializing Quantum Analysis..."):
|
|
|
497 |
results = self.workflow.app.stream({
|
498 |
"messages": [HumanMessage(content=query)],
|
499 |
"context": {},
|
500 |
"metadata": {}
|
501 |
-
})
|
502 |
for event in results:
|
503 |
self._render_event(event)
|
504 |
st.success("✅ Analysis Completed Successfully")
|
|
|
1 |
# ------------------------------
|
2 |
+
# Enhanced NeuroResearch AI System with Refinement Counter and Increased Recursion Limit
|
3 |
# ------------------------------
|
4 |
import logging
|
5 |
import os
|
|
|
9 |
import time
|
10 |
import sys
|
11 |
from datetime import datetime
|
|
|
12 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
13 |
from typing import List, Dict, Any, Optional, Sequence
|
14 |
|
|
|
26 |
from typing_extensions import TypedDict, Annotated
|
27 |
from langchain.tools.retriever import create_retriever_tool
|
28 |
|
29 |
+
# Increase Python's recursion limit at the very start (if needed)
|
30 |
sys.setrecursionlimit(10000)
|
31 |
|
32 |
# ------------------------------
|
|
|
367 |
current_count = state["context"].get("refine_count", 0)
|
368 |
state["context"]["refine_count"] = current_count + 1
|
369 |
logger.info(f"Refinement iteration: {state['context']['refine_count']}")
|
|
|
370 |
refinement_prompt = (
|
371 |
f"Refine this analysis:\n{state['messages'][-1].content}\n\n"
|
372 |
"Improve:\n1. Technical precision\n2. Empirical grounding\n3. Theoretical coherence"
|
|
|
492 |
def _execute_analysis(self, query: str) -> None:
|
493 |
try:
|
494 |
with st.spinner("Initializing Quantum Analysis..."):
|
495 |
+
# Pass a recursion limit configuration into the graph invocation
|
496 |
results = self.workflow.app.stream({
|
497 |
"messages": [HumanMessage(content=query)],
|
498 |
"context": {},
|
499 |
"metadata": {}
|
500 |
+
}, {"recursion_limit": 100})
|
501 |
for event in results:
|
502 |
self._render_event(event)
|
503 |
st.success("✅ Analysis Completed Successfully")
|