mirror of
https://github.com/lemonade-sdk/lemonade.git
synced 2026-11-23 08:49:28 -10:00
codex/auto-model-source
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d397a6e8fa |
Add SystemOne decision models: /v1/systemone, GGUF zero-shot on /v1/classify, and the systemone router classifier (#3956)
* main into zero shot, post refactoring * cleanup * cleanup * CR feedback: fixed the residency document clarification bug * cr feedback: fake tests with propoer assertions * stacks on the zero shot work in 3952 * pr feedback: better policy checks and logging for backend failures * pr feedback: adding on_truncation * pr feedback: adding the truncation support for classifier and fixing documentation issues * CI fix and doc enhancement * pr feedback: fixed edge cases * added check for 0.3.7 truncated verification * pr feedback: router validation and argument handling * Added the example lfm2 ONNX model * pr feedback: added max-length and 3 flag truncate flags * pin bump to 0.4.0 and more tests for zero-shot * CI fix * pr feedback: model level filtering * PR Feedback: CR feedback * restricting decision models based on model family. 8k context limit by default for encoder decision models * checks at router level to reject wrongly labeled systemone models with 400 * pr feedback: default set to 4k, limits passed down by llama-server, truncated is added to systemone * truncated documentation * pr feedback: checks the token count instead of the template |
||
|
|
f9004ca0a8 |
Adding zero-shot classifier support (#3952)
* main into zero shot, post refactoring * cleanup * cleanup * CR feedback: fixed the residency document clarification bug * cr feedback: fake tests with propoer assertions * pr feedback: better policy checks and logging for backend failures * pr feedback: adding on_truncation * pr feedback: adding the truncation support for classifier and fixing documentation issues * CI fix and doc enhancement * pr feedback: fixed edge cases * added check for 0.3.7 truncated verification * Added the example lfm2 ONNX model * pr feedback: added max-length and 3 flag truncate flags * pin bump to 0.4.0 and more tests for zero-shot * CI fix * pr feedback: clarified on the PII detector |
||
|
|
e87a351219 |
feat(router): add min_total_chars / max_total_chars whole-conversation length conditions (#2958) (#3181)
* Adding a new server side leaf: min and max total chars * Undo GUI bug fixes: created a separate PR #3180 * CI bug fixes |
||
|
|
9a8b2c99b9 |
Reclaim routing helpers when a router collection's policy changes (#2795)
* Reclaim routing helpers when a router collection's policy changes * Close the race condition * Fix CI tests, load race and add one more test * Fix load retry, replace with normal model and concurrent notifications * Fix three issues * Fixes * Fix race condition * Both fixed * Fix * Code refactor * Potential fix * Second fix * fix: small CMake add_test_error --------- Co-authored-by: fl0rianr <[email protected]> |
||
|
|
1d56aafa3a |
[Router] llm router classifier + routing.router desugaring (#2405) (#2698)
* [Router] llm router classifier + routing.router desugaring (#2405)
* Address review: authored-name labels, exact-only matching, trace label, schema alignment (#2698)
* clean the patch
* Address 2nd review: classifier slot, constrained router invocation, structured choice (#2698)
* Fixing CMakeLists afet -> Address 2nd review: classifier slot, constrained router invocation, structured choice (#2698)
* drop classifier-slot changes (deferred to #2725); enforce structured-reply contract (#2698)
* [Router] Structured routing context for llm router + per-candidate trace rationale (#2698)
* [CI] Build and run RoutingPolicyLlmRouterTest in Linux/macOS C++ test steps (#2698)
* [CI] Restore Tiny-Test-Model-GGUF to SmolLM2; add Tiny-Gemma-Test-Model-GGUF (#2698)
* Revert "[CI] Restore Tiny-Test-Model-GGUF to SmolLM2; add Tiny-Gemma-Test-Model-GGUF (#2698)"
This reverts commit
|
||
|
|
41ef688dab |
Wire collection.router classifiers to Router::classify + validate model capability at parse time (#2727)
* Wire routing classifier services to Router::classify for ModelType::CLASSIFICATION
run_classifier previously always called chat_completion, so a
collection.router classifier condition could never actually reach an
onnxruntime-backed model (WrappedServer's default chat_completion() is
an unsupported-capability error for backends that don't implement it).
Add classify/get_model_type callbacks (both optional, defaulting to
the prior chat-completion-only behavior) and route to Router::classify
when the target model is tagged ModelType::CLASSIFICATION.
Verified live: a collection.router policy using an onnxruntime
classifier now produces real per-request scores and routes benign vs.
flagged input differently, instead of always falling through to
on_error regardless of input.
* Validate classifier/semantic_similarity model capability at policy-parse time
routing.classifiers[].model was only checked for existence (via
resolve_component + require_declared), never for capability. A
"classifier" entry pointing at, say, an embedding or image model would
register successfully and only fail at request time with a generic
router error. Add an optional get_model_type resolver to
RoutingPolicyParseOptions and validate: "classifier" needs LLM (chat-
completion-based) or CLASSIFICATION (/v1/classify); "semantic_similarity"
needs EMBEDDING. Wired at both production parse sites (build_cache's
routing-policy parse and validate_collection_request's registration-time
compile-check); left unset in existing parser unit tests, which keeps
their behavior unchanged.
Verified live: registering a policy whose classifier model is an
embedding model is now rejected immediately with a clear error instead
of silently succeeding.
* Fix ModelType fallback ambiguity for unresolvable/inline components
RoutingModelTypeResolver returned a bare ModelType, defaulting to LLM
whenever a component couldn't be resolved (e.g. an inline collection
component not registered yet). Since LLM is an accepted classifier
type, this was asymmetric and registration-order-dependent: a valid
inline semantic_similarity + inline embedding model was rejected
("type llm, needs embedding"), while an invalid inline classifier +
inline image/embedding model was silently accepted.
Change the resolver to return std::optional<ModelType>; the parser
now throws a clear "unresolvable type" error instead of guessing.
validate_collection_request derives the type from the matching inline
`models[]` definition's labels when the component isn't registered
yet (reusing the existing find_inline_def matching), only falling
back to nullopt when genuinely nothing is known. build_cache's
resolver simplifies to nullopt on a cache miss, since everything real
is already present by that point.
Addresses fl0rianr's review on #2727.
* Preserve throw-before-load ordering in run_classifier
ensure_model now ran unconditionally before checking whether
chat_completion_call was configured, so a caller relying on
"missing chat_completion call throws before any load side effect"
would observe a different order than before the classify-routing
change. Check whether the classify path will be used first (a pure
function of the model's type, no side effects), then validate
chat_completion_call is configured before calling ensure_model when
falling back to it.
Nit from ramkrishna2910's review on #2727.
* Add unit tests for classify routing and capability validation
- run_classifier: a ModelType::CLASSIFICATION model routes through
classify (not chat_completion); a non-CLASSIFICATION model falls
back to the chat-completion path as before.
- Parser capability check: classifier accepts LLM/CLASSIFICATION and
rejects EMBEDDING; semantic_similarity accepts EMBEDDING and rejects
LLM; an unresolvable (nullopt) type is a hard error, not a silent
pass.
- The exact regression pair from fl0rianr's review: an inline
semantic_similarity condition backed by an inline embedding
definition must pass, and an inline classifier condition backed by
that same embedding definition must fail.
Requested by ramkrishna2910's review on #2727.
* Fix collection.router validation rejecting label-less inline models
validate_collection_request's get_model_type lambda only derived a type
from an inline models[] definition when it had a "labels" array, and
returned nullopt otherwise - even when the definition existed. An inline
model with no labels (a plain chat/completion model, the common case)
was thus treated as unresolvable and rejected as an invalid classifier
target, even though get_model_type_from_labels() would correctly default
it to ModelType::LLM. Now nullopt is only returned when no inline
definition is found at all.
Caught by CI: test_model_manager_collection_validation exercises exactly
this via valid_router_collection()'s label-less "pii-detector" fixture.
* Load model before resolving type in run_classifier (cold start)
Router::get_model_type() reports ModelType::LLM until the backend is loaded and
alive, so resolving the type before ensure_model() made the first request after
startup/eviction/restart pick the chat path for a classify-only model —
recreating the unsupported-capability / on_error failure this routing exists to
avoid. Resolve the type after loading; move the chat_completion-configured guard
onto the chat branch.
Adds a regression test simulating the cold-start transition (get_model_type
returns LLM before ensure_loaded, CLASSIFICATION after) — it fails on the old
ordering and passes now.
Addresses the second blocker in fl0rianr's review.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Centralize inline model-type derivation for collection.router validation
validate_collection_request() derived an unregistered inline component's type
from its explicit `labels` only, while register_user_model() also applies legacy
capability flags (embedding/reranking/vision/reasoning) and the backend
descriptor's default_labels. So a label-less sd-cpp model validated as LLM
(accepted as a classifier) but registered as IMAGE, and a legacy `embedding:true`
model was rejected for semantic_similarity though it registers as an embedder —
both recreating the runtime capability mismatch this PR prevents.
Extract normalized_definition_labels() and use it in both places so validation
and registration cannot drift. Adds ModelManagerCollectionValidationTest cases
(against the real resolver, not a fake): label-less sd-cpp as classifier fails,
legacy embedding:true for semantic_similarity passes, label-less llamacpp still
defaults to LLM.
Addresses fl0rianr's third review.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Make routing model-type backend-capability-aware (chat-indicator bypass)
get_model_type_from_labels() gives chat-indicator labels (reasoning/vision/
tools/chat-transcription) priority, so a non-chat backend plus a stray
chat-indicator label typed as LLM at BOTH validation and runtime
(router.cpp sets the runtime type from model_info.type). An onnxruntime model
with reasoning:true, or an sd-cpp model with vision:true, was therefore accepted
as a classifier and — for onnxruntime — sent down run_classifier's chat path,
which OnnxRuntimeServer cannot serve (IClassificationServer only): the original
unsupported-capability / on_error fail-open, back again.
Add get_deployment_model_type(recipe, labels): the backend descriptor's default
labels declare a definitive non-LLM deployment (onnxruntime->classification,
sd-cpp->image, whispercpp->transcription, ...), which wins over chat-indicator
labels because those backends do not implement chat_completion. Use it at every
ModelInfo::type derivation site (fixing runtime) and in the inline validation
resolver (fixing parse-time). Only affects models with a contradictory
chat-indicator label on a non-chat backend, so real catalog models are unchanged.
Tests: onnxruntime+reasoning is CLASSIFICATION (accepted, routes to classify);
sd-cpp+vision is IMAGE (rejected as classifier).
Addresses fl0rianr's fourth review.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Declare kokoro's TTS default label so it can't be typed as a classifier
kokoro is the only non-chat backend with empty default_labels, so a label-less
kokoro model still typed LLM and slipped past classifier-capability validation
into run_classifier's chat path (which KokoroServer cannot serve). Give the
descriptor its true default label ("tts") so get_deployment_model_type() pins it
to TTS. Catalog kokoro models already carry "tts" explicitly, so they are
unaffected. Adds a label-less-kokoro-as-classifier rejection test.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Don't type a chat backend CLASSIFICATION from a spurious label
/v1/classify (IClassificationServer) is implemented only by the onnxruntime
backend. A `classification`/`classifier` label on a chat backend (llamacpp/flm/
ryzenai/vllm/cloud) previously typed the model CLASSIFICATION, so run_classifier
called Router::classify() and hit an unsupported-capability error — the inverse
of the chat-indicator bypass, and the same on_error fail-open.
get_deployment_model_type() now drops a classification claim once it has fallen
through to a backend with no definitive non-LLM deployment (onnxruntime already
returns CLASSIFICATION via its default label before this point), so such a model
stays LLM and is served via the chat-classifier path, never Router::classify.
Test: llamacpp + labels:["classification"] stays LLM and is accepted as a
classifier via the chat path.
Addresses fl0rianr's fifth review.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
---------
Co-authored-by: QuManu <[email protected]>
Co-authored-by: ramkrishna2910 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
|
||
|
|
1665d1be77 |
Router/2386 decision trace response (#2606)
* feat(router): expose route decisions in responses Carry the router Decision through collection.router dispatch and attach it additively as x_lemonade_route for non-streaming responses. Surface the matched rule in x-lemonade-route headers and inject the same decision metadata into routed SSE streams while keeping route_trace stripped before backend forwarding. * test(router): cover route decision response metadata Extend router endpoint coverage for matched-rule decisions, default-route decisions, route_trace output, opaque outputs pass-through, and streaming /responses x_lemonade_route injection. * fix(router): harden route decision streaming metadata Make routed SSE decision injection tolerant of LF, CRLF, CR, and chunk-split event separators by moving the response helpers into a focused route_decision_response module with direct tests. Collapse the three streaming response handlers through one shared content-provider helper and add live endpoint coverage for streaming chat, completions, and responses. Emit an explicit default route header for routed default decisions, and validate route rule ids as safe header tokens at policy parse/schema time. |
||
|
|
3cebf6bcd0 |
Router/2383 policy parser hot reload (#2519)
* feat(router): add policy parser and hot-reload store * feat(router): preserve collection routing metadata * test(router): cover policy loading in CI * fix(router): align pull validation with policy compilation * fix(router): reject duplicate policy model names * fix(router): harden policy store file handling |