Refactor LLM route-first provider API (#28523)
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
import type { RouteModelInput } from "./route/client"
|
||||
import type { ModelID, ModelRef, ProviderID } from "./schema"
|
||||
import type { RouteDefaultsInput } from "./route/client"
|
||||
import type { Model, ModelID, ProviderID } from "./schema"
|
||||
|
||||
export type ModelOptions = Omit<RouteModelInput, "id">
|
||||
export type ModelOptions = RouteDefaultsInput
|
||||
|
||||
/**
|
||||
* Advanced structural provider definition helper. Built-in providers should
|
||||
* prefer explicit `configure(options).model(id)` facades so deployment config is
|
||||
* chosen before model selection. The optional `apis` map remains for external
|
||||
* structural providers that expose multiple route selectors behind one provider.
|
||||
*/
|
||||
export type ModelFactory<Options extends ModelOptions = ModelOptions> = (
|
||||
id: string | ModelID,
|
||||
options?: Options,
|
||||
) => ModelRef
|
||||
) => Model
|
||||
|
||||
type AnyModelFactory = (...args: never[]) => ModelRef
|
||||
type AnyModelFactory = (...args: never[]) => Model
|
||||
|
||||
export interface Definition<Factory extends AnyModelFactory = ModelFactory> {
|
||||
readonly id: ProviderID
|
||||
@@ -18,8 +24,8 @@ export interface Definition<Factory extends AnyModelFactory = ModelFactory> {
|
||||
|
||||
type DefinitionShape = {
|
||||
readonly id: ProviderID
|
||||
readonly model: (...args: never[]) => ModelRef
|
||||
readonly apis?: Record<string, (...args: never[]) => ModelRef>
|
||||
readonly model: (...args: never[]) => Model
|
||||
readonly apis?: Record<string, (...args: never[]) => Model>
|
||||
}
|
||||
|
||||
type NoExtraFields<Input, Shape> = Input & Record<Exclude<keyof Input, keyof Shape>, never>
|
||||
|
||||
Reference in New Issue
Block a user