Cerebras Inference 通过 Cerebras Wafer-Scale Engine 和 CS-3 系统提供高速、低延迟的 AI 模型推理。Agno 直接集成 Cerebras Python SDK,让您能够通过简单的接口使用最先进的 Llama 模型。

先决条件

要将 Cerebras 与 Agno 结合使用,您需要:

  1. 安装必需的软件包:

    pip install cerebras-cloud-sdk
    
  2. 设置您的 API 密钥: Cerebras SDK 要求您的 API 密钥作为环境变量可用:

    export CEREBRAS_API_KEY=your_api_key_here
    

基本用法

以下是如何在 Agno 中使用 Cerebras 模型:

from agno.agent import Agent
from agno.models.cerebras import Cerebras

agent = Agent(
    model=Cerebras(id="llama-4-scout-17b-16e-instruct"),
    markdown=True,
)

# 在终端中打印响应
agent.print_response("write a two sentence horror story")

支持的模型

Cerebras 目前支持以下模型(有关最新列表,请参阅 文档):

模型名称模型 ID参数知识库
Llama 4 Scoutllama-4-scout-17b-16e-instruct1090亿2024年8月
Llama 3.1 8Bllama3.1-8b80亿2023年3月
Llama 3.3 70Bllama-3.3-70b700亿2023年12月
DeepSeek R1 Distill Llama 70B*deepseek-r1-distill-llama-70b700亿2023年12月

* DeepSeek R1 Distill Llama 70B 目前处于私有预览阶段。

配置选项

Cerebras 类接受以下参数:

参数类型描述默认值
idstr模型标识符(例如 “llama-4-scout-17b-16e-instruct”)必需
namestr模型的显示名称”Cerebras”
providerstr提供商名称”Cerebras”
api_keyOptional[str]API 密钥(将回退到 CEREBRAS_API_KEY 环境变量)None
max_tokensOptional[int]响应中的最大令牌数None
temperaturefloat采样温度0.7
top_pfloatTop-p 采样值1.0
request_paramsOptional[Dict[str, Any]]其他请求参数None

资源

SDK 示例

  • 在此查看更多示例 here