我在尝试使用插入的方式进行补全。
似乎我应该使用一个名为suffix:
的参数来指示插入的结束位置。
发送到端点的负载: POST /v1/completions
{ "model": "code-davinci-002", "prompt": "Write a JSON document for a person with first name, last name, email and phone number\n\n{\n", "suffix": "\n}", "temperature": 0, "max_tokens": 256, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0}
我尝试从一个Ruby实现的GPT3中进行操作。
parameters=> {:model=>"code-davinci-001", :prompt=>"generate some JSON for a person with first and last name {", :max_tokens=>250, :temperature=>0, :top_p=>1, :frequency_penalty=>0, :presence_penalty=>0, :suffix=>"\n}"}
post(url: "/v1/completions", parameters: parameters)
我收到了关于suffix
的无效参数错误
{"error"=>{"message"=>"Unrecognized request argument supplied: suffix", "type"=>"invalid_request_error", "param"=>nil, "code"=>nil}}
回答:
我对比了来自OpenAI的负载和Ruby库的负载,发现了问题所在。
我的Ruby库将模型设置为code-davinci-001
,而OpenAI使用的是code-davinci-002
。
一旦我在调试中手动更改了模型属性,补全就开始正常工作了。
{ "id"=>"cmpl-5yJ8b01Cw26W6ZIHoRSOb71Dc4QvH", "object"=>"text_completion", "created"=>1665054929, "model"=>"code-davinci-002", "choices"=> [{"text"=>"\n \"firstName\": \"John\",\n \"lastName\": \"Smith\"", "index"=>0, "logprobs"=>nil, "finish_reason"=>"stop"}], "usage"=>{"prompt_tokens"=>14, "completion_tokens"=>19, "total_tokens"=>33}}