Use Operai Chatgpt en su código Python sin una clave API
Inglés | 简体中文
Informe de error | Solicitar la función
Este proyecto se puede utilizar para integrar los servicios de ChatGPT de Openai en su código Python. Puede usar este proyecto para solicitar ChatGPT para respuestas directamente desde Python, sin usar una clave API oficial.
Esto puede ser útil si desea usar la API CHATGPT sin una cuenta ChatGPT Plus.
ChatGPT tiene una API oficial que se puede usar para interactuar su código Python, pero debe usarse con una clave API. Esta clave API solo se puede obtener si tiene una cuenta ChatGPT Plus, que requiere $ 20/mes (a partir del 11/05/2023). Pero puede usar chatgpt de forma gratuita, utilizando la interfaz web de chatgpt. Este proyecto tiene como objetivo interactuar su código a la versión web de ChatGPT para que pueda usar CHATGPT en su código Python sin usar una clave API.
Las solicitudes de la interfaz web de ChatGPT se han modificado inversamente y se han integrado directamente en las solicitudes de Python. Por lo tanto, cualquier solicitud realizada con este script es simulada como una solicitud realizada por un usuario directamente en el sitio web. Por lo tanto, es gratis y no necesita una clave 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 ())Para obtener un ejemplo más complejo, consulte la carpeta de ejemplos en el repositorio.
Application y abra la sección Cookies .__Secure-next-auth.session-token y guárdelo. Las contribuciones son lo que hace que la comunidad de código abierto sea un lugar tan increíble para aprender, inspirar y crear. Cualquier contribución que haga es muy apreciada .
Si tiene una sugerencia que lo mejore, desembolse el repositorio y cree una solicitud de extracción. ¡No olvides darle una estrella al proyecto! ¡Gracias de nuevo!
git checkout -b feature/AmazingFeature )git commit -m 'Add some AmazingFeature' )git push origin feature/AmazingFeature ) Distribuido bajo la licencia Apache 2.0. Vea LICENSE para más información.
Zai -kun - Servidor de discordias
Enlace de repo: https://github.com/zai-kun/reverse-ingineered-chatgpt
sudoalphax (por escribir este readme)
Yifeikong (módulo Curl-Cffi)
Acheong08 (implementación para obtener Arkose_Token)
PYCA (módulo de criptografía)
Legrandin (módulo Pycryptodome)
Othneildrew (plantilla de readme)