跳到内容

GroqLLM

Groq API 实现,使用异步客户端进行并发文本生成。

属性

  • model: 来自 Groq API 的模型名称,用于生成。

  • base_url: 用于 Groq API 请求的基础 URL。默认为 "https://api.groq.com"

  • api_key: 用于验证对 Groq API 请求的 API 密钥。默认为 GROQ_API_KEY 环境变量的值。

  • max_retries: 在失败之前,重试 API 请求的最大次数。默认为 2

  • timeout: 等待 API 响应的最长时间(秒)。默认为 120

  • structured_output: 一个字典,包含使用 instructor 的结构化输出配置。您可以查看 distilabel.steps.tasks.structured_outputs.instructor 中的 InstructorStructuredOutputType 的字典结构。

  • _api_key_env_var: 用于 API 密钥的环境变量名称。

  • _aclient: 来自 groq 包的 AsyncGroq 客户端。

运行时参数

  • base_url: 用于 Groq API 请求的基础 URL。默认为 "https://api.groq.com"

  • api_key: 用于验证对 Groq API 请求的 API 密钥。默认为 GROQ_API_KEY 环境变量的值。

  • max_retries: 在失败之前,重试 API 请求的最大次数。默认为 2

  • timeout: 等待 API 响应的最长时间(秒)。默认为 120

示例

生成文本

from distilabel.models.llms import GroqLLM

llm = GroqLLM(model="llama3-70b-8192")

llm.load()

# Call the model
output = llm.generate_outputs(inputs=[[{"role": "user", "content": "Hello world!"}]])

Generate structured data: