PyChatGPT
1.0.0
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
。 。 allow-redirects
在這方面發揮了巨大的作用,因為它允許在登入過程中導航
我在 MeshMonitors.io 工作,我們製作了令人驚嘆的工具(看看吧!)。我決定不在這上面花太多時間,但我們在這裡。
沒有人能夠做到這一點,我想看看我是否可以。