Metadata-Version: 2.1
Name: openai-pygenerator
Version: 0.1.2
Summary: Simple generator wrapper for OpenAI Python API with retry
Author-email: Steve Phelps <sphelps@sphelps.net>
Project-URL: Homepage, https://github.com/phelps-sg/openai-pygenerator
Project-URL: Bug Tracker, https://github.com/phelps-sg/openai-pygenerator/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev
License-File: LICENSE.txt

# openai-pygenerator

[![GitHub Workflow Status](https://github.com/phelps-sg/openai-pygenerator/actions/workflows/python-package.yml/badge.svg)](https://github.com/phelps-sg/openai-generator/actions/workflows/continouos-integration.yml)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/phelps-sg/openai-pygenerator)
![GitHub](https://img.shields.io/github/license/phelps-sg/openai-pygenerator?color=blue)

This is a simple wrapper around the OpenAI Python API which provides
type annotations, retry functionality and a generator over completions.


## Installation

~~~bash
pip install openai-pygenerator
~~~

## Usage

~~~python
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](src/example.py).

## Running 

~~~bash
export OPENAI_API_KEY=<key>
python src/example.py
~~~

## Configuration

~~~bash
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
~~~

