Skip to content

Commit 8ba55cc

Browse files
committed
fix: resolve TypeScript errors in cost optimization parameters
- Use type assertion for temperature and maxTokens properties - Fix compatibility with AI SDK parameter types - Backend typecheck now passes without errors
1 parent d9744e8 commit 8ba55cc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

backend/src/llm-apis/vercel-ai-sdk/ai-sdk.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ const generateCacheKey = (messages: Message[], model: string, options: any): str
118118
const cacheableContent = {
119119
messages: messages.slice(0, 2), // Only first 2 messages (system + first user)
120120
model,
121-
temperature: options.temperature,
122-
maxTokens: options.maxTokens
121+
temperature: (options as any).temperature,
122+
maxTokens: (options as any).maxTokens
123123
}
124124
return JSON.stringify(cacheableContent)
125125
}
@@ -195,8 +195,8 @@ export const promptAiSdkStream = async function* (
195195
// Only override if not explicitly set by caller
196196
const finalOptions = {
197197
...options,
198-
temperature: options.temperature ?? optimalParams.temperature,
199-
maxTokens: options.maxTokens ?? optimalParams.maxTokens,
198+
temperature: (options as any).temperature ?? optimalParams.temperature,
199+
maxTokens: (options as any).maxTokens ?? optimalParams.maxTokens,
200200
}
201201

202202
const response = streamText({
@@ -368,8 +368,8 @@ export const promptAiSdk = async function (
368368
// Only override if not explicitly set by caller
369369
const finalOptions = {
370370
...options,
371-
temperature: options.temperature ?? optimalParams.temperature,
372-
maxTokens: options.maxTokens ?? optimalParams.maxTokens,
371+
temperature: (options as any).temperature ?? optimalParams.temperature,
372+
maxTokens: (options as any).maxTokens ?? optimalParams.maxTokens,
373373
}
374374

375375
// Cost optimization: Check cache for similar requests
@@ -475,8 +475,8 @@ export const promptAiSdkStructured = async function <T>(options: {
475475
// Only override if not explicitly set by caller
476476
const finalOptions = {
477477
...options,
478-
temperature: options.temperature ?? optimalParams.temperature,
479-
maxTokens: options.maxTokens ?? optimalParams.maxTokens,
478+
temperature: (options as any).temperature ?? optimalParams.temperature,
479+
maxTokens: (options as any).maxTokens ?? optimalParams.maxTokens,
480480
}
481481

482482
const responsePromise = generateObject<z.ZodType<T>, 'object'>({

0 commit comments

Comments
 (0)