用于与OpenAI的ChatGPT的API交互的轻量级包。使用逆向工程的官方API。
作者:Sec-Labs | 发布时间:
项目地址
https://github.com/acheong08/ChatGPT、
ChatGPT
OpenAI 的逆向工程 ChatGPT。 可扩展为聊天机器人等。
注意:这是概念验证。 这里的目标是能够使用 API 编写机器人。
特点
- 科学知识
- 有记忆。 它会记住聊天记录和上下文
- 没有节制
- 可编程的
设置
安装
pip3 install revChatGPT --upgrade
获取您的会话令牌
转到 https://chat.openai.com/chat 并登录或注册
- 打开控制台
F12 - 打开
Application选项卡 > Cookie - 复制值
__Secure-next-auth.session-token并将其粘贴到config.json.exampleundersession_token中。 你不需要填写Authorization - 将修改后的文件保存到
config.json(在当前工作目录中)
运行
$ python3 -m revChatGPT
ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
Repo: github.com/acheong08/ChatGPT
Type '!help' to show commands
Press enter twice to submit your question.
You: !help
!help - Show this message
!reset - Forget the current conversation
!refresh - Refresh the session authentication
!exit - Exit the program
如果您 !refresh 只使用 session_token .
经常刷新以防令牌过期。
参数
您可以使用命令行参数通过处理器传递输出。
例子:
用于 python3 -m revChatGPT say 让 Mac 说出输出
开发
pip3 install revChatGPT --upgrade
from revChatGPT.revChatGPT import Chatbot
import json
# Get your config in JSON
config = {
"Authorization": "<Your Bearer Token Here>", # This is optional
"session_token": "<Your Session Token here>" # This is used to refresh the authentication
}
chatbot = Chatbot(config, conversation_id=None)
chatbot.reset_chat() # Forgets conversation
chatbot.refresh_session() # Uses the session_token to get a new bearer token
resp = chatbot.get_chat_response(prompt) # Sends a request to the API and returns the response by OpenAI
resp['message'] # The message sent by the response
resp['conversation_id'] # The current conversation id
resp['parent_id'] # The ID of the response
这可以导入到机器人项目等等。 您可以通过跟踪 conversation_id 进行多个独立对话。
很棒的ChatGPT
标签:工具分享, ChatGPT