Config Driven Classification Adapters - #16208
Closed
aligulzar729 wants to merge 2 commits into
Closed
aligulzar729 wants to merge 2 commits into
aligulzar729 wants to merge 2 commits into
Conversation
8 tasks
Author
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.
Summary
Depends on #16180.
I run a self-hosted instance with local models. While wiring a second classification host I noticed the three I care about differ only in data, not behaviour: same question shapes, same answer fields, same
usageblock. Only the URL, the model name and the body wrapping change./v1/systemonejev-latest/accounts/{id}/ai/runtypesafe/jev{input: {...}}{result: {...}}/api/alpha/decisions~typesafe/jev-latestAn adapter file per host would mean a merged PR and a release before an operator can point at a gateway that already works. So this makes those differences configuration instead.
Three optional fields on a provider:
dialectpicks the wire vocabulary,requestKeynestsstateandquestionsunder a key,responseKeyunwraps an envelope. A host nobody has heard of then needs no code at all:Known hosts ship as presets, so naming one is usually enough, and any field can be overridden:
How it works
dialectexists because the only vocabulary difference between the two families is the word for a yes/no question. Everything else on the wire is already identical, so one mapping file covers both.ClassificationRequestalso gains an optionaltimeoutMs, because one ceiling does not fit every question. On my instance a ranking request over a 202-tool catalog is about 9,600 input tokens and takes roughly 4s, while a yes/no gate answers in under a second.Cloudflare has no default URL, since the account id is part of it. It stays off with a warning rather than guessing one.
Type of change
Testing
dialect.spec.ts(10),presets.spec.ts(10) andconfig.spec.ts(8), 59 across the classification module.The ones worth reading: a provider the code has never heard of, built from config alone and asserted on the wire; the Cloudflare envelope handled both wrapped and bare, because their model page shows a bare body and their platform docs show
{result}; an override beating the preset it sits on; and a misspelled key rejected rather than silently dropped.cd packages/api && npx jest src/classificationpasses 59.npx tsc --noEmitclean for all workspaces.Risk / compatibility
No behaviour change when classification is off, which is the default. An existing
httpprovider config keeps working:dialectdefaults to the port vocabulary and both wrapping fields default to none.classificationProviderSchemais now.strict(), matching the twelve other strict schemas in this file. A misspelled key that used to be dropped silently now fails at config load, which is the point, but it is worth calling out.Checklist