fix(provider): default custom models to image input
This commit is contained in:
parent
34b3d59a23
commit
628e886808
8 changed files with 243 additions and 10 deletions
|
|
@ -63,16 +63,22 @@ export const Plugin = define({
|
|||
const providerPackage = providerApi?.type === "aisdk" ? providerApi.package : undefined
|
||||
|
||||
for (const [id, config] of Object.entries(item.models ?? {})) {
|
||||
const existing = catalog.model.get(providerID, id)
|
||||
catalog.model.update(providerID, id, (model) => {
|
||||
if (config.family !== undefined) model.family = config.family
|
||||
if (config.name !== undefined) model.name = config.name
|
||||
if (config.api !== undefined) model.api = { ...model.api, ...config.api }
|
||||
const packageName = model.api.type === "aisdk" ? model.api.package : providerPackage
|
||||
// TODO: Move these defaults to a dedicated configured-model constructor when one exists.
|
||||
if (existing === undefined) {
|
||||
model.capabilities.input = ["text", "image"]
|
||||
model.capabilities.output = ["text"]
|
||||
}
|
||||
if (config.capabilities !== undefined) {
|
||||
model.capabilities = {
|
||||
tools: config.capabilities.tools,
|
||||
input: [...config.capabilities.input],
|
||||
output: [...config.capabilities.output],
|
||||
tools: config.capabilities.tools ?? model.capabilities.tools,
|
||||
input: [...(config.capabilities.input ?? model.capabilities.input)],
|
||||
output: [...(config.capabilities.output ?? model.capabilities.output)],
|
||||
}
|
||||
}
|
||||
if (config.request !== undefined) {
|
||||
|
|
|
|||
|
|
@ -44,11 +44,17 @@ const ModelApi = Schema.Union([
|
|||
}),
|
||||
])
|
||||
|
||||
class Capabilities extends Schema.Class<Capabilities>("ConfigV2.Model.Capabilities")({
|
||||
tools: ModelV2.Capabilities.fields.tools.pipe(Schema.optional),
|
||||
input: ModelV2.Capabilities.fields.input.pipe(Schema.optional),
|
||||
output: ModelV2.Capabilities.fields.output.pipe(Schema.optional),
|
||||
}) {}
|
||||
|
||||
class Model extends Schema.Class<Model>("ConfigV2.Model")({
|
||||
family: ModelV2.Family.pipe(Schema.optional),
|
||||
name: Schema.String.pipe(Schema.optional),
|
||||
api: ModelApi.pipe(Schema.optional),
|
||||
capabilities: ModelV2.Capabilities.pipe(Schema.optional),
|
||||
capabilities: Capabilities.pipe(Schema.optional),
|
||||
request: Schema.Struct({
|
||||
...Request.fields,
|
||||
variant: Schema.String.pipe(Schema.optional),
|
||||
|
|
|
|||
|
|
@ -215,8 +215,23 @@ function migrateModel(info: typeof ConfigProviderV1.Model.Type, packageName?: st
|
|||
: []),
|
||||
]
|
||||
const capabilities =
|
||||
info.tool_call !== undefined || info.modalities?.input !== undefined || info.modalities?.output !== undefined
|
||||
? { tools: info.tool_call ?? false, input: info.modalities?.input ?? [], output: info.modalities?.output ?? [] }
|
||||
info.attachment !== undefined ||
|
||||
info.tool_call !== undefined ||
|
||||
info.modalities?.input !== undefined ||
|
||||
info.modalities?.output !== undefined
|
||||
? {
|
||||
...(info.tool_call === undefined ? {} : { tools: info.tool_call }),
|
||||
...(info.modalities?.input !== undefined
|
||||
? { input: info.modalities.input }
|
||||
: info.attachment !== undefined
|
||||
? { input: info.attachment ? ["text", "image"] : ["text"] }
|
||||
: {}),
|
||||
...(info.modalities?.output !== undefined
|
||||
? { output: info.modalities.output }
|
||||
: info.attachment !== undefined
|
||||
? { output: ["text"] }
|
||||
: {}),
|
||||
}
|
||||
: undefined
|
||||
return {
|
||||
family: info.family,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue