feat: make openAICompatibleProvider work with Infomaniak out of the box (0.3.0)

- response_format is omitted by default (Infomaniak rejects the legacy
  json_object → HTTP 422); opt in via the new `responseFormat` option
  ({type:'json_object'} or a json_schema object). BREAKING for endpoints
  that relied on the forced json_object.
- parse LLM JSON leniently (tolerate markdown fences / surrounding prose)
- fold strict-coherence rules into DEFAULT_SYSTEM_PROMPT (exact
  placeholder<->mapping-key identity, values are originals, strict format,
  mask value not adjacent label) → reliable output across models

Verified live against Gemma 4 (google/gemma-4-31B-it, Infomaniak v2): all
demo phrases anonymize with clean round-trips, no custom provider needed.
36 tests passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mobiletic
2026-07-01 09:43:19 +01:00
parent 669794522e
commit f5c9f0fbd4
5 changed files with 84 additions and 9 deletions

View File

@@ -4,6 +4,22 @@ All notable changes to this project are documented here. The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.3.0] - Unreleased
### Changed
- **`openAICompatibleProvider` now works with Infomaniak (and other open-model endpoints) out of the box.**
`response_format` is **omitted by default** instead of hard-coding `{ type: 'json_object' }`, which
current Infomaniak rejects (HTTP 422). Pass the new `responseFormat` option (e.g. `{ type: 'json_object' }`
or a `json_schema` object) for endpoints that support/require it. **Breaking** for endpoints that relied
on the previous forced `json_object`.
- JSON responses are now **parsed leniently** — a fenced JSON code block or surrounding prose is tolerated
(the outermost `{ … }` is extracted), so models without an enforced `response_format` don't cause
spurious parse failures.
- The default prompt gained a **COHÉRENCE** block (exact placeholder↔mapping-key identity, values are the
original data never another placeholder, strict `[TYPE_N…]` format, mask the value not the adjacent
label) to improve reliability across models.
## [0.2.0] - Unreleased
### Added