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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0867f9b268cfdc7c69de80e8ae00451862f87ab3b9a16f5bf6ddaa1882bf3245
|
|
| MD5 |
243c010bcc81dc5f647ab635bf9e1bb6
|
|
| BLAKE2b-256 |
d6ae514f69f43131e1f4566c012bb9c421b03b5251630170dd63339e11252d22
|
File details
Details for the file openai_streamer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openai_streamer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d955f1091b4a398f47829e749c2e5ab863cb47e12a47cb220ad4d468dc0e8fb4
|
|
| MD5 |
cf087b80a19917234b517564bfb91f68
|
|
| BLAKE2b-256 |
589fbb5fa061a42546fc7035d242de1e279ccff73a6accedb8f724bbaf218e39
|