Prep for more model providers
Adds a `modelProvider` field to `promptVariants`, currently just set to "openai/ChatCompletion" for all variants for now. Adds a `modelProviders/` directory where we can define and store pluggable model providers. Currently just OpenAI. Not everything is pluggable yet -- notably the code to actually generate completions hasn't been migrated to this setup yet. Does a lot of work to get the types working. Prompts are now defined with a function `definePrompt(modelProvider, config)` instead of `prompt = config`. Added a script to migrate old prompt definitions. This is still partial work, but the diff is large enough that I want to get it in. I don't think anything is broken but I haven't tested thoroughly.
This commit is contained in:
14
src/modelProviders/types.ts
Normal file
14
src/modelProviders/types.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { type JSONSchema4 } from "json-schema";
|
||||
|
||||
export type ModelProviderModel = {
|
||||
name: string;
|
||||
learnMore: string;
|
||||
};
|
||||
|
||||
export type ModelProvider<SupportedModels extends string, InputSchema> = {
|
||||
name: string;
|
||||
models: Record<SupportedModels, ModelProviderModel>;
|
||||
getModel: (input: InputSchema) => SupportedModels | null;
|
||||
shouldStream: (input: InputSchema) => boolean;
|
||||
inputSchema: JSONSchema4;
|
||||
};
|
||||
Reference in New Issue
Block a user