OpenAI Adapter for RAG Control
A high-performance OpenAI adapter for RAG (Retrieval-Augmented Generation) systems, providing seamless integration with rag-control framework for LLM and embedding operations.
Features
- 🚀 High-Performance LLM Generation - Support for chat completions with streaming
- 🔍 Query Embeddings - Generate embeddings for text queries using OpenAI's embedding models
- 📊 Comprehensive Metadata - Track latency, token usage, and request IDs
- ⚙️ Flexible Configuration - Full OpenAI client configuration support
- 🛡️ Error Handling - Robust exception handling with custom adapter errors
- 📝 Type-Safe - Full type annotations for Python static analysis
Installation
Install the package from PyPI:
pip install openai-adapter
Or with uv:
uv pip install openai-adapter
For development installation from source:
git clone <repo-url>
cd openai-adapter
uv sync
Version Compatibility
- Current Stable Version: v0.1.0
- Compatible with: rag-control v0.1.3
Quick Start
Integration with rag-control
The OpenAI Adapter is designed to integrate seamlessly with the rag-control framework:
from rag_control import RAGControl
from openai_adapter import OpenAILLMAdapter, OpenAIQueryEmbeddingAdapter
# Initialize adapters
llm_adapter = OpenAILLMAdapter(api_key="sk-...")
embedding_adapter = OpenAIQueryEmbeddingAdapter(api_key="sk-...")
# Create RAG system with OpenAI adapters
rag = RAGControl(
llm_adapter=llm_adapter,
embedding_adapter=embedding_adapter
)
# Use for RAG operations
response = rag.query("What is machine learning?")
print(response.answer)
API Reference
OpenAILLMAdapter
__init__(api_key: str, model: str = "gpt-3.5-turbo", **kwargs)
Initialize the LLM adapter.
Parameters:
api_key(str): OpenAI API key for authenticationmodel(str): Language model to use (default: gpt-3.5-turbo)**kwargs: Additional OpenAI client configurationorganization(str): Organization IDproject(str): Project IDbase_url(str): Custom API endpointtimeout(float): Request timeout in seconds
Raises:
LLMAdapterError: If client initialization fails
OpenAIQueryEmbeddingAdapter
__init__(api_key: str, model: str = "text-embedding-3-small", **kwargs)
Initialize the embedding adapter.
Parameters:
api_key(str): OpenAI API keymodel(str): Embedding model (default: text-embedding-3-small)**kwargs: Additional OpenAI client configuration
Raises:
QueryEmbeddingAdapterError: If client initialization fails
Development & Contributing
For information on setting up a development environment, code style guidelines, and contribution guidelines, see:
- DEVELOPMENT.md - Development environment setup and code quality tools
- CONTRIBUTING.md - Contributing guidelines and pull request process
License
Licensed under the Apache License 2.0. See LICENSE file for details.
Support
For issues and questions:
- Open an issue on GitHub
- Check existing documentation
- Review error messages for guidance
Metadata
Release files for openai-adapter 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_adapter-0.1.0.tar.gz | 18.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openai_adapter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.5 kB
Release files / openai_adapter-0.1.0.tar.gz
| Download URL | openai_adapter-0.1.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a014cbfbd68044b03c018abaf1b9cdac68003ba8e128d6bc31641eebc456fd90
|
|
BLAKE2b-256 checksum How to use checksums |
d52ac0d54d9334b2853eb74d4110bab27fb48ba17440eb6ff23fa5cef7a16fa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / openai_adapter-0.1.0-py3-none-any.whl
| Download URL | openai_adapter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3fb6efc744d4f8872090b01f9f61016f79fe8a5930f43a252198a6ae41bc3b04
|
|
BLAKE2b-256 checksum How to use checksums |
6eff479fd15f0ad156e70dab78f2c1d1093b646201f39f3cc0e5046f82b17153
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|