Spaces:
Running
Running
Update workflow.py
Browse files- workflow.py +12 -3
workflow.py
CHANGED
@@ -2,16 +2,24 @@
|
|
2 |
|
3 |
import time
|
4 |
from datetime import datetime
|
5 |
-
from typing import Dict
|
6 |
|
7 |
from langchain_core.messages import AIMessage, HumanMessage
|
8 |
from langgraph.graph import END, StateGraph
|
9 |
from langgraph.graph.message import add_messages
|
|
|
10 |
|
11 |
from processor import EnhancedCognitiveProcessor
|
12 |
from config import ResearchConfig
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
logger = logging.getLogger(__name__)
|
16 |
|
17 |
class ResearchWorkflow:
|
@@ -19,8 +27,9 @@ class ResearchWorkflow:
|
|
19 |
Defines a multi-step research workflow using a state graph.
|
20 |
"""
|
21 |
def __init__(self) -> None:
|
|
|
|
|
22 |
self.processor = EnhancedCognitiveProcessor()
|
23 |
-
self.workflow = StateGraph()
|
24 |
self._build_workflow()
|
25 |
self.app = self.workflow.compile()
|
26 |
|
|
|
2 |
|
3 |
import time
|
4 |
from datetime import datetime
|
5 |
+
from typing import Dict, Sequence, Any
|
6 |
|
7 |
from langchain_core.messages import AIMessage, HumanMessage
|
8 |
from langgraph.graph import END, StateGraph
|
9 |
from langgraph.graph.message import add_messages
|
10 |
+
import logging
|
11 |
|
12 |
from processor import EnhancedCognitiveProcessor
|
13 |
from config import ResearchConfig
|
14 |
|
15 |
+
# Define the state schema for the workflow
|
16 |
+
from typing_extensions import TypedDict, Annotated
|
17 |
+
|
18 |
+
class AgentState(TypedDict):
|
19 |
+
messages: Annotated[Sequence[Any], add_messages]
|
20 |
+
context: dict
|
21 |
+
metadata: dict
|
22 |
+
|
23 |
logger = logging.getLogger(__name__)
|
24 |
|
25 |
class ResearchWorkflow:
|
|
|
27 |
Defines a multi-step research workflow using a state graph.
|
28 |
"""
|
29 |
def __init__(self) -> None:
|
30 |
+
# Provide the state schema to StateGraph
|
31 |
+
self.workflow = StateGraph(AgentState)
|
32 |
self.processor = EnhancedCognitiveProcessor()
|
|
|
33 |
self._build_workflow()
|
34 |
self.app = self.workflow.compile()
|
35 |
|