-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Expand file tree
/
Copy pathsmolagents_acp_server.py
More file actions
30 lines (22 loc) · 893 Bytes
/
smolagents_acp_server.py
File metadata and controls
30 lines (22 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from collections.abc import AsyncGenerator
from acp_sdk.models import Message, MessagePart
from acp_sdk.server import RunYield, RunYieldResume, Server
from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool
import warnings
warnings.filterwarnings("ignore")
server = Server()
model = LiteLLMModel(
model_id="ollama_chat/qwen2.5:14b",
api_base="http://localhost:11434",
# api_key="your-api-key",
num_ctx=8192
)
@server.agent()
async def research_verifier(input: list[Message]) -> AsyncGenerator[RunYield, RunYieldResume]:
"""Agent that fact-checks and enhances a research summary using web search."""
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
prompt = input[0].parts[0].content
response = agent.run(prompt)
yield Message(parts=[MessagePart(content=str(response))])
if __name__ == "__main__":
server.run(port=8001)