Skip to main content

No project description provided

Project description

VAKLM - Versatile AI Knowledge Language Model

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 message
  • api_key: API key for authentication
  • stream: Whether to stream the response (default: False)
  • temperature: Sampling temperature (0-2, default: 1.0)
  • max_tokens: Maximum tokens to generate
  • timeout: 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 errors
  • StreamingError: For streaming-specific errors

Always wrap calls in try/except blocks to handle potential errors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vaklm-0.2.7.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vaklm-0.2.7-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file vaklm-0.2.7.tar.gz.

File metadata

  • Download URL: vaklm-0.2.7.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for vaklm-0.2.7.tar.gz
Algorithm Hash digest
SHA256 0f09b7dc181d0055530f59a18df79f0378016e9b00d68016401c2b6a55722ae2
MD5 6dfecdbae87275ba120fd128b62ea0ba
BLAKE2b-256 6d75695307877c0684ab2e0cf68f2d72109d4a1a0325216c53a10588a5f719fb

See more details on using hashes here.

File details

Details for the file vaklm-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: vaklm-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for vaklm-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e7a46b2bacfea15d1dddb0b55d129c225cb7db0bfe645dfe05be8a68494897
MD5 022c37d318d78955bdee54e44936569a
BLAKE2b-256 06810a87dae912417cb4519cf4dbd87d3bf2b975092c024b471244e1830655a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page