Skip to content

Commit 90289c8

Browse files
raylchenraychen911
authored andcommitted
docs: 更新文档
1 parent c19a76f commit 90289c8

26 files changed

Lines changed: 136 additions & 90 deletions

docs/mkdocs/en/knowledge_vectorstore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ The complete example is available at [knowledge_with_vectorstore](../../../examp
614614

615615
Steps to run the example:
616616

617-
1. Configure environment variables in `examples/knowledge_with_vectorstore/.env`, set `VECTORSTORE_TYPE=tencentvdb` and fill in the Tencent Cloud VectorDB connection parameters:
617+
1. Configure environment variables in [examples/knowledge_with_vectorstore/.env](../../../examples/knowledge_with_vectorstore/.env), set `VECTORSTORE_TYPE=tencentvdb` and fill in the Tencent Cloud VectorDB connection parameters:
618618

619619
```bash
620620
VECTORSTORE_TYPE=tencentvdb

docs/mkdocs/en/langgraph_agent.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ A graph is the core structure of a workflow, composed of nodes and edges, used t
6565

6666
```python
6767
from langgraph.graph import StateGraph, START, END
68+
from langgraph.prebuilt import ToolNode
69+
70+
from trpc_agent_sdk.agents import langgraph_llm_node
71+
from trpc_agent_sdk.dsl.graph import State
72+
73+
class MyState(State):
74+
result: str
75+
76+
@langgraph_llm_node
77+
def chatbot_node(state: State):
78+
"""Chatbot node that can use tools."""
79+
return {"messages": [llm_with_tools.invoke(state["messages"])]}
80+
81+
graph_builder = StateGraph(State)
82+
83+
# Add tool node
84+
tool_node = ToolNode(tools=[])
85+
graph_builder.add_node("tools", tool_node)
6886

6987
graph_builder = StateGraph(MyState)
7088
graph_builder.add_node("chatbot", chatbot_node)
@@ -99,7 +117,7 @@ For tool nodes, they are typically used with the `@tool` and `@tool_node` decora
99117

100118
```python
101119
from langchain_core.tools import tool
102-
from trpc_agent_sdk.agents.langgraph_agent import tool_node
120+
from trpc_agent_sdk.agents import tool_node
103121

104122
@tool
105123
@tool_node
@@ -154,7 +172,7 @@ Its purpose is to:
154172
What `LangGraphAgent` actually accepts is not the `StateGraph` builder itself, but the graph object after `compile()`. The framework's `LangGraphAgent` explicitly requires a compiled graph as input.
155173

156174
```python
157-
from trpc_agent_sdk.agents.langgraph_agent import LangGraphAgent
175+
from trpc_agent_sdk.agents import LangGraphAgent
158176

159177
graph = graph_builder.compile()
160178

@@ -180,7 +198,7 @@ A LangGraphAgent can be created by providing a compiled LangGraph graph, as show
180198
The other parameters follow the same definitions as in `LlmAgent`.
181199

182200
```python
183-
from trpc_agent_sdk.agents.langgraph_agent import LangGraphAgent
201+
from trpc_agent_sdk.agents import LangGraphAgent
184202

185203
# Assume the LangGraph has already been built
186204
graph = build_your_langgraph()
@@ -198,13 +216,13 @@ agent = LangGraphAgent(
198216
### Basic Graph Structure
199217

200218
```python
219+
from typing import Annotated
220+
from typing_extensions import TypedDict
201221
from langchain.chat_models import init_chat_model
202222
from langchain_core.tools import tool
203223
from langgraph.graph import StateGraph, START
204224
from langgraph.graph.message import add_messages
205225
from langgraph.prebuilt import tools_condition, ToolNode
206-
from typing_extensions import TypedDict
207-
from typing import Annotated
208226

209227
# Define the state structure
210228
class State(TypedDict):
@@ -256,7 +274,7 @@ def custom_chatbot(state: CustomState):
256274
Used to decorate tool execution nodes, automatically recording tool invocation information. Note that @tool_node must be placed after LangGraph's @tool decorator:
257275

258276
```python
259-
from trpc_agent_sdk.agents.langgraph_agent import tool_node
277+
from trpc_agent_sdk.agents import tool_node
260278
from langchain_core.tools import tool
261279

262280
@tool
@@ -303,7 +321,7 @@ runner.run_async(..., run_config=run_config)
303321
After receiving an `Event`, you can access the raw LangGraph payload as shown below:
304322

305323
```python
306-
from trpc_agent_sdk.agents.langgraph_agent import get_langgraph_payload
324+
from trpc_agent_sdk.agents import get_langgraph_payload
307325

308326
async for event in runner.run_async(...):
309327
langgraph_payload = get_langgraph_payload(event)
@@ -318,7 +336,7 @@ async for event in runner.run_async(...):
318336
Within LangGraph nodes, you can access `trpc_agent` context information:
319337

320338
```python
321-
from trpc_agent_sdk.agents.langgraph_agent import get_langgraph_agent_context
339+
from trpc_agent_sdk.agents import get_langgraph_agent_context
322340

323341
@langgraph_llm_node
324342
def context_aware_node(state: State, config: RunnableConfig):
@@ -448,7 +466,7 @@ from typing import AsyncGenerator
448466
from ag_ui.core import BaseEvent, EventType, CustomEvent
449467
from trpc_agent_sdk.events import Event as TrpcEvent
450468
from trpc_agent_sdk.agents.utils import LangGraphEventType, get_event_type
451-
from trpc_agent_sdk.server.ag_ui._plugin._langgraph_event_translator import (
469+
from trpc_agent_sdk.server.ag_ui import (
452470
AgUiLangGraphEventTranslator,
453471
AgUiTranslationContext,
454472
)

docs/mkdocs/en/llm_agent.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ Using thinking mode requires configuring the following components:
505505
- `thinking_budget`: Token budget for the thinking process, must be less than `max_output_tokens`
506506

507507
```python
508-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
508+
from trpc_agent_sdk.agents import LlmAgent
509509
from trpc_agent_sdk.models import LLMModel, OpenAIModel
510510
from trpc_agent_sdk.tools import FunctionTool
511511
from trpc_agent_sdk.types import GenerateContentConfig
@@ -577,6 +577,7 @@ The framework supports passing an async function as a model creation callback to
577577
from trpc_agent_sdk.agents import LlmAgent
578578
from trpc_agent_sdk.models import OpenAIModel, LLMModel
579579
from trpc_agent_sdk.configs import RunConfig
580+
from trpc_agent_sdk.runners import Runner
580581

581582
async def create_model(custom_data: dict) -> LLMModel:
582583
"""Model creation callback function
@@ -637,6 +638,8 @@ The implementation mechanism of output_schema has two different methods dependin
637638
from pydantic import BaseModel
638639
from typing import List
639640

641+
from trpc_agent_sdk.agents import LlmAgent
642+
640643
class UserProfileOutput(BaseModel):
641644
"""Output schema for user profile analysis."""
642645
user_name: str
@@ -671,6 +674,8 @@ LlmAgent also supports structured input (input_schema), which is generally used
671674
```python
672675
from pydantic import BaseModel
673676
from typing import List, Optional
677+
678+
from trpc_agent_sdk.agents import LlmAgent
674679
from trpc_agent_sdk.tools import AgentTool
675680

676681
class UserProfileInput(BaseModel):

docs/mkdocs/en/memory.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Core Capabilities of MemoryService
2020

21-
Based on the implementation in `trpc_agent_sdk/memory/`, MemoryService provides the following core capabilities:
21+
Based on the implementation in [trpc_agent_sdk/memory/](../../../trpc_agent_sdk/memory/), MemoryService provides the following core capabilities:
2222

2323
### 1. Storing Session Memory
2424

@@ -76,7 +76,7 @@ async def search_memory(self, key: str, query: str, limit: int = 10, ...) -> Sea
7676
event_ttl.update_expired_at()
7777
```
7878

79-
**Keyword Extraction** (`_utils.py`):
79+
**Keyword Extraction** ([_utils.py](../../../trpc_agent_sdk/memory/_utils.py)):
8080
```python
8181
def extract_words_lower(text: str) -> set[str]:
8282
"""Extract English words and Chinese characters"""
@@ -234,8 +234,8 @@ memory_service = InMemoryMemoryService(memory_service_config=memory_service_conf
234234

235235
**Configuration Example**:
236236
```python
237-
from trpc_agent_sdk.memory import RedisMemoryService, MemoryServiceConfig
238237
import os
238+
from trpc_agent_sdk.memory import RedisMemoryService, MemoryServiceConfig
239239

240240
# Read Redis configuration from environment variables
241241
db_host = os.environ.get("REDIS_HOST", "127.0.0.1")
@@ -308,8 +308,8 @@ EXPIRE memory:weather_app/user_001:session_1 86400 # Expires after 24 hours
308308

309309
**Configuration Example**:
310310
```python
311-
from trpc_agent_sdk.memory import SqlMemoryService, MemoryServiceConfig
312311
import os
312+
from trpc_agent_sdk.memory import SqlMemoryService, MemoryServiceConfig
313313

314314
# Read MySQL configuration from environment variables
315315
db_user = os.environ.get("MYSQL_USER", "root")
@@ -413,7 +413,8 @@ async def _cleanup_expired_async(self) -> None:
413413

414414
```python
415415
from trpc_agent_sdk.sessions import InMemorySessionService
416-
from trpc_agent_sdk.memory import InMemoryMemoryService, MemoryServiceConfig
416+
from trpc_agent_sdk.memory import MemoryServiceConfig
417+
from trpc_agent_sdk.memory import InMemoryMemoryService
417418
from trpc_agent_sdk.runners import Runner
418419
from trpc_agent_sdk.types import Content, Part
419420

@@ -1234,7 +1235,7 @@ Through proper use of MemoryService, you can achieve:
12341235
- Cross-session knowledge sharing
12351236
- Intelligent conversation context
12361237

1237-
For more detailed usage examples, please refer to the related examples in the `examples/` directory.
1238+
For more detailed usage examples, please refer to the related examples in the [examples/](../../../examples/) directory.
12381239

12391240
- [examples/memory_service_with_in_memory/run_agent.py](../../../examples/memory_service_with_in_memory/run_agent.py)
12401241
- [examples/memory_service_with_redis/run_agent.py](../../../examples/memory_service_with_redis/run_agent.py)

docs/mkdocs/en/model.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export TRPC_AGENT_MODEL_NAME="your-model-name"
221221

222222
```python
223223
from trpc_agent_sdk.models import LiteLLMModel
224-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
224+
from trpc_agent_sdk.agents import LlmAgent
225225

226226
model = LiteLLMModel(
227227
model_name="openai/gpt-4o", # Required: provider/model
@@ -236,7 +236,7 @@ LlmAgent(..., model=model, instruction="...")
236236
Without explicitly instantiating `LiteLLMModel`, you can pass only the model name string; the framework uses `ModelRegistry`'s `supported_models` regex patterns to match and create a LiteLLMModel instance. In this case, the API Key, base_url, and other settings rely on environment variables (e.g., `OPENAI_API_KEY`, `OPENAI_API_BASE`).
237237

238238
```python
239-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
239+
from trpc_agent_sdk.agents import LlmAgent
240240

241241
LlmAgent(..., model="openai/gpt-4o", instruction="...")
242242
```

docs/mkdocs/en/multi_agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Content Processing Assistant (Main Agent)
442442

443443
TransferAgent is a transfer proxy Agent designed to enable custom Agents without transfer capability (such as `TrpcRemoteA2aAgent`) to gain transfer capability, thereby integrating them into the tRPC-Agent framework's multi-Agent system.
444444

445-
`TrpcRemoteA2aAgent` can be used to simulate a remote Agent scenario (first start an A2A Agent service with `examples/a2a/run_server.py` to mimic a remote Agent).
445+
`TrpcRemoteA2aAgent` can be used to simulate a remote Agent scenario (first start an A2A Agent service with [examples/a2a/run_server.py](../../../examples/a2a/run_server.py) to mimic a remote Agent).
446446

447447
Through TransferAgent, custom Agents can:
448448
- **Act as sub_agent**: The parent Agent can transfer control to this Agent, and this Agent can transfer control to parent/sibling Agents

docs/mkdocs/en/session.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In trpc-agent, `SessionService` is used to manage `Session` (sessions). A `Sessi
2222

2323
### Core Structure of Session
2424

25-
Based on the implementation in `trpc_agent/sessions/_session.py`, a `Session` contains the following key fields:
25+
Based on the implementation in [trpc_agent_sdk/sessions/_session.py](../../../trpc_agent_sdk/sessions/_session.py), a `Session` contains the following key fields:
2626

2727
#### 1. Identity
2828

@@ -84,7 +84,7 @@ def extract_state_delta(state_delta: Optional[dict[str, Any]]) -> StateStorageEn
8484

8585
### Core Features of SessionService
8686

87-
Based on the implementation in `trpc_agent/sessions/`, `SessionService` provides the following core features:
87+
Based on the implementation in [trpc_agent_sdk/sessions/](../../../trpc_agent_sdk/sessions/), `SessionService` provides the following core features:
8888

8989
#### 1. Session Management (CRUD)
9090

@@ -700,7 +700,7 @@ The following examples demonstrate the usage of different SessionService impleme
700700

701701
#### InMemorySessionService
702702

703-
📁 **Example Path**: `examples/session_service_with_in_memory/`
703+
📁 **Example Path**: [examples/session_service_with_in_memory/](../../../examples/session_service_with_in_memory/)
704704

705705
**Description**:
706706
- Demonstrates basic usage of In-Memory Session Service
@@ -718,7 +718,7 @@ python3 run_agent.py
718718

719719
#### RedisSessionService
720720

721-
📁 **Example Path**: `examples/session_service_with_redis/`
721+
📁 **Example Path**: [examples/session_service_with_redis/](../../../examples/session_service_with_redis/)
722722

723723
**Description**:
724724
- Demonstrates Redis Session Service usage
@@ -736,7 +736,7 @@ python3 run_agent.py
736736

737737
#### SqlSessionService
738738

739-
📁 **Example Path**: `examples/session_service_with_sql/`
739+
📁 **Example Path**: [examples/session_service_with_sql/](../../../examples/session_service_with_sql/)
740740

741741
**Description**:
742742
- Demonstrates SQL Session Service usage
@@ -808,7 +808,7 @@ By properly using SessionService, you can achieve:
808808
- Application-level state sharing
809809
- Session lifecycle management
810810

811-
For more detailed usage examples, refer to the related examples in the `examples/` directory.
811+
For more detailed usage examples, refer to the related examples in the [examples/](../../../examples/) directory.
812812

813813
- [examples/session_service_with_in_memory/run_agent.py](../../../examples/session_service_with_in_memory/run_agent.py)
814814
- [examples/session_service_with_redis/run_agent.py](../../../examples/session_service_with_redis/run_agent.py)

docs/mkdocs/en/skill.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Create a skill repository and a workspace executor. If no executor is specified,
9696

9797
```python
9898
import os
99-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
99+
from trpc_agent_sdk.agents import LlmAgent
100100
from trpc_agent_sdk.models import OpenAIModel
101101
from trpc_agent_sdk.skills import SkillToolSet
102102
from trpc_agent_sdk.skills import create_default_skill_repository
@@ -1428,7 +1428,7 @@ def create_skill_dynamic_tool_set(skill_repository: BaseSkillRepository, only_ac
14281428
)
14291429

14301430
# agent/agent.py
1431-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
1431+
from trpc_agent_sdk.agents import LlmAgent
14321432
from .tools import create_skill_tool_set, create_skill_dynamic_tool_set
14331433

14341434
def create_agent():
@@ -1692,7 +1692,7 @@ Here are the results for your requests:
16921692

16931693
#### Scenario: Real-World Project Example
16941694

1695-
Based on the actual implementation in `examples/skills_with_dynamic_tools/`:
1695+
Based on the actual implementation in [examples/skills_with_dynamic_tools/](../../../examples/skills_with_dynamic_tools/):
16961696

16971697
```python
16981698
# 1. Define all tools (agent/tools/_tools.py)
@@ -2001,7 +2001,7 @@ print(f"Tools state: {ctx.session_state.get(key)}")
20012001

20022002
#### ✅ Run Results Match Expectations Exactly
20032003

2004-
Based on actual run results from `examples/skills_with_dynamic_tools/run_agent.py`:
2004+
Based on actual run results from [examples/skills_with_dynamic_tools/run_agent.py](../../../examples/skills_with_dynamic_tools/run_agent.py):
20052005

20062006
##### 1. Tool Discovery Mechanism Works Correctly
20072007
```

docs/mkdocs/en/tool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ If `cwd` is not specified, the tools will use the current working directory.
971971
If you need to use a specific tool individually, you can import and add them one by one:
972972

973973
```python
974-
from trpc_agent_sdk.agents.llm_agent import LlmAgent
974+
from trpc_agent_sdk.agents import LlmAgent
975975
from trpc_agent_sdk.tools.file_tools import ReadTool, WriteTool, EditTool, GrepTool, BashTool, GlobTool
976976

977977
# Create the working directory

docs/mkdocs/zh/knowledge_vectorstore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ print(docs[0].page_content)
614614

615615
示例运行步骤:
616616

617-
1.`examples/knowledge_with_vectorstore/.env` 中配置环境变量,设置 `VECTORSTORE_TYPE=tencentvdb` 并填写腾讯云向量数据库连接参数:
617+
1.[examples/knowledge_with_vectorstore/.env](../../../examples/knowledge_with_vectorstore/.env) 中配置环境变量,设置 `VECTORSTORE_TYPE=tencentvdb` 并填写腾讯云向量数据库连接参数:
618618

619619
```bash
620620
VECTORSTORE_TYPE=tencentvdb

0 commit comments

Comments
 (0)