Metadata-Version: 2.4
Name: docker-model-runner
Version: 0.1.0
Summary: Python Client for Docker Model Runner
Author: Docker Model Runner Team
License: MIT
Project-URL: Homepage, https://github.com/AIMLDev726/docker_model_runner_python_client
Project-URL: Repository, https://github.com/AIMLDev726/docker_model_runner_python_client
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: pydantic>=1.8.0
Requires-Dist: typing-extensions>=4.0.0
Dynamic: license-file


# Docker Model Runner Client

A Python client for interacting with Docker Model Runner, providing a standard API interface for chat completions, embeddings, and more.

[![GitHub](https://img.shields.io/badge/GitHub-Repository-blue)](https://github.com/AIMLDev726/docker_model_runner_python_client)

## Installation

Install via pip:

```bash
pip install docker-model-runner
```

## Quick Start

### Synchronous Client

```python
from docker_model_runner import Client

client = Client(base_url="http://localhost:12434/engines/llama.cpp/v1")  # API key optional

# Chat completion
response = client.chat.completions.create(
    model="your-model",
    messages=[{"role": "user", "content": "Hello, world!"}]
)

print(response['choices'][0]['message']['content'])
```

### Asynchronous Client

```python
import asyncio
from docker_model_runner import AsyncClient

async def main():
    async with AsyncClient(base_url="http://localhost:12434/engines/llama.cpp/v1") as client:  # API key optional
        response = await client.chat.completions.create(
            model="your-model",
            messages=[{"role": "user", "content": "Hello, world!"}]
        )
        print(response['choices'][0]['message']['content'])

asyncio.run(main())
```

### Tool Calls

```python
from docker_model_runner import Client

client = Client()  # Uses default base_url, API key optional

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"location": {"type": "string"}},
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="your-model",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools,
    tool_choice="auto"
)

# Handle tool calls
message = response['choices'][0]['message']
if message.get("tool_calls"):
    for tool_call in message["tool_calls"]:
        print(f"Tool: {tool_call['function']['name']}")
```

## Features

- Synchronous and asynchronous clients
- Chat completions with streaming support
- Embeddings
- Tool calls with local handling
- Compatible with standard API format

## API Reference

### Client

- `Client(base_url, api_key)`: Initialize sync client (api_key optional)
- `client.chat.completions.create(model, messages, **kwargs)`: Create chat completion
- `client.chat.completions.stream(model, messages, **kwargs)`: Stream chat completion
- `client.embeddings.create(model, input, **kwargs)`: Create embeddings
- `client.models.list()`: List available models

### AsyncClient

- `AsyncClient(base_url, api_key)`: Initialize async client (api_key optional)
- Similar methods as Client, but async

### Tool Choice

- `"auto"`: Let model decide (default)
- `"none"`: Don't use tools
- `"always"`: Force tool usage

## License

MIT License - see LICENSE file for details
