GPT-3 Python API试用

试用了一下Idea generation功能,示例代码如下:

import openai
openai.api_key = "***"
response = openai.Completion.create(
    engine="davinci", 
    prompt="Blog topics dealing with daily life living on Mars\r\n1.", 
    temperature=0.3, 
    top_p=1, 
    frequency_penalty=0.5, 
    presence_penalty=0.8, 
    best_of=1, 
    max_tokens=64)

response内容如下:

{
  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "logprobs": null,
      "text": " What is the best way to eat on Mars?\n2. What are the best ways to get around on Mars?\n3. How do you make a house on Mars?\n4. How do you make clothes for Mars?\n5. How do you grow food on Mars?\n6. What kind of"
    }
  ],
  "created": 1615435342,
  "id": "cmpl-2c6ogBbdrKYgVQdfEnnuASp3ZrI3y",
  "model": "davinci:2020-05-03",
  "object": "text_completion"
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容