Skip to main content

A package for streaming text completion using OpenAI's Responses API

Project description

OpenAI Streamer

A Python package for streaming text completion using OpenAI's Responses API.

Installation

You can install the package directly from the source:

# Activate your conda environment
conda activate OpenRAPI

# Install the package in development mode
pip install -e .

Or you can build and install the package:

# Activate your conda environment
conda activate OpenRAPI

# Build the package
python setup.py sdist bdist_wheel

# Install the package
pip install dist/openai_streamer-0.1.0-py3-none-any.whl

Usage

Basic Usage

from openai_streamer.streamer import stream_completion

# Simple example
prompt = "Write a short poem about artificial intelligence."
instructions = "You are a creative poet with a technical background."

response = stream_completion(prompt, instructions=instructions)

Using the Class

from openai_streamer.streamer import OpenAIStreamer

# Create an instance
streamer = OpenAIStreamer()

# Generate a completion
prompt = "Explain quantum computing in simple terms."
instructions = "You are a science educator explaining complex topics to beginners."

response = streamer.stream_completion(prompt, instructions=instructions)

Configuration

The package uses environment variables for configuration. Create a .env file in your project root with:

OPENAI_API_KEY=your_api_key_here

Requirements

  • Python 3.8+
  • openai>=1.0.0
  • python-dotenv>=0.19.0

License

MIT

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

openai_streamer-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

openai_streamer-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file openai_streamer-0.1.0.tar.gz.

File metadata

  • Download URL: openai_streamer-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for openai_streamer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0867f9b268cfdc7c69de80e8ae00451862f87ab3b9a16f5bf6ddaa1882bf3245
MD5 243c010bcc81dc5f647ab635bf9e1bb6
BLAKE2b-256 d6ae514f69f43131e1f4566c012bb9c421b03b5251630170dd63339e11252d22

See more details on using hashes here.

File details

Details for the file openai_streamer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_streamer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d955f1091b4a398f47829e749c2e5ab863cb47e12a47cb220ad4d468dc0e8fb4
MD5 cf087b80a19917234b517564bfb91f68
BLAKE2b-256 589fbb5fa061a42546fc7035d242de1e279ccff73a6accedb8f724bbaf218e39

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