Update app.py
Browse files
app.py
CHANGED
|
@@ -27,9 +27,8 @@ class BasicAgent:
|
|
| 27 |
def __init__(self):
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
|
| 30 |
-
chat = ChatOpenAI(model="gpt-
|
| 31 |
|
| 32 |
-
print("check1")
|
| 33 |
# llm = HuggingFaceEndpoint(
|
| 34 |
# repo_id="mistralai/Mistral-7B-Instruct-v0.2",
|
| 35 |
# huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
|
|
@@ -39,13 +38,11 @@ class BasicAgent:
|
|
| 39 |
|
| 40 |
# Set up tools
|
| 41 |
search_tool = DuckDuckGoSearchRun()
|
| 42 |
-
print("check1.1")
|
| 43 |
tools = [search_tool]
|
| 44 |
-
|
| 45 |
-
# Bind LLM with tools
|
| 46 |
-
chat_with_tools = chat.bind_tools(tools)
|
| 47 |
|
| 48 |
-
print("check2")
|
| 49 |
# Assistant function (process one step)
|
| 50 |
def assistant(state: AgentState):
|
| 51 |
return {
|
|
@@ -54,11 +51,11 @@ class BasicAgent:
|
|
| 54 |
|
| 55 |
# Create a StateGraph
|
| 56 |
builder = StateGraph(AgentState)
|
| 57 |
-
|
| 58 |
# Add nodes
|
| 59 |
builder.add_node("assistant", assistant)
|
| 60 |
builder.add_node("tools", ToolNode(tools))
|
| 61 |
-
|
| 62 |
# Define edges
|
| 63 |
builder.add_edge(START, "assistant")
|
| 64 |
builder.add_conditional_edges("assistant", tools_condition)
|
|
|
|
| 27 |
def __init__(self):
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
|
| 30 |
+
chat = ChatOpenAI(model="gpt-4o", temperature=0)
|
| 31 |
|
|
|
|
| 32 |
# llm = HuggingFaceEndpoint(
|
| 33 |
# repo_id="mistralai/Mistral-7B-Instruct-v0.2",
|
| 34 |
# huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
|
|
|
|
| 38 |
|
| 39 |
# Set up tools
|
| 40 |
search_tool = DuckDuckGoSearchRun()
|
|
|
|
| 41 |
tools = [search_tool]
|
| 42 |
+
|
| 43 |
+
# # Bind LLM with tools
|
| 44 |
+
# chat_with_tools = chat.bind_tools(tools)
|
| 45 |
|
|
|
|
| 46 |
# Assistant function (process one step)
|
| 47 |
def assistant(state: AgentState):
|
| 48 |
return {
|
|
|
|
| 51 |
|
| 52 |
# Create a StateGraph
|
| 53 |
builder = StateGraph(AgentState)
|
| 54 |
+
|
| 55 |
# Add nodes
|
| 56 |
builder.add_node("assistant", assistant)
|
| 57 |
builder.add_node("tools", ToolNode(tools))
|
| 58 |
+
|
| 59 |
# Define edges
|
| 60 |
builder.add_edge(START, "assistant")
|
| 61 |
builder.add_conditional_edges("assistant", tools_condition)
|