Skip to main content

patera-aiinterface

Experimental LLM interface for Patera: prompts, chat history and retrieval augmentation. Part of Patera, a modular async-first Python web framework.

Experimental. This package is not yet ready for production use; its API may change in any release.

Installation

pip install patera-aiinterface
# with retrieval augmentation (sentence-transformers, PyTorch, pgvector)
pip install "patera-aiinterface[augmentation]"

Requires Python 3.13 or newer and patera>=0.121.

Usage

patera-aiinterface connects to chat completion APIs (OpenAI-compatible and Ollama). Retrieval augmentation needs the augmentation extra; everything else works without it.

from typing import AsyncIterator, Optional

from patera.aiinterface import (
    AiService, AiServiceConfig, ChatResponse, SqlHistoryProvider, history, system_prompt, user_prompt,
)
from patera.aiinterface.service_provider.openai import OpenAIServiceProvider


class ChatHistory(SqlHistoryProvider[ChatMessageRow]):   # a model with session_id, role,
    model = ChatMessageRow                               # content and order_number columns


class Assistant(AiService):
    service_provider = OpenAIServiceProvider()           # or OllamaServiceProvider()
    history_provider = ChatHistory()

    @system_prompt("You are a helpful translator.")
    @user_prompt("Translate '<:text>' to <:language>.")
    async def translate(self, text: str, language: str = "German") -> ChatResponse: ...

    @history
    @system_prompt("You are a friendly assistant.")
    @user_prompt("<:message>")
    async def chat(self, session_id: Optional[str], message: str) -> AsyncIterator[ChatResponse]: ...


class Config(BaseConfig):
    ...
    ASSISTANT: AiServiceConfig = AiServiceConfig(
        BASE_URL="https://api.openai.com/v1", API_KEY="...", MODEL="gpt-4o-mini", HISTORY_LIMIT=10,
    )

See the AI interface (experimental) section of the Patera documentation for the full guide.

Local integration results and reproduction steps are in VALIDATION.md.

License

MIT. See LICENSE.

Metadata

Release files for patera-aiinterface 0.13.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for patera-aiinterface 0.13.5
File Size Uploaded Provenance Actions
patera_aiinterface-0.13.5.tar.gz 19.6 kB Without provenance Details for patera_aiinterface-0.13.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for patera-aiinterface 0.13.5
File Interpreter ABI Platform Actions
patera_aiinterface-0.13.5-py3-none-any.whl Python 3 none any Details for patera_aiinterface-0.13.5-py3-none-any.whl

Total release size: 46.9 kB

Release files / patera_aiinterface-0.13.5.tar.gz

Download URL patera_aiinterface-0.13.5.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a4c715d80d3407cd929db1f95cca45d03bfedcd669a08892d79630dae0e23ea8
BLAKE2b-256 checksum
How to use checksums
cee82f19f0cd45d71419a972a257eecb57d098d5e5b73b9f1565d5faa137ce43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / patera_aiinterface-0.13.5-py3-none-any.whl

Download URL patera_aiinterface-0.13.5-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ff2cd077fac1f67abec99976eb550a8c67261084b847f02d917fc8c6aa8b7f
BLAKE2b-256 checksum
How to use checksums
1b9ef0f899f3d2a05e59a04e8de54e2d50b4e824d5ad42c4fbe462fab9cbc7c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for patera-aiinterface 0.13.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.13.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page