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。

本頁目錄