-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathagent.py
More file actions
64 lines (49 loc) · 1.87 KB
/
agent.py
File metadata and controls
64 lines (49 loc) · 1.87 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# 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.
"""
This is an example of a Parallel Agent for parallel content review.、
Main Process: Quality Review + Security Review.
Agents pass information to each other using output_key.
"""
from trpc_agent_sdk.agents import LlmAgent
from trpc_agent_sdk.agents import ParallelAgent
from trpc_agent_sdk.models import LLMModel
from trpc_agent_sdk.models import OpenAIModel
from .config import get_model_config
def _create_model() -> LLMModel:
""" Create a model"""
api_key, url, model_name = get_model_config()
model = OpenAIModel(model_name=model_name, api_key=api_key, base_url=url)
return model
def create_agent():
"""Create a Parallel Review Agent"""
model = _create_model()
# Quality Review Agent
quality_reviewer = LlmAgent(
name="quality_reviewer",
model=model,
description="Review content quality",
instruction="""Review content quality: clarity, accuracy, readability.
Provide quality score (1-10) and brief feedback. Please output in markdown format.""",
output_key="quality_review",
)
# Security Review Agent
security_reviewer = LlmAgent(
name="security_reviewer",
model=model,
description="Review content security",
instruction="""Review security concerns: data privacy, vulnerabilities.
Provide security score (1-10) and identify risks. Please output in markdown format.""",
output_key="security_review",
)
# Create a Parallel Agent
return ParallelAgent(
name="review_panel",
description="Parallel review: quality + security",
sub_agents=[quality_reviewer, security_reviewer],
)
root_agent = create_agent()