yaml model capabilities
This commit is contained in:
parent
47a47dac42
commit
19c8da156f
2 changed files with 28 additions and 1 deletions
|
|
@ -35,8 +35,10 @@ async function modelConfigToBaseLLM(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const { capabilities, ...rest } = model;
|
||||
|
||||
let options: LLMOptions = {
|
||||
...model,
|
||||
...rest,
|
||||
completionOptions: {
|
||||
...(model.defaultCompletionOptions ?? {}),
|
||||
model: model.model,
|
||||
|
|
@ -51,6 +53,22 @@ async function modelConfigToBaseLLM(
|
|||
promptTemplates: model.promptTemplates,
|
||||
};
|
||||
|
||||
// Model capabilities - need to be undefined if not found
|
||||
// To fallback to our autodetection
|
||||
if (capabilities?.find((c) => c === "tool_use")) {
|
||||
options.capabilities = {
|
||||
...options.capabilities,
|
||||
tools: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (capabilities?.find((c) => c === "image_input")) {
|
||||
options.capabilities = {
|
||||
...options.capabilities,
|
||||
uploadImage: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (model.embedOptions?.maxBatchSize) {
|
||||
options.maxEmbeddingBatchSize = model.embedOptions.maxBatchSize;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ export const modelRolesSchema = z.enum([
|
|||
]);
|
||||
export type ModelRole = z.infer<typeof modelRolesSchema>;
|
||||
|
||||
// TODO consider just using array of strings for model capabilities
|
||||
// To allow more dynamic string parsing
|
||||
export const modelCapabilitySchema = z.union([
|
||||
z.literal("tool_use"),
|
||||
z.literal("image_input"),
|
||||
]);
|
||||
export type ModelCapability = z.infer<typeof modelCapabilitySchema>;
|
||||
|
||||
export const completionOptionsSchema = z.object({
|
||||
contextLength: z.number().optional(),
|
||||
maxTokens: z.number().optional(),
|
||||
|
|
@ -61,6 +69,7 @@ const baseModelFields = {
|
|||
apiKey: z.string().optional(),
|
||||
apiBase: z.string().optional(),
|
||||
roles: modelRolesSchema.array().optional(),
|
||||
capabilities: modelCapabilitySchema.array().optional(),
|
||||
defaultCompletionOptions: completionOptionsSchema.optional(),
|
||||
requestOptions: requestOptionsSchema.optional(),
|
||||
embedOptions: embedOptionsSchema.optional(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue