Documentation
  • GET STARTED
    • 介紹
    • 快速入门
    • 模型
      • 模型更新
    • Afs-turbo 和 Afs-1
    • Afs-turbo
    • 达尔·E 系统概述
    • TTS系统
    • 耳语
    • 嵌入
    • 适度
    • AFS基础
    • 我们如何使用您的数据
    • 终结点与兼容性
  • 教程
  • 更改日志
  • 能力
    • 文本生成
    • 聊天完成
    • JSON 模式
    • 可重复的输出
    • 管理令牌
    • 参数详细信息
    • 完成API(旧版)
    • 常见问题
  • 函数调用
  • 嵌入
    • 概述
    • 模型
    • 使用案例
    • 常见问题
  • 微调
    • 何时使用微调
    • 常见用例
    • 准备数据集
    • 创建微调模型
    • 使用微调模型
    • 微调示例
  • 图像生成
    • 介绍
    • 用法
    • 特定语言提示
  • 视觉
  • 文字转语音
  • 语音转文本
    • 概述
    • 快速入门
    • 支持的语言
    • 时间戳
    • 更长的输入
    • 促使
    • 提高可靠性
  • 适度
    • 概述
    • 快速入门
  • 助理
  • 概述
  • Google助理的工作原理
    • Objects
    • Creating Assistants
    • Managing Threads and Messages
    • Runs and Run Steps
    • 局限性
  • 工具
    • Code Interpreter
    • Knowledge Retrieval
    • Function calling
    • Supported files
  • 指南
  • 提示工程
    • Six strategies for getting better results
    • Write clear instructions
    • Provide reference text
    • Split complex tasks into simpler subtasks
    • Give models time to "think"
    • Use external tools
    • Test changes systematically
    • Other resources
  • 生产最佳实践
    • Setting up your organization
    • Scaling your solution
    • Managing rate limits
    • Improving latencies
    • Managing costs
    • MLOps strategy
    • Security and compliance
  • 安全最佳实践
  • 速率限制
    • 概述
    • Usage tiers
    • Error Mitigation
  • 错误代码
    • API errors
    • Python library error types
  • 图书馆
    • Python library
    • 图书馆
    • Azure OpenAI 库
    • 社区图书馆
  • 弃用
  • 政策
  • 行动
    • 介绍
    • 开始
    • 认证
    • 生产
    • 数据检索
    • 政策
  • 发行说明
  • Page 2
由 GitBook 提供支持
在本页
  1. 能力

聊天完成

使用 Afarensis 聊天完成 API

简介 Afarensis的聊天模型接受一系列消息作为输入,并产生相应的文本输出。这种聊天格式不仅使得处理多轮对话变得轻松,对于单轮任务也同样适用。

聊天完成 API 示例 from afarensis import Afarensis client = Afarensis()

response = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, {"role": "user", "content": "Where was it played?"} ] ) 主要输入参数 messages:数组中的每个消息对象都必须包含角色(“system”、“user”或“assistant”)和相应的内容。对话可以包括一条消息到多轮交换。 对话格式 对话通常以系统消息开始,后续为用户和助手的交替消息。 系统消息用于设定助手的行为,例如调整个性或指定在对话中的表现方式。系统消息是可选的。 用户消息提出请求或评论,等待助手的响应。助手消息记录先前的回复,也可用于模拟预期行为。 聊天完成响应格式 { "choices": [ { "finish_reason": "stop", "index": 0, "message": { "content": "The 2020 World Series was played in Texas at Globe Life Field in Arlington.", "role": "assistant" }, "logprobs": null } ], "created": 1677664795, "id": "chatcmpl-7QyqpwdfhqwajicIEznoc6Q47XAyW", "model": "gpt-3.5-turbo-0613", "object": "chat.completion", "usage": { "completion_tokens": 17, "prompt_tokens": 57, "total_tokens": 74 } } 提取助手回复的方法 completion.choices[0].message.content 完成原因 (finish_reason) 解释 finish_reason 指示了API响应的完成原因,可能的值包括 "stop"、"length"、"function_call"、"content_filter"、"null"。 "stop":API返回完整消息或由stop参数指定的序列终止的消息。 "length":由于max_tokens参数或令牌限制模型输出不完整。 "function_call":模型决定调用函数。 "content_filter":内容因内容过滤器标记而省略。 "null":API响应进行中或未完成。 更多信息 若要了解更多关于 Afarensis 聊天完成 API 的信息,请参阅我们的完整 API 参考文档。

上一页文本生成下一页JSON 模式

最后更新于1年前