Simple generator wrapper for OpenAI Python API with retry
Project description
openai-pygenerator
This is a simple wrapper around the OpenAI Python API which provides type annotations, retry functionality and a generator over completions.
Installation
pip install openai-pygenerator
Usage
from openai_pygenerator import ChatSession
session = ChatSession()
solution = session.ask("What is the square root of 256?")
print(solution)
working = session.ask("Show your working")
print(working)
print("Transcript:")
print(session.transcript)
For an example of overriding parameters see src/example.py.
Running
export OPENAI_API_KEY=<key>
python src/example.py
Configuration
export GPT_MODEL=gpt-3.5-turbo
export GPT_TEMPERATURE=0.2
export GPT_MAX_TOKENS=100
export GPT_MAX_RETRIES=5
export GPT_RETRY_EXPONENT_SECONDS=2
export GPT_RETRY_BASE_SECONDS=20
export OPENAI_API_KEY=<key>
python src/example.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
openai_pygenerator-0.1.0.tar.gz
(14.3 kB
view hashes)
Built Distribution
Close
Hashes for openai_pygenerator-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 940725e07b8377666a013479c779eef5eeec24d818288e62972fe5a4c35198e4 |
|
MD5 | 18e5423420a597f9b5a2aa7b0b37caaa |
|
BLAKE2b-256 | 2f305603c4c85f965e91069b3c86f87b6c7e547b7cecd274b53e26074cf19c89 |