@@ -361,6 +361,57 @@ describe('complete', () => {
361361 expect ( result . content ) . toBe ( 'ok' ) ;
362362 } ) ;
363363
364+ it ( 'keeps image inputs for synthesized openai-chat models' , async ( ) => {
365+ getModelMock . mockReturnValue ( undefined ) ;
366+ completeSimpleMock . mockImplementationOnce ( async ( model , context ) => {
367+ expect ( model ) . toMatchObject ( {
368+ api : 'openai-completions' ,
369+ input : [ 'text' , 'image' ] ,
370+ baseUrl : 'https://gateway.example.test/v1' ,
371+ } ) ;
372+ expect ( context . messages ) . toEqual ( [
373+ {
374+ role : 'user' ,
375+ content : [
376+ { type : 'text' , text : 'use this screenshot' } ,
377+ { type : 'image' , data : 'AAAA' , mimeType : 'image/png' } ,
378+ ] ,
379+ timestamp : 1 ,
380+ } ,
381+ ] ) ;
382+ return {
383+ role : 'assistant' ,
384+ content : [ { type : 'text' , text : 'ok' } ] ,
385+ api : 'openai-completions' ,
386+ provider : 'custom-openai' ,
387+ model : 'local-text-or-vision-model' ,
388+ usage : {
389+ input : 1 ,
390+ output : 1 ,
391+ cacheRead : 0 ,
392+ cacheWrite : 0 ,
393+ totalTokens : 2 ,
394+ cost : { input : 0 , output : 0 , cacheRead : 0 , cacheWrite : 0 , total : 0 } ,
395+ } ,
396+ stopReason : 'stop' ,
397+ timestamp : Date . now ( ) ,
398+ } ;
399+ } ) ;
400+
401+ const result = await complete (
402+ { provider : 'custom-openai' , modelId : 'local-text-or-vision-model' } ,
403+ [ { role : 'user' , content : 'use this screenshot' } ] ,
404+ {
405+ apiKey : 'sk-test' ,
406+ wire : 'openai-chat' ,
407+ baseUrl : 'https://gateway.example.test/v1' ,
408+ userImages : [ { data : 'AAAA' , mimeType : 'image/png' } ] ,
409+ } ,
410+ ) ;
411+
412+ expect ( result . content ) . toBe ( 'ok' ) ;
413+ } ) ;
414+
364415 it ( 'synthesizes openai-chat PiModel with reasoning=false for Qwen DashScope (#183)' , async ( ) => {
365416 getModelMock . mockReturnValue ( undefined ) ;
366417 completeSimpleMock . mockImplementationOnce ( async ( model ) => {
0 commit comments