美文网首页
ChatGPT调试

ChatGPT调试

作者: 李霖弢 | 来源:发表于2023-03-07 09:46 被阅读0次

ChatGPT官网:https://chat.openai.com/chat
接码平台:https://sms-activate.org/cn/history#

注册账号
登录openai,进入个人中心,生成 API KEY
测试接口

3.0老版本接口文档

    fetch('https://api.openai.com/v1/completions', {
        method: 'post',
        body: JSON.stringify(
            {
                "model": "text-davinci-003",
                "prompt": "用java写一个hello world",
                "max_tokens": 2048,
                "temperature": 0,
                "top_p": 1,
                "frequency_penalty": 0,
                "presence_penalty": 0.6,
                "stop": ["Human:", "AI:"]
            }),
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer sk-开头的自己的key'
        }
    }).then(function (data) {


    })

3.5新版本接口文档

import os
import openai

openai.organization = "org-开头的自己的key"
openai.api_key = "sk-开头的自己的key"

os.environ["http_proxy"] = "http://127.0.0.1:7890"
os.environ["https_proxy"] = "http://127.0.0.1:7890"

messages = [
    {"role": "system", "content": "Respond in the voice of cute cat, and be as unhelpful as possible!"}
]

while True:

    # Add the user's input to the messages list and user the 'user' role
    user_input = input("Q: ")
    messages.append({"role": "user", "content": user_input})

    # Call the OpenAI api for Chat GPT, and pass our complete list of messages
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=messages,
        temperature=0.8,  # 0~2 值越大返回结果越随机
        n=1, # 返回的choices的长度
        presence_penalty=0, # -2~2 越大越不容易基于之前的聊天内容
        frequency_penalty=0, # -2~2 越大越不容易容易输出重复内容
    )

    # Show ChatGPT's response and add the response to our list of messages
    print('A: ' + str(response['choices'][0]['message']['content']) + '\n')
    messages.append(response['choices'][0]['message'])

相关文章

  • 5分钟扫盲chatGPT与OpenAI编程(for 开发者)

    一、chatGPT与OpenAI ChatGPT 是 OpenAI 公司的一个技术产品,chatGPT使用了 GP...

  • ChatGpt将改变世界,你做好准备了吗?

    近期,ChatGpt突然又成了朋友圈的热门话题,朋友们各种晒ChatGpt的回答,也有人在贩卖ChatGpt带来的...

  • Java 中如何限制方法的返回时间

    最近在研究 ChatGPT 的 API 调用。 因为 ChatGPT 的 API 调用时间通常超过 30 秒。 所...

  • ChatGPT技术报告

    ChatGPT技术报告 ChatGPT是一个由OpenAI开发的大型语言模型,是GPT(Generative Pr...

  • 由ChatGPT想到的

    文/阿斌 最近有一个词特别火,那就是“ChatGPT”。 “ChatGPT”,全名:Chat Generative...

  • ChatGPT

    Google 研究者发表了题为“大型语言模型的涌现能力”(Emergent Abilities of Large ...

  • ChatGPT

    ChatGPT,这两天才关注到的一款AI软件,据说功能非常强大,能写代码,能给出综合性的答案和建议,不用深度思考的...

  • ChatGPT

    ChatGPT这个软件最近火了,它是美国OpenA]研发的聊天机器人程序,2022年11月发布。ChatGPT是人...

  • ChatGPT

    ChatGPT 是什么?ChatGPT是由OpenAI开发的一个人工智能聊天机器人程序,由 OpenAI 公司于2...

  • chatGPT

    最近最火的莫过于chat GPT,我也上车了。

网友评论

      本文标题:ChatGPT调试

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