Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -112,24 +112,24 @@ def build_graph(provider: str):
|
|
| 112 |
temperature=0,
|
| 113 |
),
|
| 114 |
)
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
# test
|
| 135 |
if __name__ == "__main__":
|
|
|
|
| 112 |
temperature=0,
|
| 113 |
),
|
| 114 |
)
|
| 115 |
+
def assistant(state: MessagesState):
|
| 116 |
+
""" Use the tools to answer the query. you have add,subtract,multiply,divide,web_search,wikipedia_search,arxiv_search tools."""
|
| 117 |
+
response = llm_with_tools.invoke([system_message]+state["messages"])
|
| 118 |
+
#time.sleep(4) # 무료 티어의 한계
|
| 119 |
+
return {"messages": state["messages"] + [response]}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
builder = StateGraph(MessagesState)
|
| 123 |
+
builder.add_node("assistant", assistant)
|
| 124 |
+
builder.add_node("tools", ToolNode(tools))
|
| 125 |
+
builder.add_edge(START, "assistant")
|
| 126 |
+
builder.add_conditional_edges(
|
| 127 |
+
"assistant",
|
| 128 |
+
tools_condition
|
| 129 |
+
)
|
| 130 |
+
builder.add_edge("tools", "assistant")
|
| 131 |
+
|
| 132 |
+
return builder.compile()
|
| 133 |
|
| 134 |
# test
|
| 135 |
if __name__ == "__main__":
|