Discord 讨论当前状态:未维护。不工作。
对不起各位!私人项目真的很忙。这很有趣!
阅读更多内容 - OpenAI 如何过滤机器人/抓取工具发出的请求
️ 喜欢这个仓库吗?请加注星标并考虑捐赠以保持其维护
如果 OpenAI 改变了他们的 API,我会尽快修复它,所以如果你想得到通知,请观看repo
融入 Huggingface 空间?使用Gradio。尝试网络演示
聊天
创建令牌
You: Hi there, My name is Rawa
Chat GPT: Hello Rawa, nice to meet you. Is there something you would like to talk about or ask me? I'm here to help with any questions you may have.
You: great, now say my name like Heisenberg
Chat GPT: Sure, Rawa like Heisenberg. Is there anything else you would like to talk about? I'm here to help with any questions you may have.
You: Sorry I meant like the episode of Breaking Bad where Walter White says Heisenberg
Chat GPT: Ah, I see. In that case, you could try saying it like this: "My name is Rawa, like Heisenberg." This is a reference to the character Walter White from the TV show Breaking Bad, who often used the pseudonym "Heisenberg" when conducting illegal activities. The character was known for his cool and calculated demeanor, so saying your name like Heisenberg in this context would mean saying it with confidence and authority.
pip install chatgptpy --upgrade
[新] 将options()
对象传递给ChatGPT()
构造函数以自定义会话
[新] 您现在可以将对话保存到文件中
from PyChatGPT import Chat , Options
options = Options ()
# [New] Pass Moderation. https://github.com/rawandahmad698/PyChatGPT/discussions/103
# options.pass_moderation = False
# [New] Enable, Disable logs
options . log = True
# Track conversation
options . track = True
# Use a proxy
options . proxies = 'http://localhost:8080'
# Optionally, you can pass a file path to save the conversation
# They're created if they don't exist
# options.chat_log = "chat_log.txt"
# options.id_log = "id_log.txt"
# Create a Chat object
chat = Chat ( email = "email" , password = "password" , options = options )
answer = chat . ask ( "How are you?" )
print ( answer )
[新] 恢复对话
from PyChatGPT import Chat
# Create a Chat object
chat = Chat ( email = "email" , password = "password" ,
conversation_id = "Parent Conversation ID" ,
previous_convo_id = "Previous Conversation ID" )
answer , parent_conversation_id , conversation_id = chat . ask ( "How are you?" )
print ( answer )
# Or change the conversation id later
answer , _ , _ = chat . ask ( "How are you?" ,
previous_convo_id = "Parent Conversation ID" ,
conversation_id = "Previous Conversation ID" )
print ( answer )
启动 CLI 会话
from PyChatGPT import Chat
chat = Chat ( email = "email" , password = "password" )
chat . cli_chat ()
问一次性问题
from PyChatGPT import Chat
# Initializing the chat class will automatically log you in, check access_tokens
chat = Chat ( email = "email" , password = "password" )
answer , parent_conversation_id , conversation_id = chat . ask ( "Hello!" )
import time
from PyChatGPT import OpenAI
# Manually set the token
OpenAI . Auth ( email_address = "email" , password = "password" ). save_access_token ( access_token = "" , expiry = time . time () + 3600 )
# Get the token, expiry
access_token , expiry = OpenAI . get_access_token ()
# Check if the token is valid
is_expired = OpenAI . token_expired () # Returns True or False
pip install chatgptpy --upgrade
进行更新options()
类引入新的pass_moderation
参数,默认为False
pass_moderation
为 True,则该函数将在另一个线程中调用,因此不会阻塞主线程。 answer, previous_convo, convo_id
options()
类方法action=next
切换到action=variant
。该库现在使用action=variant
而不是action=next
来从 API 获取下一个响应。502 Bad Gateway
错误。如果令牌创建过程失败:
我计划添加更多功能,例如:
我一直在寻找一种与新的 Chat GPT API 交互的方法,但 GitHub 上的大多数源代码都要求您在后台运行 Chromium 实例。或者使用 Web Inspector 手动获取访问令牌。
不再。我已经能够对 API 进行逆向工程,并使用 TLS 客户端来模拟真实用户,允许脚本登录而不会触发 Auth0 的任何机器人检测技术
基本上,该脚本使用 TLS 客户端代表您登录,然后获取访问令牌。速度相当快。
首先,我想告诉您,“仅发出 http”请求是不够的,Auth0 很智能,每个进程都由state
令牌(即 JWT 令牌)保护。这个token是用来防止CSRF攻击的,也用来防止机器人登录。如果你看一下auth.py
文件,有超过9个函数,每个函数负责不同的任务,而且它们都共同努力为您创建代币。 allow-redirects
在这方面发挥了巨大的作用,因为它允许在登录过程中导航
我在 MeshMonitors.io 工作,我们制作了很棒的工具(看看哟!)。我决定不在这上面花太多时间,但我们就在这里。
没有人能够做到这一点,我想看看我是否可以。