Update agent/agent.py
Browse files- agent/agent.py +29 -29
agent/agent.py
CHANGED
|
@@ -1,29 +1,29 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from typing import TypedDict, List, Dict, Any, Optional
|
| 3 |
-
from
|
| 4 |
-
from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage, AIMessage
|
| 5 |
-
from langgraph.grap.message import add_messages
|
| 6 |
-
from langgraph.graph import START, StateGraph
|
| 7 |
-
from langgraph.prebuilt import ToolNode, tools_condition
|
| 8 |
-
|
| 9 |
-
from tools.search_tool import search_tool
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
# --- zBottaAgent Definition ---
|
| 13 |
-
|
| 14 |
-
class zBottaAgent:
|
| 15 |
-
def __init__(self):
|
| 16 |
-
print("zBottaAgent initialized.")
|
| 17 |
-
chat = ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0.7)
|
| 18 |
-
tools = [search_tool]
|
| 19 |
-
self.chat_with_tools = chat.bind_tools(tools)
|
| 20 |
-
|
| 21 |
-
def __call__(self, question: str) -> str:
|
| 22 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 23 |
-
messages = [
|
| 24 |
-
SystemMessage(content="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer. Your answer should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."),
|
| 25 |
-
HumanMessage(content=question)
|
| 26 |
-
]
|
| 27 |
-
response = self.chat_with_tools.invoke(messages)
|
| 28 |
-
print(f"Agent returning response: {response}")
|
| 29 |
-
return response
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from typing import TypedDict, List, Dict, Any, Optional
|
| 3 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 4 |
+
from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage, AIMessage
|
| 5 |
+
from langgraph.grap.message import add_messages
|
| 6 |
+
from langgraph.graph import START, StateGraph
|
| 7 |
+
from langgraph.prebuilt import ToolNode, tools_condition
|
| 8 |
+
|
| 9 |
+
from tools.search_tool import search_tool
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# --- zBottaAgent Definition ---
|
| 13 |
+
|
| 14 |
+
class zBottaAgent:
|
| 15 |
+
def __init__(self):
|
| 16 |
+
print("zBottaAgent initialized.")
|
| 17 |
+
chat = ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0.7)
|
| 18 |
+
tools = [search_tool]
|
| 19 |
+
self.chat_with_tools = chat.bind_tools(tools)
|
| 20 |
+
|
| 21 |
+
def __call__(self, question: str) -> str:
|
| 22 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 23 |
+
messages = [
|
| 24 |
+
SystemMessage(content="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer. Your answer should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."),
|
| 25 |
+
HumanMessage(content=question)
|
| 26 |
+
]
|
| 27 |
+
response = self.chat_with_tools.invoke(messages)
|
| 28 |
+
print(f"Agent returning response: {response}")
|
| 29 |
+
return response
|