feat: support /api/v0/models for context length discovery#22
feat: support /api/v0/models for context length discovery#22SerenityG4K wants to merge 2 commits into
Conversation
Query LM Studio's native /api/v0/models endpoint to read loaded_context_length and max_context_length, exposed via limit.context in the model config. This enables OpenCode features like auto-compaction based on the context window actually configured in LM Studio. Falls back transparently to /v1/models on older LM Studio versions (< 0.3.5) with a warning log. - Add LMStudioModelV0 types for /api/v0/models response - New discoverLMStudioModelsV0() function with 404→null fallback signal - enhance-config: prioritize v0 endpoint, map loaded_context_length to limit.context - Output tokens capped at 16384, 1/4 of context window - 3 new tests covering v0 success, 404 fallback, max_context_length handling - Update README features and How It Works sections Co-Authored-By: Claude Opus 4.7
| if (contextLength && contextLength > 0) { | ||
| modelConfig.limit = { | ||
| context: contextLength, | ||
| output: Math.min(Math.floor(contextLength / 4), MAX_OUTPUT_TOKENS_CAP) |
There was a problem hiding this comment.
Curious why the hard cap here relying on the static variable? Any way - aside from modifying the source - to change this? It would be quite useful if the configuration parameters for the plugin could be used to set this hard-ceiling. while I realize it's not as common, there are certainly users out there potentially leveraging much higher context lengths than expected, and capping the ceiling results in models suddenly cutting off if the output exceeds 16k. (Just curious - not poking)
|
I think this did the same thing as the #19 ? |
|
Thank you @SerenityG4K for the |
Query LM Studio's native /api/v0/models endpoint to read loaded_context_length and max_context_length, exposed via limit.context in the model config. This enables OpenCode features like auto-compaction based on the context window actually configured in LM Studio.
Falls back transparently to /v1/models on older LM Studio versions (< 0.3.5) with a warning log.
Co-Authored-By: Claude Opus 4.7