Scott Cogan
commited on
Commit
·
f39a6cf
1
Parent(s):
3427e8c
debug
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ import base64
|
|
| 13 |
from google.ai.generativelanguage_v1beta.types import Tool as GenAITool
|
| 14 |
import google.generativeai as genai
|
| 15 |
import operator
|
| 16 |
-
from langgraph.prebuilt import
|
| 17 |
from langchain_core.tools import tool
|
| 18 |
from utilities import get_file
|
| 19 |
import time
|
|
@@ -165,7 +165,7 @@ class BasicAgent:
|
|
| 165 |
get_file, analyse_excel, add_numbers, transcribe_audio,
|
| 166 |
python_code, open_image, open_youtube_video, google_search
|
| 167 |
]
|
| 168 |
-
self.
|
| 169 |
|
| 170 |
# System message
|
| 171 |
self.sys_msg = SystemMessage('''You are a general AI assistant. I will ask you a question. Follow these steps:
|
|
@@ -194,7 +194,8 @@ class BasicAgent:
|
|
| 194 |
- Never make up information - if you can't find it, say so''')
|
| 195 |
|
| 196 |
# Create the graph
|
| 197 |
-
self.workflow = StateGraph(AgentState
|
|
|
|
| 198 |
|
| 199 |
# Add nodes
|
| 200 |
self.workflow.add_node("agent", self.call_model)
|
|
@@ -321,7 +322,7 @@ class BasicAgent:
|
|
| 321 |
logger.info(f"Executing tool: {tool_name}")
|
| 322 |
logger.info(f"Tool arguments: {json.dumps(tool_args, indent=2)}")
|
| 323 |
|
| 324 |
-
result = self.
|
| 325 |
logger.info(f"Tool result: {result}")
|
| 326 |
|
| 327 |
messages.append(AIMessage(content=f"Tool result: {result}"))
|
|
|
|
| 13 |
from google.ai.generativelanguage_v1beta.types import Tool as GenAITool
|
| 14 |
import google.generativeai as genai
|
| 15 |
import operator
|
| 16 |
+
from langgraph.prebuilt import ToolNode
|
| 17 |
from langchain_core.tools import tool
|
| 18 |
from utilities import get_file
|
| 19 |
import time
|
|
|
|
| 165 |
get_file, analyse_excel, add_numbers, transcribe_audio,
|
| 166 |
python_code, open_image, open_youtube_video, google_search
|
| 167 |
]
|
| 168 |
+
self.tool_node = ToolNode(self.tools)
|
| 169 |
|
| 170 |
# System message
|
| 171 |
self.sys_msg = SystemMessage('''You are a general AI assistant. I will ask you a question. Follow these steps:
|
|
|
|
| 194 |
- Never make up information - if you can't find it, say so''')
|
| 195 |
|
| 196 |
# Create the graph
|
| 197 |
+
self.workflow = StateGraph(AgentState)
|
| 198 |
+
self.workflow.set_config({"recursion_limit": 50})
|
| 199 |
|
| 200 |
# Add nodes
|
| 201 |
self.workflow.add_node("agent", self.call_model)
|
|
|
|
| 322 |
logger.info(f"Executing tool: {tool_name}")
|
| 323 |
logger.info(f"Tool arguments: {json.dumps(tool_args, indent=2)}")
|
| 324 |
|
| 325 |
+
result = self.tool_node.invoke({"name": tool_name, "args": tool_args})
|
| 326 |
logger.info(f"Tool result: {result}")
|
| 327 |
|
| 328 |
messages.append(AIMessage(content=f"Tool result: {result}"))
|