feat(providers): add extra_body config for OpenAI-compatible endpoints
Add an `extra_body` field to `ProviderConfig` that merges arbitrary key-value pairs into every OpenAI-compatible request body. This is the escape hatch for provider-specific features that nanobot does not have first-class fields for. Real-world use cases this unblocks via config alone (no code changes): - vLLM/TGI `chat_template_kwargs` (e.g. `enable_thinking: false`) - vLLM guided decoding (`guided_json`, `guided_regex`) - Local model sampling params (`repetition_penalty`, `top_k`, `min_p`) - Any future provider-specific param without a new PR each time The config extra_body is applied last via recursive deep-merge, so it can extend or override provider-specific defaults (e.g. thinking params) without clobbering sibling keys set by internal logic. Changes: - Add `extra_body: dict[str, Any] | None` to `ProviderConfig` - Pass it through `factory.py` to `OpenAICompatProvider.__init__` - Deep-merge into `_build_kwargs` after all internal extra_body entries - Add `_deep_merge` helper (recursive dict merge, does not mutate inputs) - 21 tests: deep-merge semantics, provider init, _build_kwargs integration, thinking coexistence, real-world patterns (guided_json, repetition_penalty), and schema validation
This commit is contained in:
@@ -69,6 +69,7 @@ def make_provider(config: Config) -> LLMProvider:
|
||||
default_model=model,
|
||||
extra_headers=p.extra_headers if p else None,
|
||||
spec=spec,
|
||||
extra_body=p.extra_body if p else None,
|
||||
)
|
||||
|
||||
defaults = config.agents.defaults
|
||||
|
||||
Reference in New Issue
Block a user