Repository navigation
Conversation
Signed-off-by: zlg-codes <light131455@gmail.com>
Author
|
This PR is now marked ready for review. #7018 has been temporarily moved to draft to free a non-draft slot under the repository’s open PR limit; no pull requests were closed. The rebased branch and validation results in the description are current. |
surlymochan
reviewed
Dec 5, 2026
surlymochan
left a comment
There was a problem hiding this comment.
Reviewed the diff (not a maintainer approval — just a verification note from reading the code):
What checks out:
- The native
/api/chatpayload is built correctly for the covered cases:num_ctxlands inoptions,temperature/top_p/top_k/seed/stopmove intooptions,max_tokensmaps tonum_predict, the response schema is passed viaformatfor structured models and omitted forstr, and the endpoint rewrite strips a trailing/v1. The cache-key change (explicit value only,Nonefor the default) is covered by a test, including the env-var alias.
Three things worth confirming, because the change is bigger than the title suggests:
- This is not just "apply
num_ctx" — any user who setsLLM_OLLAMA_NUM_CTXnow leaves the instructor/OpenAI-compatible path entirely and goes through native/api/chat, which changes structured-output semantics (nativeformatschema instead of instructor's JSON/tool-call modes). Users who already setnum_ctxtoday will silently switch paths on upgrade. Is that intended, and should it be called out in the docs/release notes? _acreate_native_outputraisesValueErrorfor anyllm_argskey outside its allow-list (temperature,top_p,top_k,seed,stop,max_tokens,max_completion_tokens). The OpenAI-compatible path previously passed other kwargs through (e.g.frequency_penalty,presence_penalty), so a user with those set plusnum_ctxwould go from working to a hard error. Is failing loudly the intended contract, or should unknown kwargs be forwarded intooptionslike theextra_bodykeys are?- The native call uses
AsyncClient(timeout=None), so a hung Ollama server would hang this call indefinitely. The OpenAI-compatible path goes through the configured client — should the native call carry a timeout as well?
… chat Signed-off-by: zlg-codes <light131455@gmail.com>
Author
|
Thanks for reading through the diff so carefully — #2 and #3 were real gaps.
Pushed |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7014.
LLM_OLLAMA_NUM_CTXwas merged intoextra_bodyon the OpenAI-compatible chat path. Ollama ignores that top-level field, so the configured context size never reached the model. The environment variable also was not mapped to the corresponding settings field.This change maps the setting and, when
ollama_num_ctxis explicitly configured, sends chat requests to Ollama's native/api/chatendpoint withoptions.num_ctx. Plain-text and structured-output requests are both covered. When the setting is unset, the existing OpenAI-compatible path is unchanged.Acceptance Criteria
LLM_OLLAMA_NUM_CTXreaches the Ollama adapter asollama_num_ctx.options.num_ctxthrough/api/chat.Type of Change
Screenshots
Validation on the branch rebased onto current
dev(b0c6c567):A real local Ollama
llama3.2:latestround-trip returnedOKfor both plain text and structured output./api/psreportedcontext_length=4096for the loaded model.Pre-submission Checklist
CONTRIBUTING.md)DCO Affirmation
I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.