Scott Cogan commited on
Commit
96ca77e
·
1 Parent(s): cd7d021

langchain versions

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -8,7 +8,7 @@ from langchain_google_genai import ChatGoogleGenerativeAI
8
  from typing import IO, Dict
9
  from io import BytesIO
10
  from langchain_core.messages import HumanMessage, SystemMessage
11
- from langgraph.graph import START, StateGraph
12
  from langgraph.prebuilt import tools_condition
13
  from langgraph.prebuilt import ToolNode
14
  import base64
@@ -198,14 +198,14 @@ class BasicAgent:
198
  ''')
199
 
200
  # Graph
201
- self.builder = StateGraph(START)
202
 
203
  # Define nodes: these do the work
204
  self.builder.add_node("assistant", self.assistant)
205
  self.builder.add_node("tools", ToolNode(self.tools))
206
 
207
  # Define edges: these determine how the control flow moves
208
- self.builder.add_edge(START, "assistant")
209
  self.builder.add_conditional_edges(
210
  "assistant",
211
  # If the latest message (result) from assistant is a tool call -> tools_condition routes to tools
@@ -217,7 +217,7 @@ class BasicAgent:
217
 
218
  print("BasicAgent initialized.")
219
 
220
- def assistant(self, state: StateGraph):
221
  return {"messages": [self.agent.invoke([self.sys_msg] + state["messages"])]}
222
 
223
  async def __call__(self, question: str, task_id: str) -> str:
 
8
  from typing import IO, Dict
9
  from io import BytesIO
10
  from langchain_core.messages import HumanMessage, SystemMessage
11
+ from langgraph.graph import StateGraph
12
  from langgraph.prebuilt import tools_condition
13
  from langgraph.prebuilt import ToolNode
14
  import base64
 
198
  ''')
199
 
200
  # Graph
201
+ self.builder = StateGraph()
202
 
203
  # Define nodes: these do the work
204
  self.builder.add_node("assistant", self.assistant)
205
  self.builder.add_node("tools", ToolNode(self.tools))
206
 
207
  # Define edges: these determine how the control flow moves
208
+ self.builder.add_edge("start", "assistant")
209
  self.builder.add_conditional_edges(
210
  "assistant",
211
  # If the latest message (result) from assistant is a tool call -> tools_condition routes to tools
 
217
 
218
  print("BasicAgent initialized.")
219
 
220
+ def assistant(self, state):
221
  return {"messages": [self.agent.invoke([self.sys_msg] + state["messages"])]}
222
 
223
  async def __call__(self, question: str, task_id: str) -> str: