UCWA SDK for AI memory management and model integration
Project description
UCWA SDK The UCWA SDK is a powerful tool that allows AI labs and developers to integrate and interact with UCWA (Universal Context Window API) services. With this SDK, you can easily extend AI models (LLMs, multimodal models, etc.) by utilizing external memory extensions and scaling their context window dynamically.
This SDK provides both a Python library and API client to interact with the UCWA services, offering memory management, storage, retrieval, and much more.
Features Vector Memory: Leverage FAISS to manage and store vectors in a scalable, high-performance system.
OpenAI Embedding Support: Integrates with OpenAI models to embed and scale context windows dynamically.
Async & Streaming APIs: Handle large-scale requests with asynchronous support for optimized performance.
API Key Authentication: Secure your API interactions with API key-based authentication.
Rate Limiting: Ensure fair usage with built-in rate limiting for API calls.
Dockerized: Easily deploy the API with Docker for local or cloud-based installations.
Postgres + FAISS Persistence: Data is persistently stored for quick retrieval using PostgreSQL and FAISS.
Logging & Health Checks: Built-in logging support and health check endpoints for production-grade stability.
Installation To install the UCWA SDK and set up the client in your Python environment, follow these steps.
Install from PyPI To install the SDK, simply run:
bash Copy Edit pip install ucwa-sdk Install from Source Alternatively, you can install the SDK directly from the source code by cloning the repository:
bash Copy Edit git clone https://github.com/your-username/ucwa-sdk.git cd ucwa-sdk python setup.py install Dependencies The following Python packages are required:
requests
fastapi
pydantic
faiss-cpu (for memory vector management)
asyncio
httpx
Ensure that all dependencies are installed, either via pip install or through the provided requirements.txt.
Configuration Before using the SDK, you need to configure the API key for secure authentication.
Set your API Key: You'll need to generate an API key from the UCWA service. Add it to your environment variables or directly in your code.
bash Copy Edit export UCWA_API_KEY="your-api-key-here" Base URL Configuration: Configure the UCWA base API URL in the configuration file (config.py), or set it as an environment variable.
python Copy Edit BASE_URL = "https://your-ucwa-api-url.com" Usage Here’s an example of how to interact with the UCWA API using the SDK.
- Initialize the Client To initialize the API client, simply import and create an instance of UCWAClient.
python Copy Edit from ucwa_sdk import UCWAClient
client = UCWAClient(api_key="your-api-key") 2. Add Memory (Storing Vectors) Use the add_memory method to store memory (vectors) for a given model:
python Copy Edit response = client.memory.add_memory( model_name="OpenAI GPT-3", vector_data=[0.1, 0.2, 0.3, 0.4], # Your vector data here metadata={"example_key": "example_value"} ) print(response) 3. Search Memory You can search the memory storage for a vector match:
python Copy Edit response = client.memory.search_memory( query_vector=[0.1, 0.2, 0.3, 0.4] ) print(response) 4. Stream Data (Async) For large-scale operations, the SDK supports streaming data. Here's how to use it:
python Copy Edit async def stream_data(): async with client.stream() as stream: async for chunk in stream.fetch_data(query="some_query"): print(chunk)
Run in an async environment
import asyncio asyncio.run(stream_data()) Docker Deployment If you want to deploy UCWA as a containerized application, we provide a Docker configuration.
- Build the Docker Image From the docker/ directory:
bash Copy Edit docker build -t ucwa-api . 2. Run the Docker Container Run the container locally or deploy it to any cloud service:
bash Copy Edit docker run -d -p 8000:8000 ucwa-api Tests The SDK includes unit and integration tests for verifying functionality.
Run Unit Tests Run the tests locally with:
bash Copy Edit pytest tests/ Ensure you have pytest installed before running tests:
bash Copy Edit pip install pytest
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 ucwa_sdk-1.0.0.tar.gz.
File metadata
- Download URL: ucwa_sdk-1.0.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23466c11c0407564ec2edb6d06cd01614050db85cfe9b5421d2e0da650f803f7
|
|
| MD5 |
952cb1ec13c6e7b26cb5882410a4a7e2
|
|
| BLAKE2b-256 |
5e1850f505ff43bfc91d61bc537394d39e49f2982238c4a55f0aa00e4e3e808d
|
File details
Details for the file ucwa_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ucwa_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
127c9be2b3cfd3103ad762fa67d936afe1bcb9ccaae093f0a016d4b63ce97da0
|
|
| MD5 |
02cd8899a71c42806cf0be0686b4efb2
|
|
| BLAKE2b-256 |
37fb270cb8788b862552993aa7254d3c6f0c1134a9fcb2010dc25f8f1429b264
|