美文网首页
GPT-3 Python API试用

GPT-3 Python API试用

作者: 兮嘉 | 来源:发表于2021-03-11 12:07 被阅读0次

    试用了一下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"
    }
    

    相关文章

      网友评论

          本文标题:GPT-3 Python API试用

          本文链接:https://www.haomeiwen.com/subject/itinqltx.html