ChatGPT 介绍

发布时间: 更新时间: 总字数:755 阅读时间:2m 作者: 分享 复制网址

ChatGPT(生成型预训练变换模型)是一个自回归语言模型,目的是为了使用深度学习生成人类可以理解的自然语言

介绍

  • GPT-3是由在旧金山的人工智能公司OpenAI训练与开发,模型设计基于谷歌开发的变换语言模型
    • GPT-3的神经网络包含1750亿个参数,为有史以来参数最多的神经网络模型
  • 竞品
    • Google Bard
    • LLM
    • ColossalAI 让大型人工智能模型更便宜、更快速、更容易获得

使用

api 调用示例

基于 Python 调用接口示例

  • 安装依赖
pip3 install openai
  • 设置 key
export OPENAI_API_KEY="xxx"
import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.Completion.create(
  model="text-davinci-003",
  prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with "Unknown".",  # 提示信息
  temperature=0,
  max_tokens=100,
  top_p=1,
  frequency_penalty=0.0,
  presence_penalty=0.0,
  stop=["\n"]
)

print(response)
  • ChatGPT 给的脚本示例
import openai

openai.api_key = "<INSERT API KEY HERE>"
# Create the OpenAI API object
openai_api = openai.API()

# Ask the OpenAI API a question
response = openai_api.create_engagement("What is the capital of France?",
                                        engagement_level="chat")

# Print the response from the OpenAI API
print(response.text)

客户端

ChatGPT 微信聊天机器人

git clone https://github.com/zhayujie/chatgpt-on-wechat
cd chatgpt-on-wechat/

# 创建 venv
python3 -m venv .venv
. .venv/bin/activate

# 安装依赖
pip3 install itchat-uos==1.5.0.dev0 -i http://pypi.douban.com/simple/ -U tox --trusted-host pypi.douban.com
pip3 install --upgrade openai -i http://pypi.douban.com/simple/ -U tox --trusted-host pypi.douban.com

# 配置
cp config-template.json config.json

# config.json文件内容示例
{
  "open_ai_api_key": "YOUR API KEY"                           # 填入上面创建的 OpenAI API KEY
  "single_chat_prefix": ["bot", "@bot"],                      # 私聊时文本需要包含该前缀才能触发机器人回复
  "single_chat_reply_prefix": "[bot] ",                       # 私聊时自动回复的前缀,用于区分真人
  "group_chat_prefix": ["@bot"],                              # 群聊时包含该前缀则会触发机器人回复
  "group_name_white_list": ["ChatGPT测试群", "ChatGPT测试群2"], # 开启自动回复的群名称列表
  "image_create_prefix": ["画", "看", "找"],                   # 开启图片回复的前缀
  "conversation_max_tokens": 1000,                            # 支持上下文记忆的最多字符数
  "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"  # 人格描述
}

# 启动服务
nohup python3 app.py &

# 查看日志
tail -f nohup.out

# 扫描启动的二维码登录&使用

F&Q

OpenAI not available in your country

OpenAI’s services are not available in your country

  • 解决方式
# javascript: 要手动输入
javascript:window.localStorage.removeItem(Object.keys(window.localStorage).find(i=>i.startsWith('@@auth0spajs')))

https://github.com/lencx/ChatGPT/issues/83

最新评论
加载中...
Home Archives Categories Tags Statistics