API 키없이 Python 코드에서 OpenAi chatgpt 사용
영어 | 简体中文
보고 버그 | 요청 기능
이 프로젝트는 OpenAI의 ChatGpt 서비스를 Python 코드에 통합하는 데 사용될 수 있습니다. 이 프로젝트를 사용하여 공식 API 키를 사용하지 않고 Python에서 직접 응답을 위해 Chatgpt를 프롬프트 할 수 있습니다.
Chatgpt Plus 계정없이 Chatgpt API를 사용하려는 경우 유용 할 수 있습니다.
Chatgpt에는 Python 코드를 인터페이스하는 데 사용할 수있는 공식 API가 있지만 API 키와 함께 사용해야합니다. 이 API 키는 ChatGpt Plus 계정이있는 경우에만 얻을 수 있으며, 이는 $ 20/월이 필요합니다 (05/11/2023 기준). 그러나 Chatgpt 웹 인터페이스를 사용하여 Chatgpt를 무료로 사용할 수 있습니다. 이 프로젝트는 코드를 Chatgpt 웹 버전으로 인터페이스하여 API 키를 사용하지 않고 Python 코드에서 Chatgpt를 사용할 수 있습니다.
ChatGpt Web Interface의 요청은 역 엔지니어링되었으며 Python 요청에 직접 통합되었습니다. 따라서이 스크립트를 사용하여 작성된 모든 요청은 웹 사이트에서 직접 사용자가 요청한 요청으로 시뮬레이션됩니다. 따라서 무료이며 API 키가 필요하지 않습니다.
pip install re-gpt
from re_gpt import SyncChatGPT
session_token = "__Secure-next-auth.session-token here"
conversation_id = None # conversation ID here
with SyncChatGPT ( session_token = session_token ) as chatgpt :
prompt = input ( "Enter your prompt: " )
if conversation_id :
conversation = chatgpt . get_conversation ( conversation_id )
else :
conversation = chatgpt . create_new_conversation ()
for message in conversation . chat ( prompt ):
print ( message [ "content" ], flush = True , end = "" )
import asyncio
import sys
from re_gpt import AsyncChatGPT
session_token = "__Secure-next-auth.session-token here"
conversation_id = conversation_id = None # conversation ID here
if sys . version_info >= ( 3 , 8 ) and sys . platform . lower (). startswith ( "win" ):
asyncio . set_event_loop_policy ( asyncio . WindowsSelectorEventLoopPolicy ())
async def main ():
async with AsyncChatGPT ( session_token = session_token ) as chatgpt :
prompt = input ( "Enter your prompt: " )
if conversation_id :
conversation = chatgpt . get_conversation ( conversation_id )
else :
conversation = chatgpt . create_new_conversation ()
async for message in conversation . chat ( prompt ):
print ( message [ "content" ], flush = True , end = "" )
if __name__ == "__main__" :
asyncio . run ( main ())
보다 복잡한 예를 보려면 저장소의 예제 폴더를 확인하십시오.
Application
탭으로 이동하여 Cookies
섹션을 엽니 다.__Secure-next-auth.session-token
의 값을 복사하여 저장하십시오. 기여는 오픈 소스 커뮤니티를 배우고, 영감을주고, 창조 할 수있는 놀라운 장소입니다. 당신이하는 모든 기여는 대단히 감사합니다 .
이를 더 좋게 만드는 제안이 있다면, repo를 포크하고 풀 요청을 만듭니다. 프로젝트에 별을주는 것을 잊지 마십시오! 다시 한 번 감사드립니다!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
Apache License 2.0에 따라 배포되었습니다. 자세한 내용은 LICENSE
참조하십시오.
Zai -kun- 불화 서버
Repo Link : https://github.com/zai-kun/reverse-engineered-chatgpt
Sudoalphax (이 readme를 작성하기 위해)
Yifeikong (Curl-Cffi 모듈)
Acheong08 (Arkose_token을 얻기위한 구현)
PYCA (암호화 모듈)
Legrandin (Pycryptodome 모듈)
Othneildrew (readme 템플릿)