feat(generic-openai): passthrough sampling and extra request params - #6048
feat(generic-openai): passthrough sampling and extra request params#6048Souravrajvi0 wants to merge 2 commits into
Conversation
Add env-configurable OpenAI Chat Completions fields (top_p, frequency_penalty, presence_penalty, seed, stop) and a GENERIC_OPEN_AI_EXTRA_PARAMS JSON escape hatch for provider-specific params. Applies to chat and agent generic-openai providers. Fixes Mintplex-Labs#6043
|
You guys are awesome. Looking forward to release. Thank you |
|
Instead of doing this through an infinitely long ENV we wanted to support this via a This would be easier to support long term since you could just add and type in any value as every provider has different configs and error states that even have side effects to the model selection too. It might even make sense to have model id subkeys in this config so that the same config can be tuned per provider/model selection. |
|
+1 on moving this to storage/config/llm/.json — and the per-model subkey idea is genuinely useful beyond just this issue (we occasionally A/B different local models against the same workspace and having per-model tuning live in one place would be nice). One thing I’d like to confirm before it’s built, since it determines whether this actually solves the problem for us: will the new config format still support arbitrary/unlisted parameters, not just a curated set of named fields (top_p, frequency_penalty, etc.)? The concrete case that pushed us to file the original issue was repetition_penalty and xtc_probability/xtc_threshold — sampler params exposed by our local inference server (oMLX, MLX-based) that aren’t part of the standard OpenAI Chat Completions spec at all. We hit a real repetition-loop degeneration in production that these params fixed, but had no way to pass them through the Generic OpenAI provider, and ended up bypassing AnythingLLM’s chat API entirely to call our inference server directly instead — which works, but means we lose being able to browse/interact with that workflow’s output through AnythingLLM itself. If the new config file ships as a fixed schema of named OpenAI-spec fields, it’ll fix the issue for standard params but not for cases like ours. If it keeps something equivalent to the original PR’s GENERIC_OPEN_AI_EXTRA_PARAMS escape hatch (freeform JSON merged into the request body), that covers both — happy to test against a real oMLX deployment once there’s something to try. |
Address PR feedback by replacing GENERIC_OPEN_AI_* sampling/extra ENV vars with storage/config/llm/<provider>.json. Params are spread into chat and agent inference, support arbitrary provider keys, and allow optional per-model overrides under a models map.
|
Thanks for the direction @timothycarambat — updated this PR to use What changed
{
"top_p": 0.9,
"repetition_penalty": 1.1,
"xtc_probability": 0.1,
"models": {
"my-local-model": { "repetition_penalty": 1.2 }
}
}Copy |
|
@aikidovation yes — freeform / unlisted keys are supported. There is no curated allowlist of OpenAI-only fields. Whatever you put in {
"repetition_penalty": 1.1,
"xtc_probability": 0.1,
"xtc_threshold": 0.1,
"models": {
"your-omlx-model-id": {
"repetition_penalty": 1.2
}
}
}Copy |
|
Great, @Souravrajvi0, that resolves my concern. Looking forward to the fix! |
|
Ran the smoke test you asked for — and then some. Built this branch ( 1. Isolated smoke test. Separate container/volume, with a proxy standing in for the LLM backend so I could capture the literal outgoing request body. Dropped this in as {
"repetition_penalty": 1.15,
"xtc_probability": 0.5,
"xtc_threshold": 0.1,
"top_p": 0.95,
"models": {
"my-model-id": { "seed": 42 }
}
}The captured request showed all four top-level keys passed through verbatim (including 2. Production stress test. Swapped this build into my actual production AnythingLLM instance (backed up first) and reverted a pipeline I'd previously had to bypass AnythingLLM entirely for, specifically because of the gap this PR fixes ( One unrelated build note in case it trips anyone else up testing locally: Happy to answer questions about the setup if useful for review. |
|
@aikidovation thank you for the thorough verification — especially the production stress test with the real oMLX + Gemma path. Really glad the freeform passthrough + per-model merge behaved as expected and unblocked that pipeline. Noted on the Node 18 nodesource 403 during local Docker builds; agreed that’s upstream/EOL unrelated to this change. |
|
Following up since this went quiet for a month — noticed it was unassigned on 2026-08-26 with no comment, and today's v1.16.1 release doesn't include it either. For context on where things stood: as of the last exchange here (2026-07-28), this had been verified two ways against a real production oMLX + Gemma deployment — an isolated request-capture test confirming the freeform passthrough + per-model merge work exactly as designed, and a live production stress test (6 back-to-back generations through AnythingLLM's actual chat API) with zero regressions, replacing a workaround we'd been forced into (bypassing AnythingLLM's chat API entirely) specifically because of the gap this fixes. Is there anything blocking review at this point, or is this queued behind other work? Happy to re-verify against a newer base if a rebase is the holdup. This is still genuinely needed on our side (see #6043) and it'd be a shame for fully-verified work to stall out with no explanation. |
Pull Request Type
Relevant Issues
resolves #6043
Description
The Generic OpenAI provider (
generic-openai) only forwardedmodel,messages,temperature, andmax_tokensto OpenAI-compatible backends. Standard Chat Completions sampling params and provider-specific extensions (e.g.repetition_penalty,xtc_probability) were silently dropped.Per maintainer feedback, this is now configured via a JSON file instead of ENV vars:
storage/config/llm/<provider>.json{ "top_p": 0.9, "repetition_penalty": 1.1, "xtc_probability": 0.1, "xtc_threshold": 0.1, "models": { "my-local-model": { "top_p": 0.95, "repetition_penalty": 1.2 } } }models.<modelId>overrides merge on top of provider defaultsmodel,messages,stream,tools, etc.) cannot be overriddenShared helper:
server/utils/helpers/llmProviderConfig.js(getLLMProviderRequestParams) so other providers can adopt the same pattern later.Visuals (if applicable)
N/A
Additional Information
server/storage/config/llm/generic-openai.json.example,README.mdserver/__tests__/utils/AiProviders/genericOpenAi/index.test.js(9 tests)storage/config/llm/*.json)Local testing performed:
Results:
yarn lint:ci— passyarn test— 246/246 tests pass (29 suites)Developer Validations
yarn lintfrom the root of the repo & committed changes