-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathagent.py
More file actions
41 lines (31 loc) · 1.22 KB
/
agent.py
File metadata and controls
41 lines (31 loc) · 1.22 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
36
37
38
39
40
41
# 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.
"""Agent module"""
from trpc_agent_sdk.agents import LlmAgent
from trpc_agent_sdk.models import LLMModel
from trpc_agent_sdk.models import OpenAIModel
from .config import get_model_config
from .prompts import MAIN_INSTRUCTION
from .tools import create_translator_tool
def _create_model() -> LLMModel:
"""Create a model"""
api_key, url, model_name = get_model_config()
return OpenAIModel(model_name=model_name, api_key=api_key, base_url=url)
def create_agent() -> LlmAgent:
"""Create a main agent with an AgentTool for translation.
The translator agent is wrapped as an AgentTool so the main agent
can delegate translation tasks through tool invocation.
"""
model = _create_model()
translator_tool = create_translator_tool(model)
return LlmAgent(
name="content_processor",
description="A content processing assistant that can invoke translation tools",
model=model,
instruction=MAIN_INSTRUCTION,
tools=[translator_tool],
)
root_agent = create_agent()