forked from trpc-group/trpc-agent-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
35 lines (27 loc) · 1.06 KB
/
Copy pathagent.py
File metadata and controls
35 lines (27 loc) · 1.06 KB
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
31
32
33
34
35
# Tencent is pleased to support the open source community by making tRPC-Agent-Python available.
#
# Copyright (C) 2026 Tencent. All rights reserved.
#
# tRPC-Agent-Python is licensed under Apache-2.0.
"""Usage: LiteLLMModel(provider/model) -> LlmAgent(model=...)."""
from trpc_agent_sdk.agents import LlmAgent
from trpc_agent_sdk.models import LiteLLMModel
from trpc_agent_sdk.tools import FunctionTool
from .config import get_model_config
from .prompts import INSTRUCTION
from .tools import get_weather_report
def _model(model_name: str | None = None):
api_key, base_url, default_name = get_model_config()
name = model_name if model_name is not None else default_name
kwargs = {"api_key": api_key}
if base_url:
kwargs["api_base"] = base_url
return LiteLLMModel(model_name=name, **kwargs)
def create_agent(model_name: str | None = None) -> LlmAgent:
return LlmAgent(
name="weather_agent",
model=_model(model_name),
instruction=INSTRUCTION,
tools=[FunctionTool(get_weather_report)],
)
root_agent = create_agent()