Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from langchain_core.tools import tool
|
|
9 |
from langchain_core.utils.function_calling import convert_to_openai_tool
|
10 |
from langgraph.graph import StateGraph, END
|
11 |
|
|
|
12 |
# Environment Setup
|
13 |
os.environ['OPENAI_API_KEY'] = os.getenv("OPENAI_API_KEY")
|
14 |
|
@@ -28,6 +29,10 @@ class AgentState(TypedDict):
|
|
28 |
|
29 |
graph = StateGraph(AgentState)
|
30 |
|
|
|
|
|
|
|
|
|
31 |
def invoke_model(state):
|
32 |
question = state['messages'][-1]
|
33 |
return {"messages": [model_with_tools.invoke(question)]}
|
|
|
9 |
from langchain_core.utils.function_calling import convert_to_openai_tool
|
10 |
from langgraph.graph import StateGraph, END
|
11 |
|
12 |
+
|
13 |
# Environment Setup
|
14 |
os.environ['OPENAI_API_KEY'] = os.getenv("OPENAI_API_KEY")
|
15 |
|
|
|
29 |
|
30 |
graph = StateGraph(AgentState)
|
31 |
|
32 |
+
# Define MessagesState
|
33 |
+
class MessagesState(TypedDict):
|
34 |
+
messages: Annotated[Sequence[BaseMessage], operator.add]
|
35 |
+
|
36 |
def invoke_model(state):
|
37 |
question = state['messages'][-1]
|
38 |
return {"messages": [model_with_tools.invoke(question)]}
|