Skip to main content

An extremely simple interface to ChatGPT

Project description

Simple ChatGPT

An extremely simple programmatic interface to ChatGPT. The conversation automatically gets truncated (from the oldest message) if the token limit is reached.

The goal of this project is to remove the need for boilerplate code to create a chat bot in your program, allowing you to jump right into integrating ChatGPT into whatever you are making.

You can use this package like:

from simplechatgpt import Chat

import os

chat = Chat(os.environ["OPENAI_API_KEY"])

while True:
    prompt = input("You: ")
    print("Bot:", chat.send(prompt))

You can choose a model when initializing your Chat object like:

chat = Chat(os.environ["OPENAI_API_KEY"], model="gpt-4")

As of the time of this writing (07/08/2023), the following models are available for use:

  • gpt-4
  • gpt-4-32k
  • gpt-3.5-turbo
  • gpt-3.5-turbo-16k

See https://platform.openai.com/docs/models/overview for a full list of available models.

You can also customize the "system" message to initialize the chat bot to act in a certain way throughout the conversation. For example,

key = os.environ["OPENAI_API_KEY"]
chat = Chat(key, chatbot_description="You are Hucklyberry Finn.")

while True:
    prompt = input("You: ")
    print("Bot:", chat.send(prompt))

Would produce responses like:

You: Hey son, how are you?
Bot: Well, I reckon I'm doin' alright Pa. How 'bout yourself?

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

simplechatgpt-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplechatgpt-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file simplechatgpt-1.0.1.tar.gz.

File metadata

  • Download URL: simplechatgpt-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Darwin/22.5.0

File hashes

Hashes for simplechatgpt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fedc0dc52c0506767816097befe7e7dcc525e17cf22bb0b92b3e9e1c84439145
MD5 ad21230de461df606e21e5ed2a0ec801
BLAKE2b-256 ca747293bcc92fa29cc80d04c3ebf22c7d987c1e1000c237e06438c238675769

See more details on using hashes here.

File details

Details for the file simplechatgpt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: simplechatgpt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Darwin/22.5.0

File hashes

Hashes for simplechatgpt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c75a212efe87f15113a11c53c602d6223a0d4eabd68ec2b7a24d810fd05df9b
MD5 2c080de9982bb8d14e369f58a0d5ad7a
BLAKE2b-256 7c1f3c43a98c3814f28f40d97eb64ba8ae6f7ac2c8ccdd3e2e02cce87ba7b76c

See more details on using hashes here.

Supported by

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