Spaces:
Runtime error
Runtime error
Added history
Browse files
app.py
CHANGED
|
@@ -29,14 +29,20 @@ MCP_SERVERS = [
|
|
| 29 |
tools = get_mcp_tools(MCP_SERVERS)
|
| 30 |
|
| 31 |
model = InferenceClientModel(token=os.getenv("HF_TOKEN"))
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
chat = gr.ChatInterface(
|
| 35 |
-
fn=lambda message, history: str(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
type="messages",
|
| 37 |
examples=["Prime factorization of 68"],
|
| 38 |
title="Agent with MCP Tools",
|
| 39 |
-
description="This is a simple agent that uses MCP tools to answer questions."
|
|
|
|
| 40 |
)
|
| 41 |
|
| 42 |
chat.launch()
|
|
|
|
| 29 |
tools = get_mcp_tools(MCP_SERVERS)
|
| 30 |
|
| 31 |
model = InferenceClientModel(token=os.getenv("HF_TOKEN"))
|
| 32 |
+
# @TODO: Change promot to ask for clarifications if necessary and set final answer.
|
| 33 |
+
agent = CodeAgent(tools=[*tools], model=model, max_steps=8, planning_interval=2)
|
| 34 |
|
| 35 |
chat = gr.ChatInterface(
|
| 36 |
+
fn=lambda message, history: str(
|
| 37 |
+
agent.run(
|
| 38 |
+
"\n".join([str(x) for x in history[-10:]]) if history else "" + message
|
| 39 |
+
)
|
| 40 |
+
),
|
| 41 |
type="messages",
|
| 42 |
examples=["Prime factorization of 68"],
|
| 43 |
title="Agent with MCP Tools",
|
| 44 |
+
description="This is a simple agent that uses MCP tools to answer questions.",
|
| 45 |
+
save_history=True,
|
| 46 |
)
|
| 47 |
|
| 48 |
chat.launch()
|