Merge pull request #4457 from continuedev/dallin/yaml-capabilities

YAML model capabilities
This commit is contained in:
Nate Sesti 2025-03-12 11:16:24 -07:00 • committed by GitHub
commit 4fd7ad3476
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 47 additions and 7 deletions

View file

@ -35,8 +35,10 @@ async function modelConfigToBaseLLM(
return undefined;
}
const { capabilities, ...rest } = model;
let options: LLMOptions = {
...model,
...rest,
completionOptions: {
...(model.defaultCompletionOptions ?? {}),
model: model.model,
@ -55,6 +57,22 @@ async function modelConfigToBaseLLM(
},
};
// 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;
}

View file

@ -36,6 +36,7 @@ Each model has specific configuration options tailored to its provider and funct
- `engine`: Engine for Azure OpenAI requests.
- `capabilities`: Override auto-detected capabilities:
- `uploadImage`: Boolean indicating if the model supports image uploads.
- `tools`: Boolean indicating if the model supports tool calls.
_(AWS Only)_

View file

@ -134,6 +134,7 @@ The `models` section defines the language models used in your configuration. Mod
- `provider` (**required**): The provider of the model (e.g., `openai`, `ollama`).
- `model` (**required**): The specific model name (e.g., `gpt-4`, `starcoder`).
- `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used.
- `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. Supported capabilities include `tool_use` and `image_input`.
- `embedOptions`: If the model includes role `embed`, these settings apply for embeddings:
- `maxChunkSize`: Maximum tokens per document chunk. Minimum is 128 tokens.
@ -187,6 +188,17 @@ models:
model: codestral-latest
roles:
- autocomplete
- name: My Model - OpenAI-Compatible
provider: openai
apiBase: http://my-endpoint/v1
model: my-custom-model
capabilities:
- tool_use
- image_input
roles:
- chat
- edit
```
---

8
gui/package-lock.json generated
View file

@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-yaml": "^1.0.52",
"@continuedev/config-yaml": "^1.0.56",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
@ -555,9 +555,9 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.52",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.52.tgz",
"integrity": "sha512-x0m4bcQpjHrrv95cq5tsen4Hb6yKCVGn+NeojyzNQYnRD0If/On+ATgX78uXtQtZxsdO4ip73HHCyQlA0O3ZyQ==",
"version": "1.0.56",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.56.tgz",
"integrity": "sha512-2OBhmlSFOgZ+Z/ZQ18R/JR9zo6HIzkQ09PCuHQQ9NanN+g5AEVCdWgEtMyOq5DmQM3HLJCoLMXwqzQ9qSJEfFg==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",

View file

@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@continuedev/config-yaml": "^1.0.52",
"@continuedev/config-yaml": "^1.0.56",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/config-yaml",
"version": "1.0.52",
"version": "1.0.56",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -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(),