Skip to main content

Python implementation of Unofficial ChatGPT Client

Project description

Update 30-DEC-2022

We have introduced a new method that utilizes a socket for faster performance without the need for a browser anymore. [NodeJS Version][C# Version]

For support join [Discord]

PyGPT - Unofficial API client for ChatGPT [Discord]

PyPi Version PyPi Downloads GitHub issues GitHub forks GitHub stars GitHub license Discord server

Get Started

Install dependencies first

pip install --upgrade PyGPT

Example

import asyncio
from pygpt import PyGPT

async def main():
    chat_gpt = PyGPT('eyJhbGciOiJkaXIiLCJlbmMiOiJBMR0NN....')
    await chat_gpt.connect()
    await chat_gpt.wait_for_ready()
    answer = await chat_gpt.ask('What is the capital of France?')
    print(answer)
    await chat_gpt.disconnect()

if __name__ == '__main__':
    asyncio.run(main())

For multiple queries

import asyncio
from pygpt import PyGPT

async def main():
    chat_gpt = PyGPT('eyJhbGciOiJkaXIiLCJlbmMiOiJBMR0NN....')
    await chat_gpt.connect()
    await chat_gpt.wait_for_ready()
    questions = ["how are you", "where do you live", "what do you do"]
    for question in questions:
        answer = await chat_gpt.ask(question)
        print(answer)
    await chat_gpt.disconnect()

if name == 'main':
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyGPT-1.0.5.tar.gz (10.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page