File size: 1,882 Bytes
68d7816 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import { z } from 'zod';
import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation';
import type { ModelCapability } from '../contract/capability';
import type { Model } from '../model/catalog';
import type { ResolvedLlmModel } from '../model/model-requester-impl';
import type { ProtocolBaseId, ResolvedAdapterIdentity } from './protocol-base';
export const ProtocolSchema = z.enum(['anthropic', 'openai', 'openai_responses', 'google-genai']);
export type Protocol = z.infer<typeof ProtocolSchema>;
export interface ProtocolProviderOptions {
readonly reasoningKey?: string;
readonly defaultMaxTokens?: number;
readonly supportEfforts?: readonly string[];
readonly offEffort?: string;
readonly adaptiveThinking?: boolean;
readonly betaApi?: boolean;
readonly metadata?: Readonly<Record<string, string>>;
readonly vertexai?: boolean;
readonly project?: string;
readonly location?: string;
}
export interface ProtocolAdapterConfig {
readonly protocol: Protocol;
readonly providerType?: string;
readonly baseUrl?: string;
readonly modelName: string;
readonly apiKey?: string;
readonly defaultHeaders?: Readonly<Record<string, string>>;
readonly providerOptions?: ProtocolProviderOptions;
}
export interface IProtocolAdapterRegistry {
readonly _serviceBrand: undefined;
supportedProtocols(): readonly Protocol[];
resolveAdapterIdentity(protocol: Protocol, providerType?: string): ResolvedAdapterIdentity;
resolveProviderBaseId(protocol: Protocol, providerType?: string): ProtocolBaseId;
resolveCapability(
protocol: Protocol,
modelName: string,
providerType?: string,
): ModelCapability;
resolve(model: Model): ResolvedLlmModel;
}
export const IProtocolAdapterRegistry: ServiceIdentifier<IProtocolAdapterRegistry> =
createDecorator<IProtocolAdapterRegistry>('protocolAdapterRegistry');
|