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
Metadata
Release files for openai-streamer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openai_streamer-0.1.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openai_streamer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / openai_streamer-0.1.0.tar.gz
| Download URL | openai_streamer-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0867f9b268cfdc7c69de80e8ae00451862f87ab3b9a16f5bf6ddaa1882bf3245
|
|
BLAKE2b-256 checksum How to use checksums |
d6ae514f69f43131e1f4566c012bb9c421b03b5251630170dd63339e11252d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / openai_streamer-0.1.0-py3-none-any.whl
| Download URL | openai_streamer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d955f1091b4a398f47829e749c2e5ab863cb47e12a47cb220ad4d468dc0e8fb4
|
|
BLAKE2b-256 checksum How to use checksums |
589fbb5fa061a42546fc7035d242de1e279ccff73a6accedb8f724bbaf218e39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|