Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from langgraph.prebuilt import tools_condition
|
|
| 12 |
from langgraph.graph import StateGraph, START, END
|
| 13 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 14 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 15 |
-
from langchain.chat_models import ChatOpenAI
|
| 16 |
|
| 17 |
# (Keep Constants as is)
|
| 18 |
# --- Constants ---
|
|
@@ -27,16 +27,17 @@ class BasicAgent:
|
|
| 27 |
def __init__(self):
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
|
| 30 |
-
chat =
|
| 31 |
|
| 32 |
# Set up tools
|
| 33 |
search_tool = DuckDuckGoSearchRun()
|
| 34 |
tools = [search_tool]
|
|
|
|
| 35 |
|
| 36 |
# Assistant function (process one step)
|
| 37 |
def assistant(state: AgentState):
|
| 38 |
return {
|
| 39 |
-
"messages": [
|
| 40 |
}
|
| 41 |
|
| 42 |
# Create a StateGraph
|
|
|
|
| 12 |
from langgraph.graph import StateGraph, START, END
|
| 13 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 14 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 15 |
+
from langchain.chat_models import ChatOpenAI, init_chat_model
|
| 16 |
|
| 17 |
# (Keep Constants as is)
|
| 18 |
# --- Constants ---
|
|
|
|
| 27 |
def __init__(self):
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
|
| 30 |
+
chat = init_chat_model(model="gpt-4-turbo", temperature=0)
|
| 31 |
|
| 32 |
# Set up tools
|
| 33 |
search_tool = DuckDuckGoSearchRun()
|
| 34 |
tools = [search_tool]
|
| 35 |
+
chat_with_tools = chat.bind_tools(tools)
|
| 36 |
|
| 37 |
# Assistant function (process one step)
|
| 38 |
def assistant(state: AgentState):
|
| 39 |
return {
|
| 40 |
+
"messages": [chat_with_tools.invoke(state["messages"])]
|
| 41 |
}
|
| 42 |
|
| 43 |
# Create a StateGraph
|