fix(ai): apply vision reasoning settings
This commit is contained in:
parent
8294e32f33
commit
96b030699c
|
|
@ -4,6 +4,7 @@ import * as v from 'valibot'
|
|||
|
||||
import { computeContentBounds } from '@open-pencil/core/io'
|
||||
|
||||
import { buildReasoningProviderOptions } from '@/app/ai/chat/transports'
|
||||
import { createAIModelRuntime } from '@/app/ai/models'
|
||||
import type { EditorStore } from '@/app/editor/active-store'
|
||||
|
||||
|
|
@ -70,6 +71,10 @@ export async function inspectRenderedDesign(
|
|||
const result = await dependencies.inspect({
|
||||
model: runtime.model,
|
||||
maxOutputTokens: Math.min(runtime.role.profile.maxOutputTokens, MAX_VISION_OUTPUT_TOKENS),
|
||||
providerOptions: buildReasoningProviderOptions(
|
||||
runtime.role.connection.providerID,
|
||||
runtime.role.profile.reasoningEffort ?? ''
|
||||
),
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ describe('isolated visual inspection', () => {
|
|||
model: {} as LanguageModel,
|
||||
role: {
|
||||
requestedRole: 'vision',
|
||||
profile: { maxOutputTokens: 8000 },
|
||||
connection: {}
|
||||
profile: { maxOutputTokens: 8000, reasoningEffort: 'low' },
|
||||
connection: { providerID: 'openrouter' }
|
||||
}
|
||||
}) as never,
|
||||
inspect: async (options) => {
|
||||
|
|
@ -53,9 +53,11 @@ describe('isolated visual inspection', () => {
|
|||
})
|
||||
const request = inspections[0] as {
|
||||
maxOutputTokens: number
|
||||
providerOptions?: unknown
|
||||
messages: Array<{ content: Array<{ type: string; data?: Uint8Array }> }>
|
||||
}
|
||||
expect(request.maxOutputTokens).toBe(1200)
|
||||
expect(request.providerOptions).toEqual({ openrouter: { reasoning: { effort: 'low' } } })
|
||||
expect(request.messages[0]?.content[1]?.type).toBe('file')
|
||||
expect(request.messages[0]?.content[1]?.data).toEqual(new Uint8Array([1, 2, 3]))
|
||||
expect(result).not.toHaveProperty('base64')
|
||||
|
|
|
|||
Loading…
Reference in a new issue