Skip to main content

A simplified object-oriented interface for OpenAI's chat completion API.

Project description

💬 SimpleChat 💬

A simplified object-oriented interface for OpenAI's chat completion API.

Usage

Creating a chat

This library relies on a valid OpenAI API key. To create a chat, just call the constructor with your API key as the api_key parameter.

chat = Conversation("sk-...")

Chatting to your assistant

You converse with your assistant via the say() method.

chat = Conversation("sk-...")
response = chat.say("hello")
print(response)

You can also see the last response you received from your assistant with last_response().
Here is an equivalent of the above code using the last_response method

chat = Conversation("sk-...")
chat.say("hello")
print(chat.last_response())

Settings

You can add settings to your assistant by putting a list of settings as the settings argument in the constructor.

s = ["Keep answers concise", "Speak like a pirate", "Have opinions on topics"]
chat = Conversation("sk-...", settings=s)

Settings can also be removed, added and cleared after construction.

s = ["Keep answers concise", "Speak like a pirate", "Have opinions on topics"]
chat = Conversation("sk-...", settings=s)
print(chat.get_settings())

chat.pop_setting()
print(chat.get_settings())

chat.clear_settings()
print(chat.get_settings())

Viewing and resetting your chat

Messages can be viewed and reset during the chat, leaving settings intact

s = ["Keep answers concise", "Speak like a pirate", "Have opinions on topics"]
chat = Conversation("sk-...", settings=s)

chat.say("hello")
chat.say("write me a poem")

chat.clear_messages()
print(chat.get_messages())
print(chat.get_settings())

The entire chat (settings included) can also be reset.

s = ["Keep answers concise", "Speak like a pirate", "Have opinions on topics"]
chat = Conversation("sk-...", settings=s)

chat.say("hello")
chat.say("write me a poem")

chat.reset()
print(chat.get_messages())
print(chat.get_settings())

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

simpleGpyT-0.1.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

simpleGpyT-0.1.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file simpleGpyT-0.1.4.tar.gz.

File metadata

  • Download URL: simpleGpyT-0.1.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for simpleGpyT-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3087c00e6d1fce8734a98c8963f653a10c93aacbd3f17392f7d62aa1f4f5dfbb
MD5 94e0b67d0c1dcbac444602d9c8bcb201
BLAKE2b-256 3cac6671b0b8f92c6e01d14a2583c5d5f9b20719f2b15bd55a41fd043a347215

See more details on using hashes here.

File details

Details for the file simpleGpyT-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: simpleGpyT-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for simpleGpyT-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8266a648c748fe140306072dc19be3f7593b4ecc84743bee7f81be1c97e0206b
MD5 1e3188c65deb1b7ada221ab374bda6ee
BLAKE2b-256 39a69535efb007fb9adc0d84cf2229eece00ed7326321aa7830242601829c2ac

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