Open API中文文档
  • 介绍
  • Quick Start
  • Reference
    • OpenAI API 参考文档
      • ChatGpt注册方法
      • 介绍
      • 认证
      • 请求组织
      • 发出请求
      • 模型
      • 问答
      • 对话
      • 编辑
      • 图片
      • 嵌入向量
      • 音频
      • 文件
      • 优化模型
      • 内容审核
      • 引擎
      • 参数详情
  • ChatGpt插件开发
  • ChatGpt注册方法
由 GitBook 提供支持
在本页

这有帮助吗?

  1. Reference
  2. OpenAI API 参考文档

编辑

给定提示和指令,模型将返回提示的编辑版本。

创建编辑

POST https://api.openai.com/v1/edits

为提供的输入、指令和参数创建新的编辑。

请求示例

curl https://api.openai.com/v1/edits \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "text-davinci-edit-001",
    "input": "What day of the wek is it?",
    "instruction": "Fix the spelling mistakes"
  }'
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Edit.create(
  model="text-davinci-edit-001",
  input="What day of the wek is it?",
  instruction="Fix the spelling mistakes"
)
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEdit({
  model: "text-davinci-edit-001",
  input: "What day of the wek is it?",
  instruction: "Fix the spelling mistakes",
});
请求参数
{
  "model": "text-davinci-edit-001",
  "input": "What day of the wek is it?",
  "instruction": "Fix the spelling mistakes",
}
返回结果
{
  "object": "edit",
  "created": 1589478378,
  "choices": [
    {
      "text": "What day of the week is it?",
      "index": 0,
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 32,
    "total_tokens": 57
  }
}
json

请求主体

  • model 字符串 必需 要使用的模型的ID。您可以在此端点中使用text-davinci-edit-001或code-davinci-edit-001模型。

  • input 字符串 可选的 默认为'' 用作编辑起点的输入文本。

  • instruction 字符串 必需 告诉模型如何编辑提示的指令。

  • n 整数 可选的 默认为1 要为输入和指令生成多少个编辑。

  • temperature 数字 可选的 默认为1 使用的采样温度,介于0和2之间。较高的值(例如0.8)将使输出更随机,而较低的值(例如0.2)将使其更加集中和确定性。

    我们通常建议更改这个或top_p,但不要同时更改两个。

  • top_p: 数字 可选的 默认为1 与采用温度进行采样的另一种方法称为nucleus采样,其中模型考虑具有top_p概率质量的令牌的结果。因此,0.1表示仅考虑组成前10%概率质量的令牌。

    我们通常建议更改这个或temperature,但不要同时更改两个。

上一页对话下一页图片

最后更新于2年前

这有帮助吗?