安全公告 — 恶意 litellm 版本 1.82.7 与 1.82.8 已从 PyPI 移除(存在 API 密钥外泄风险)。请卸载、轮换已暴露凭据,并升级至安全版本(如 1.82.9+)。运行 pip show litellm 以确认。 PyPI · README

快速上手

5 分钟内完成安装并运行第一个智能体。

快速上手

5 分钟内完成安装并运行第一个智能体。

1. 安装

bash
1pip install agenticx

2. 创建第一个智能体

python
1from agenticx import Agent, Task, AgentExecutor
2from agenticx.llms import OpenAIProvider
3
4# Define the agent
5agent = Agent(
6 id="data-analyst",
7 name="Data Analyst",
8 role="Data Analysis Expert",
9 goal="Help users analyze and understand data",
10 organization_id="my-org"
11)
12
13# Define a task
14task = Task(
15 id="analysis-task",
16 description="Analyze sales data trends for Q4 2025",
17 expected_output="A detailed analysis report with key insights"
18)
19
20# Run
21llm = OpenAIProvider(model="gpt-4o")
22executor = AgentExecutor(agent=agent, llm=llm)
23result = executor.run(task)
24print(result)

3. 添加工具

为智能体接入自定义函数调用能力:

python
1from agenticx.tools import tool
2from agenticx import Agent, Task, AgentExecutor
3from agenticx.llms import OpenAIProvider
4
5@tool
6def calculate_sum(x: int, y: int) -> int:
7 """Calculate the sum of two numbers."""
8 return x + y
9
10@tool
11def search_web(query: str) -> str:
12 """Search the web for information."""
13 # integrate with your search provider
14 return f"Results for: {query}"
15
16agent = Agent(
17 id="assistant",
18 name="Assistant",
19 role="General Assistant",
20 goal="Help with any task",
21 organization_id="my-org"
22)
23
24task = Task(
25 description="What is 42 + 58?",
26 expected_output="The numerical answer"
27)
28
29executor = AgentExecutor(agent=agent, llm=OpenAIProvider(), tools=[calculate_sum, search_web])
30result = executor.run(task)

4. CLI 快速入门

安装完成后即可使用 agx CLI:

bash
1# Create a new project
2agx project create my-agent --template basic
3cd my-agent
4
5# Start the Studio API server
6agx serve --port 8000
7
8# Run a workflow file
9agx run workflows/my_pipeline.py --verbose

5. 使用 Studio UI

AgenticX 内置基于 Web 的 Studio,用于管理智能体、会话与群聊:

bash
1agx serve --port 8000
2# Open http://localhost:8000 in your browser

下一步