File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
backend/src/llm-apis/vercel-ai-sdk Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 toolNameParam ,
1212} from '@codebuff/common/tools/constants'
1313import { buildArray } from '@codebuff/common/util/array'
14+ import { convertCbToModelMessages } from '@codebuff/common/util/messages'
1415import { errorToObject } from '@codebuff/common/util/object'
1516import { withTimeout } from '@codebuff/common/util/promise'
1617import { generateCompactId } from '@codebuff/common/util/string'
@@ -100,6 +101,7 @@ export const promptAiSdkStream = async function* (
100101 ...options ,
101102 model : aiSDKModel ,
102103 maxRetries : options . maxRetries ,
104+ messages : convertCbToModelMessages ( options ) ,
103105 } )
104106
105107 let content = ''
@@ -246,6 +248,7 @@ export const promptAiSdk = async function (
246248 const response = await generateText ( {
247249 ...options ,
248250 model : aiSDKModel ,
251+ messages : convertCbToModelMessages ( options ) ,
249252 } )
250253
251254 const content = response . text
@@ -309,6 +312,7 @@ export const promptAiSdkStructured = async function <T>(options: {
309312 ...options ,
310313 model : aiSDKModel ,
311314 output : 'object' ,
315+ messages : convertCbToModelMessages ( options ) ,
312316 } )
313317
314318 const response = await ( options . timeout === undefined
Original file line number Diff line number Diff line change @@ -66,3 +66,11 @@ export function withCacheControl(msg: CodebuffMessage): CodebuffMessage {
6666 message . providerOptions . openrouter . cacheControl = { type : 'ephemeral' }
6767 return message
6868}
69+
70+ export function convertCbToModelMessages ( {
71+ messages,
72+ } : {
73+ messages : CodebuffMessage [ ]
74+ } ) : ModelMessage [ ] {
75+ return messages
76+ }
You can’t perform that action at this time.
0 commit comments