orientxorientx

CrewAI

通过兼容 OpenAI 的 LLM 构建多智能体团队

CrewAI 接受指向任意兼容 OpenAI 的 /v1 主机的 LLM 对象。模型名称需使用 openai/ 前缀。

Base URLhttps://api.orientx.ai/v1
身份验证ORIENTX_API_KEY
模型openai/<MODEL_ID>
官方文档连接任意 LLM

安装

pip install crewai

接入 LLM

import os
from crewai import Agent, Crew, LLM, Task

llm = LLM(
    model="openai/<MODEL_ID>",
    base_url="https://api.orientx.ai/v1",
    api_key=os.environ["ORIENTX_API_KEY"],
)

researcher = Agent(
    role="Researcher",
    goal="Summarize what an API gateway does",
    backstory="You write short, precise technical notes.",
    llm=llm,
)

task = Task(
    description="Explain an API gateway in two sentences.",
    expected_output="Two sentences.",
    agent=researcher,
)

Crew(agents=[researcher], tasks=[task]).kickoff()

将相同的 llm= 传给每个需要调用 orientx 的智能体。

也可以导出 OPENAI_API_BASE=https://api.orientx.ai/v1 和 OPENAI_API_KEY, 代替向 LLM() 传入 base_url / api_key。

本页目录