Skip to main content

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

Project description

💬 SimpleGPyT 💬

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

Installation

Ensure you have Python 3.10 or newer. Python 3.7.1 and up should work as well, but these are untested.
To install the package, run:

pip install simpleGPyT

To use the package, import it at the top of the file.

from simpleGPyT import Conversation

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.5.tar.gz (4.7 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.5-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simpleGpyT-0.1.5.tar.gz
  • Upload date:
  • Size: 4.7 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.5.tar.gz
Algorithm Hash digest
SHA256 eed2bf27f711b8c008be8b518b151b51af5c808d4d67e9e6fa19a315e24a65a6
MD5 b01cd0d38011564700cdc8db09c7d69f
BLAKE2b-256 b3b51f7a590a787f68cbd2936fb5a7f8633a7b173c9acb7af1db0edb922c0050

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simpleGpyT-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f07f8c95f8efa7e8650afd29c54cd061dc6d8a2d4f27753db4c27d6dde7ef761
MD5 525fb585583baa8c0fff02acb54e0446
BLAKE2b-256 06a7fc3a0ef32ebb07a1a34a4702a2867efcb45b19d24fedc1060f7a51b44495

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