VAKLM
A Python client for interacting with OpenAI-compatible API endpoints with reasoning support.
Installation
pip install vaklm
Usage
Basic Usage
from vaklm import vaklm, VAKLMException
# Non-streaming response with reasoning
try:
content, reasoning = vaklm(
endpoint="http://localhost:11434/v1/chat/completions",
model_name="llama3.2:latest",
user_prompt="Explain quantum computing in simple terms",
system_prompt="You are a helpful AI assistant",
api_key="YOUR_API_KEY",
temperature=0.7
)
print("Content:", content)
print("Reasoning:", reasoning)
except VAKLMException as e:
print(f"Error: {str(e)}")
Streaming Usage
from vaklm import vaklm
print("\nStreaming example:")
try:
for content, reasoning in vaklm(
endpoint="http://localhost:11434/v1/chat/completions",
model_name="llama3.2:latest",
user_prompt="Write a short story about a cat.",
system_prompt="You are a creative writer.",
api_key="YOUR_API_KEY",
stream=True,
temperature=0.7
):
print(content, end='', flush=True)
if reasoning:
print(f"\n[Reasoning: {reasoning}]")
except VAKLMException as e:
print(f"Error: {str(e)}")
Features
- Supports both streaming and non-streaming responses
- Includes reasoning content in responses
- Automatic retry logic for failed requests
- Configurable temperature and max tokens
- System prompt support for context setting
- Comprehensive error handling
Configuration
The vaklm function accepts the following parameters:
endpoint: API endpoint URL (required)model_name: Model identifier (required)user_prompt: User's input message (required)system_prompt: Optional system context messageapi_key: API key for authenticationstream: Whether to stream the response (default: False)temperature: Sampling temperature (0-2, default: 1.0)max_tokens: Maximum tokens to generatetimeout: Request timeout in seconds (default: 30)max_retries: Maximum retry attempts (default: 3)retry_delay: Base delay between retries (default: 1.0)
Error Handling
The client raises VAKLMException for general errors, with specific subclasses:
APIError: For API-specific errorsStreamingError: For streaming-specific errors
Always wrap calls in try/except blocks to handle potential errors.
Metadata
Release files for vaklm 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vaklm-0.3.1.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vaklm-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / vaklm-0.3.1.tar.gz
| Download URL | vaklm-0.3.1.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65270f788ae7db5d438583647ae57541054fd83cc0f87b8be5deb044d21c3288
|
|
BLAKE2b-256 checksum How to use checksums |
381238921fb19c1615efcac3d9f1ef79aadf5c87ba6835878cbf3b4fe7039b8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / vaklm-0.3.1-py3-none-any.whl
| Download URL | vaklm-0.3.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a80e72ad86536e92fb49aaade087bf5eced8b8c8a41796ff75ec91c3119a03ce
|
|
BLAKE2b-256 checksum How to use checksums |
3ce8cdd92f524b00a56333d5a743181c9e426a84df31c72091143b54ee31e410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|