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.3.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.

simpleGpyT-0.1.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simpleGpyT-0.1.3.tar.gz
  • Upload date:
  • Size: 2.8 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.3.tar.gz
Algorithm Hash digest
SHA256 9b538a1c003e29a01545ef86c56d77891912c6fa334b206ad26d5f45afee0cf7
MD5 deba33ac29f832c0b63548c19aed98f8
BLAKE2b-256 090f10ef281e799a6e25e5bc3c5a96da4ac57d2790a7bee415f81def50178566

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simpleGpyT-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d3b2b4fde686e8e9098ce30b5a312d8b7138431eb128fb61d6d36ba74bf45e
MD5 9b92eb99bc1d52585c219cb1ba523b31
BLAKE2b-256 40754494cda0b00e0a9d2f9e6586c543ff98cf0d894c8f5f39e4e9b80d9e9f0d

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