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 details)

Uploaded Source

File details

Details for the file PyGPT-1.0.5.tar.gz.

File metadata

  • Download URL: PyGPT-1.0.5.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for PyGPT-1.0.5.tar.gz
Algorithm Hash digest
SHA256 b5622c108f3310e3dee3f1a9a0e5f12cf9bfb1320d8667b0e74d2d6c47a28695
MD5 b745a54b2b6d02e653f6dd83e9cfa94a
BLAKE2b-256 88d9a10361c1b6ff011607834f5faffee324397f2b3c997c9015d167e96c79ee

See more details on using hashes here.

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