feat(adapters): extend prompt fallback to the OpenAI and Ollama backends

オープン
#1,748 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@ajbozarth がすでに取り組んでいます。

2026年10月19日 から。

評価

この issue はまだ評価されていません。

説明

area/adapter-functions area/backends

#1654 added prompt fallback for adapter functions on the LocalHF backend and closes #993 as that slice. Extend the same capability to the two served-adapter backends, OpenAI and Ollama, so an adapter function can fall back to a hand-authored prompt when no trained or embedded adapter exists for the model.

This is wanted on both backends; the implementation design is open. The LocalHF work was deliberately scoped to land first, with the served backends split out to this follow-up.

Firm constraint: a fallback must register at the resolve layer

The one thing already settled, because it follows from #1654's shipped design. The high-level helpers (rag.check_answerability, core.requirement_check, …) call backend.resolve_adapter(name) before generating, so a fallback is reachable through the documented API only if resolve_adapter registers it — hooking generation alone is not enough.

For OpenAI this is sharp: resolve_adapter takes the embedded-discovery branch (_uses_embedded_adapters = True), and for a model with no published embedded adapter, discovery registers nothing and resolve_adapter raises before generation runs. A generation-time-only fallback would be unreachable via the helpers — it would fire only on the low-level mfuncs.act(Intrinsic(...)) path.

Reusable pieces #1654 already provides:

  • PromptBinding (weightless WeightsBinding), AdapterType.PROMPT, widened Identity.adapter_type — _core.py.
  • resolve_prompt_io_yaml(...) and the adapter_type param on adapter_subpath/obtain_io_yaml — intrinsics/util.py (model-specific → any, with the sub-par warning).
  • The invocation-complete telemetry helpers — OpenAI's embedded path already uses them.

Current seams (for scoping)

Where a fallback would hook, as the code stands on this branch:

  • OpenAI (openai.py): add_adapter accepts only EmbeddedBinding; resolution runs through the shared AdapterMixin.resolve_adapter embedded branch (no availability walk); _generate_from_intrinsic dispatches embedded adapters by editing the request. A trained LocalFileBinding cannot be loaded by a remote backend, so only the prompt path is relevant here.
  • Ollama (ollama.py, adapter support added in #1634): overrides resolve_adapter / _resolve_adapter_uncoalesced, which raises when a capability has no adapter_models tag; add_adapter requires ServerMediatedBinding.

Design questions to settle

  • Validity, per capability. A prompt fallback is base-model prompting, the same class as LLM-as-a-judge. On a served model with no trained adapter — the headline case — the comparison is "prompt fallback vs. nothing," so it is useful where it works; but for some capabilities a purpose-authored prompt with a constrained schema may not be reliable enough to present as an adapter-function result. Decide which capabilities clear that bar.
  • Ollama feasibility. Unconfirmed whether the transform/rewriter path works for a plain Ollama base-model prompt (an earlier look flagged message-format support as a possible blocker). If it does not, Ollama is a larger effort than OpenAI and the two may want sequencing separately.
  • OpenAI hook point. Extend the shared AdapterMixin.resolve_adapter embedded branch, or an OpenAIBackend-local override (as Ollama does)? Either touches shared code.
  • Shared helper. Whether to extract a prompt-only resolve helper (resolve_prompt_io_yaml → PromptBinding-composed Adapter → add_adapter(config=...)) shared across backends, or let each implement its own.
  • Ollama telemetry. Whether invocation-complete telemetry is wired for Ollama (its docstrings note that as outstanding) so a prompt path reports consistently with the other backends.

Docs / tests

  • docs/docs/advanced/intrinsics.md describes backend coverage in a prose backend note, and its prompt-fallback section is LocalHF-framed; both need updating once a backend gains support.
  • Mirror #1654's per-backend unit coverage (PromptBinding dispatch + resolve registration). For any e2e, reuse the access-guard pattern in test/backends/test_adapters/test_adapter_resolution_e2e.py and the public-repo retarget tracked in #1655.

Related

  • #993 — the prompt-fallback feature (closed by #1654, LocalHF slice).
  • #1654 — the LocalHF implementation this extends.
  • #1634 — Ollama adapter-function support (prerequisite, merged).
  • #1655 — retarget e2e off the temporary private fixture repo.
主要言語
Python
スター
1.8k
フォーク
161
平均マージ
4日 3時間
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

generative-computing/mellea のほかの issue

generative-computing/mellea の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。