Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,7 @@ from langchain_core.messages import HumanMessage, SystemMessage
|
|
| 61 |
# """Multiply a and b."""
|
| 62 |
# return a * b
|
| 63 |
|
| 64 |
-
def assistant(state: AgentState):
|
| 65 |
# System message
|
| 66 |
textual_description_of_tool = """
|
| 67 |
DuckDuckGoSearchResults():
|
|
@@ -114,10 +114,12 @@ class BasicAgent:
|
|
| 114 |
# self.visionLLM = ChatOpenAI(model="gpt-4o",api_key=api_key) # multi-modal LLM
|
| 115 |
self.LLM = ChatOpenAI(model="gpt-4o",api_key=api_key) # manager LLM
|
| 116 |
self.LLM_with_tools = self.LLM.bind_tools(tools, parallel_tool_calls=False)
|
|
|
|
|
|
|
| 117 |
# Graph
|
| 118 |
self.Builder = StateGraph(AgentState)
|
| 119 |
# Define nodes: these do the work
|
| 120 |
-
self.Builder.add_node("assistant",
|
| 121 |
self.Builder.add_node("tools",ToolNode(tools))
|
| 122 |
# Define edges: these determine how the control flow moves
|
| 123 |
self.Builder.add_edge(START,"assistant")
|
|
|
|
| 61 |
# """Multiply a and b."""
|
| 62 |
# return a * b
|
| 63 |
|
| 64 |
+
def assistant(state: AgentState, llm_with_tools):
|
| 65 |
# System message
|
| 66 |
textual_description_of_tool = """
|
| 67 |
DuckDuckGoSearchResults():
|
|
|
|
| 114 |
# self.visionLLM = ChatOpenAI(model="gpt-4o",api_key=api_key) # multi-modal LLM
|
| 115 |
self.LLM = ChatOpenAI(model="gpt-4o",api_key=api_key) # manager LLM
|
| 116 |
self.LLM_with_tools = self.LLM.bind_tools(tools, parallel_tool_calls=False)
|
| 117 |
+
|
| 118 |
+
assistant_with_llm = lambda state:assistant(state, self.LLM_with_tools)
|
| 119 |
# Graph
|
| 120 |
self.Builder = StateGraph(AgentState)
|
| 121 |
# Define nodes: these do the work
|
| 122 |
+
self.Builder.add_node("assistant", assistant_with_llm)
|
| 123 |
self.Builder.add_node("tools",ToolNode(tools))
|
| 124 |
# Define edges: these determine how the control flow moves
|
| 125 |
self.Builder.add_edge(START,"assistant")
|