Spaces:
Sleeping
Sleeping
fix bugs
Browse files- Agents/agent.py +10 -12
- app.py +2 -2
Agents/agent.py
CHANGED
|
@@ -66,16 +66,6 @@ tools = [
|
|
| 66 |
remainder
|
| 67 |
]
|
| 68 |
|
| 69 |
-
def use_react_agent():
|
| 70 |
-
graph = create_react_agent(
|
| 71 |
-
"anthropic:claude-3-7-sonnet-latest",
|
| 72 |
-
tools=[check_weather],
|
| 73 |
-
prompt="You are a helpful assistant",
|
| 74 |
-
)
|
| 75 |
-
inputs = {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
|
| 76 |
-
for chunk in graph.stream(inputs, stream_mode="updates"):
|
| 77 |
-
print(chunk)
|
| 78 |
-
|
| 79 |
def build_graph(provider: str="groq"):
|
| 80 |
if provider== "groq":
|
| 81 |
print(f"Running llm groq")
|
|
@@ -115,12 +105,20 @@ def build_graph(provider: str="groq"):
|
|
| 115 |
'''
|
| 116 |
builder = StateGraph(MessagesState)
|
| 117 |
print(f"running builder ")
|
|
|
|
| 118 |
directPath = bool(os.getenv("DirectPath"))
|
| 119 |
#builder.add_node("retriever",retriever)
|
| 120 |
builder.add_node("assistant",assistant)
|
| 121 |
builder.add_node("tools", ToolNode(tools))
|
| 122 |
builder.add_edge(START,"assistant")
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
builder.add_edge("assistant","tools")
|
| 125 |
builder.add_edge("tools",END)
|
| 126 |
else:
|
|
@@ -130,7 +128,7 @@ def build_graph(provider: str="groq"):
|
|
| 130 |
tools_condition,
|
| 131 |
{"tools": "tools", "__end__": "__end__"}
|
| 132 |
)
|
| 133 |
-
builder.add_edge("tools","assistant")
|
| 134 |
|
| 135 |
return builder.compile()
|
| 136 |
|
|
|
|
| 66 |
remainder
|
| 67 |
]
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def build_graph(provider: str="groq"):
|
| 70 |
if provider== "groq":
|
| 71 |
print(f"Running llm groq")
|
|
|
|
| 105 |
'''
|
| 106 |
builder = StateGraph(MessagesState)
|
| 107 |
print(f"running builder ")
|
| 108 |
+
print(f"DirectPath = {os.getenv("DirectPath")} ")
|
| 109 |
directPath = bool(os.getenv("DirectPath"))
|
| 110 |
#builder.add_node("retriever",retriever)
|
| 111 |
builder.add_node("assistant",assistant)
|
| 112 |
builder.add_node("tools", ToolNode(tools))
|
| 113 |
builder.add_edge(START,"assistant")
|
| 114 |
+
|
| 115 |
+
builder.add_conditional_edges(
|
| 116 |
+
"assistant",
|
| 117 |
+
tools_condition,
|
| 118 |
+
{"tools": "tools", "__end__": "__end__"}
|
| 119 |
+
)
|
| 120 |
+
builder.add_edge("tools","assistant")
|
| 121 |
+
'''if(directPath):
|
| 122 |
builder.add_edge("assistant","tools")
|
| 123 |
builder.add_edge("tools",END)
|
| 124 |
else:
|
|
|
|
| 128 |
tools_condition,
|
| 129 |
{"tools": "tools", "__end__": "__end__"}
|
| 130 |
)
|
| 131 |
+
builder.add_edge("tools","assistant")'''
|
| 132 |
|
| 133 |
return builder.compile()
|
| 134 |
|
app.py
CHANGED
|
@@ -22,8 +22,8 @@ class ReactAgent:
|
|
| 22 |
def __init__(self):
|
| 23 |
print(f"tools: {tools}")
|
| 24 |
print(f"prompt : {systemPrompt}")
|
| 25 |
-
graph = create_react_agent(
|
| 26 |
-
"anthropic:claude-3-7-sonnet-latest",
|
| 27 |
tools=tools,
|
| 28 |
prompt=systemPrompt,
|
| 29 |
)
|
|
|
|
| 22 |
def __init__(self):
|
| 23 |
print(f"tools: {tools}")
|
| 24 |
print(f"prompt : {systemPrompt}")
|
| 25 |
+
graph = create_react_agent("qwen:qwen3-32b",
|
| 26 |
+
#"anthropic:claude-3-7-sonnet-latest",
|
| 27 |
tools=tools,
|
| 28 |
prompt=systemPrompt,
|
| 29 |
)
|