快速上手
5 分钟内完成安装并运行第一个智能体。
快速上手
5 分钟内完成安装并运行第一个智能体。
1. 安装
bash
1pip install agenticx
2. 创建第一个智能体
python
1from agenticx import Agent, Task, AgentExecutor2from agenticx.llms import OpenAIProvider34# Define the agent5agent = 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)1213# Define a task14task = 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)1920# Run21llm = OpenAIProvider(model="gpt-4o")22executor = AgentExecutor(agent=agent, llm=llm)23result = executor.run(task)24print(result)
3. 添加工具
为智能体接入自定义函数调用能力:
python
1from agenticx.tools import tool2from agenticx import Agent, Task, AgentExecutor3from agenticx.llms import OpenAIProvider45@tool6def calculate_sum(x: int, y: int) -> int:7 """Calculate the sum of two numbers."""8 return x + y910@tool11def search_web(query: str) -> str:12 """Search the web for information."""13 # integrate with your search provider14 return f"Results for: {query}"1516agent = Agent(17 id="assistant",18 name="Assistant",19 role="General Assistant",20 goal="Help with any task",21 organization_id="my-org"22)2324task = Task(25 description="What is 42 + 58?",26 expected_output="The numerical answer"27)2829executor = AgentExecutor(agent=agent, llm=OpenAIProvider(), tools=[calculate_sum, search_web])30result = executor.run(task)
4. CLI 快速入门
安装完成后即可使用 agx CLI:
bash
1# Create a new project2agx project create my-agent --template basic3cd my-agent45# Start the Studio API server6agx serve --port 800078# Run a workflow file9agx run workflows/my_pipeline.py --verbose
5. 使用 Studio UI
AgenticX 内置基于 Web 的 Studio,用于管理智能体、会话与群聊:
bash
1agx serve --port 80002# Open http://localhost:8000 in your browser