Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -9,20 +9,17 @@ from typing import TypedDict
|
|
| 9 |
|
| 10 |
tools = [add, substract, multiply, divide, web_search]
|
| 11 |
|
| 12 |
-
class AgentState(TypedDict):
|
| 13 |
-
messages: str
|
| 14 |
-
|
| 15 |
def build_agent():
|
| 16 |
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0)
|
| 17 |
chat_with_tools = llm.bind_tools(tools)
|
| 18 |
|
| 19 |
-
def assistant(state:
|
| 20 |
return {
|
| 21 |
"messages": [chat_with_tools.invoke(state["messages"])],
|
| 22 |
}
|
| 23 |
|
| 24 |
## The graph
|
| 25 |
-
builder = StateGraph(
|
| 26 |
|
| 27 |
# Define nodes: these do the work
|
| 28 |
builder.add_node("assistant", assistant)
|
|
|
|
| 9 |
|
| 10 |
tools = [add, substract, multiply, divide, web_search]
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
def build_agent():
|
| 13 |
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0)
|
| 14 |
chat_with_tools = llm.bind_tools(tools)
|
| 15 |
|
| 16 |
+
def assistant(state: MessagesState):
|
| 17 |
return {
|
| 18 |
"messages": [chat_with_tools.invoke(state["messages"])],
|
| 19 |
}
|
| 20 |
|
| 21 |
## The graph
|
| 22 |
+
builder = StateGraph(MessagesState)
|
| 23 |
|
| 24 |
# Define nodes: these do the work
|
| 25 |
builder.add_node("assistant", assistant)
|