Metadata-Version: 2.5
Name: invera-sdk
Version: 0.7.2
Summary: invera Python SDK for ready-to-consume attributed chat completions
Author: Layerwise GmbH
License-Expression: LicenseRef-PolyForm-Perimeter-1.0.1
License-File: LAYERWISE-ADDITIONAL-PERMISSION.md
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: jinja2>=3.1
Requires-Dist: transformers<6,>=4.51
Description-Content-Type: text/markdown

# invera-sdk

Current version: **0.7.2**

Python SDK for invera, developed by Layerwise GmbH.

Documentation, guides, recipes, and the full API reference live at
[developer.layerwise.ai](https://developer.layerwise.ai).

## License

PolyForm Perimeter License 1.0.1 together with the Layerwise SDK Additional
Permission. The complete terms and a plain-language summary are published at
[developer.layerwise.ai/license](https://developer.layerwise.ai/license).
The distribution ships both license texts as `LICENSE` and
`LAYERWISE-ADDITIONAL-PERMISSION.md`.

## Changelog

<!-- changelog:start -->
- **0.7.2** (2026-11-05)
  - No changes to the Python package's API or behavior. New [Hallucination detection recipe](https://developer.layerwise.ai/recipes/hallucination-detection) on developer.layerwise.ai: a runnable RAG example that streams an answer with `stream_with_evidence` and shows, flags, or withholds it based on per-claim grounding scores, `requires_review`, and an optional semantic verifier, plus guidance on calibrating the thresholds on your own data.
  - New [LLM judge escalation recipe](https://developer.layerwise.ai/recipes/llm-judge-escalation): extends the hallucination detection recipe so that an LLM judge checks only the claims attribution does not settle, including claims grounded in the question rather than in a retrieved chunk. The judge confirms the hallucination (the claim is withheld) or rejects it (the claim is shown).
- **0.7.1** (2026-11-05)
  - Engines that report `contract.chat_completions_endpoint: true` or `contract.supports_sampling: true` are no longer rejected. These flags describe other routes of the Engine server; the SDK never calls a chat route or sends sampling parameters. Compatibility now depends only on how `POST /v1/raw_attribution` decodes: `contract.decoding` must be `greedy_argmax`, otherwise the client raises `EngineCompatibilityError` before any raw attribution request.
  - The Python SDK now also checks `contract.decoding`, as the TypeScript SDK already did. `EngineContract` has a new `decoding` field (default `None`, which is rejected); discovery fills it from the Engine's contract metadata.
- **0.7.0** (2026-11-05)
  - Breaking: requires Engine Contract `>=1.3.1 <2.0.0` (was `>=1.3.0 <2.0.0`). Contract 1.3.1 reports `sdk_hints.recommended_tool_parser` for each model; a Contract 1.3.0 Engine is rejected with `EngineCompatibilityError`.
  - The client now serves any model its invera Engine reports in `GET /v1/models`, not only release-pinned profiles. It loads the tokenizer from the reported Hugging Face `tokenizer.id` and immutable `tokenizer.revision` and accepts it only when its locally computed fingerprint equals `tokenizer.fingerprint`. A new model or tokenizer revision needs no SDK release.
  - `model_type` is no longer an allowlist. Discovery is instead checked for a pinned tokenizer identity (40-character commit revision, SHA-256 fingerprint), an available chat template, valid EOS and special token ids, and a supported `sdk_hints.recommended_tool_parser`. Each failure raises `EngineCompatibilityError` before any `POST /v1/raw_attribution`; a tokenizer fingerprint mismatch now raises `EngineCompatibilityError` instead of `RuntimeError`.
  - Models whose Engine recommends no tool parser stream text completions; a request with `tools` for such a model raises `EngineCompatibilityError`.
  - Tool calls are now parsed in both formats the Engine recommends: `qwen_json_tool_call`, Hermes-style JSON inside `<tool_call>` (Qwen2.5, Qwen3, QwQ), and `qwen_xml_tool_call`, XML per parameter (Qwen3.5 and later). The client picks the format from `sdk_hints.recommended_tool_parser`. Streaming chunks, `ParameterEvidence`, and the pre-execution tool-call decision are equivalent for the same call in either format; a malformed JSON call is reported with the schema issue code `invalid_json`.
  - Breaking (advanced): `parse_qwen_tool_calls` and `stream_evidence` require the tool parser (`stream_evidence(..., tool_parser=...)`); there is no implicit `qwen_xml_tool_call` default. Pass the Engine's `recommended_tool_parser`; `stream_evidence` accepts `None` for streams without tool calls.
  - Discovery must report exactly one model per Engine endpoint; zero or several entries raise `EngineCompatibilityError` (several were previously resolved to the first supported entry). The SDK still never asks the Engine for a specific model.
  - A custom `TokenizerAdapter` passed to `create_client_with_tokenizer` now works for any model whose identity exactly matches discovery, without static profile resolution.
  - Breaking (`invera_sdk.advanced`): `MODEL_PROFILES`, `ModelProfile`, and `SUPPORTED_MODEL_PROFILES` are removed; the new `SUPPORTED_TOOL_PARSERS` lists the parsable tool-parser hints. `create_hugging_face_tokenizer` now takes the expected `TokenizerIdentity` instead of a `ModelProfile`.
- **0.6.1** (2026-10-02)
  - Supports invera Engines serving `Qwen/Qwen3.8-27B` through the new release-pinned `qwen3.8-27b` tokenizer profile. The client still picks the profile from the tokenizer identity the Engine reports; there is no model option.
- **0.6.0** (2026-10-02)
  - Breaking: the SDK now supports only invera Engines serving `Qwen/Qwen3.5-4B` (tokenizer profile `qwen3.5-4b`, model family `qwen3_5`). `Qwen/Qwen3-4B-Instruct-2507` is no longer supported.
  - Breaking: the `model` client option is removed. The client always uses the release-pinned model profile; it cannot choose a model.
  - Breaking: requires Engine Contract `>=1.3.0 <2.0.0` (was `>=1.2.0 <2.0.0`).
  - Breaking: tool calls are parsed only in the Qwen3.5 XML format (`<function=…><parameter=…>…</parameter></function>`); parameter values are typed from the tool's JSON schema. A malformed call is reported with the new schema issue code `invalid_xml`, which replaces `invalid_json`.
  - The default tokenizer adapter now works with Transformers 4.x as well: its tokenizer fingerprint no longer depends on the installed Transformers major version, which previously failed the pinned-profile check on 4.x.
  - `tool-description` messages are display-only: the default tokenizer never renders them into the prompt. Pass tool definitions through `tools`.
<!-- changelog:end -->

The complete history is published at
[developer.layerwise.ai/changelog/python](https://developer.layerwise.ai/changelog/python).
