Skip to main content

Python SDK to call all LLM apis.

Project description

Unified LLM Python API Library

A unified interface for interacting with multiple LLM providers (OpenAI compatible only for now) with consistent API design.

Features

  • Single interface for multiple LLM providers
  • Standardized request/response formats
  • Easy provider configuration

Basic Usage

Async call

DEEPSEEK_BASE_URL=https://api.deepseek.com
DEEPSEEK_API_KEY=sk-xxxx
from kissllm import LLMClient
from kissllm.tools import tool

# Example tool definition
@tool
def get_weather(location: str, unit: str = "celsius"):
    """Get current weather for a location"""
    # Mock implementation
    return f"Sunny 22°C in {location}"

# Initialize client with provider/model
client = LLMClient(provider_model="deepseek/deepseek-chat")

async def main():
    # Basic async completion
    response = await client.async_completion(
        messages=[{"role": "user", "content": "What's the weather in Paris?"}],
        tools=True,
        tool_choice="auto"
    )
    print(response.choices[0].message.content)

    # Async streaming
    stream = await client.async_completion(
        messages=[{"role": "user", "content": "What's 15*27?"}],
        stream=True,
        tools=[{
            "type": "function",
            "function": {
                "name": "calculate",
                "description": "Calculate math expressions",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "expression": {"type": "string"}
                    }
                }
            }
        }]
    )

    print("\nStreaming response:")
    async for chunk in stream.iter_content():
        print(chunk, end="")

    # Continue with tool results
    if response.tool_calls:
        continuation = await client.continue_with_tool_results(response)
        print("\n\nFinal answer:")
        print(continuation.choices[0].message.content)

# Run the async application
import asyncio
asyncio.run(main())

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

kissllm-0.0.1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

kissllm-0.0.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file kissllm-0.0.1.tar.gz.

File metadata

  • Download URL: kissllm-0.0.1.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kissllm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 020f92407adc58c7de8df03ebcf9ff6a8d88da510899de0616e0e6b62e375316
MD5 2c4a60479ceaac17d28ade79214e724d
BLAKE2b-256 b36e973b475059ef1d6d0e5daa11e6be7d4bcad001bc30ce8b910aa7e5a1ce61

See more details on using hashes here.

Provenance

The following attestation bundles were made for kissllm-0.0.1.tar.gz:

Publisher: publish-to-pypi.yml on Arosial/kissllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kissllm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: kissllm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kissllm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b9cbf8c91b16b2d800bf1e9cb1e4acd13932f8612b9bab5146e81c6937a71a
MD5 76be437580449130d9738c32b62cc243
BLAKE2b-256 fdf8b800a0e691f80fc191f8e07640f26082790f2c7a6d3571bcb29ccf71d4d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kissllm-0.0.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Arosial/kissllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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