mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 00:38:35 +00:00
* feat(core): add Z.ai AI provider Z.ai can be added as an instance or workspace AI provider with an API key. It uses pydantic-ai's ZaiModel with a profile limited to the request fields Z.ai documents: automatic tool choice, max_tokens, no strict tool definitions and no file parts. AI fields send JPG/PNG images and small text files; the temperature is capped at 1. Part of #5753. * fix(core): limit Z.ai thinking on short capped requests Z.ai reasons at maximum effort by default, so a 250-token Kuma title or a 256-token model test could spend its whole budget reasoning and return nothing. Requests capped at 1024 tokens or less now disable thinking, or ask always-thinking models such as glm-5.3 for low effort, unless the caller chose a level.
85 lines
2.3 KiB
JavaScript
85 lines
2.3 KiB
JavaScript
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import { GenerativeAIModelType } from '@baserow/modules/core/generativeAIModelTypes'
|
|
import { getEffectiveAIAgentModels } from '@baserow/modules/integrations/ai/utils'
|
|
|
|
describe('AI Agent integration model resolution', () => {
|
|
let testApp
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await testApp.afterEach()
|
|
})
|
|
|
|
test.each([
|
|
'openai',
|
|
'anthropic',
|
|
'bedrock',
|
|
'google',
|
|
'groq',
|
|
'xai',
|
|
'zai',
|
|
'mistral',
|
|
'ollama',
|
|
'openrouter',
|
|
])(
|
|
'%s inherits omitted models while preserving explicit lists',
|
|
(providerType) => {
|
|
const modelType = testApp
|
|
.getRegistry()
|
|
.get('generativeAIModel', providerType)
|
|
const connections = {
|
|
ollama: { host: 'http://localhost:11434' },
|
|
bedrock: { api_key: 'integration-key', region: 'eu-central-1' },
|
|
}
|
|
const connection = connections[providerType] || {
|
|
api_key: 'integration-key',
|
|
}
|
|
const resolve = (integrationSettings) =>
|
|
getEffectiveAIAgentModels({
|
|
workspaceModels: ['shared-model'],
|
|
integrationSettings,
|
|
modelType,
|
|
})
|
|
|
|
expect(resolve(connection)).toEqual(['shared-model'])
|
|
expect(resolve({ ...connection, models: [] })).toEqual([])
|
|
expect(resolve({ ...connection, models: ['own-model'] })).toEqual([
|
|
'own-model',
|
|
])
|
|
expect(resolve({ models: ['own-model', 'shared-model'] })).toEqual([
|
|
'shared-model',
|
|
])
|
|
}
|
|
)
|
|
|
|
test('does not add inherited models to an authoritative extension override', () => {
|
|
class ExtensionModelType extends GenerativeAIModelType {
|
|
static getType() {
|
|
return 'extension'
|
|
}
|
|
}
|
|
const modelType = new ExtensionModelType({ app: testApp.getApp() })
|
|
|
|
expect(
|
|
getEffectiveAIAgentModels({
|
|
workspaceModels: ['shared-model'],
|
|
integrationSettings: {},
|
|
modelType,
|
|
})
|
|
).toEqual([])
|
|
})
|
|
|
|
test('excludes a removed provider even when workspace models are stale', () => {
|
|
expect(
|
|
getEffectiveAIAgentModels({
|
|
workspaceModels: ['removed-model'],
|
|
integrationSettings: { models: ['removed-model'] },
|
|
modelType: null,
|
|
})
|
|
).toEqual([])
|
|
})
|
|
})
|