Skip to content

Commit 09a1b5c

Browse files
author
Theodore Li
committed
Remove any type
1 parent ee2e123 commit 09a1b5c

File tree

11 files changed

+16
-15
lines changed

11 files changed

+16
-15
lines changed

apps/sim/providers/anthropic/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ export async function executeAnthropicProviderRequest(
491491
}
492492

493493
const toolCalls = []
494-
const toolResults: any[] = []
494+
const toolResults: Record<string, unknown>[] = []
495495
const currentMessages = [...messages]
496496
let iterationCount = 0
497497
let hasUsedForcedTool = false
@@ -610,7 +610,7 @@ export async function executeAnthropicProviderRequest(
610610
})
611611

612612
let resultContent: unknown
613-
if (result.success) {
613+
if (result.success && result.output) {
614614
toolResults.push(result.output)
615615
resultContent = result.output
616616
} else {
@@ -905,7 +905,7 @@ export async function executeAnthropicProviderRequest(
905905
}
906906

907907
const toolCalls = []
908-
const toolResults: any[] = []
908+
const toolResults: Record<string, unknown>[] = []
909909
const currentMessages = [...messages]
910910
let iterationCount = 0
911911
let hasUsedForcedTool = false
@@ -1026,7 +1026,7 @@ export async function executeAnthropicProviderRequest(
10261026
})
10271027

10281028
let resultContent: unknown
1029-
if (result.success) {
1029+
if (result.success && result.output) {
10301030
toolResults.push(result.output)
10311031
resultContent = result.output
10321032
} else {

apps/sim/providers/cerebras/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const cerebrasProvider: ProviderConfig = {
196196
total: currentResponse.usage?.total_tokens || 0,
197197
}
198198
const toolCalls = []
199-
const toolResults: any[] = []
199+
const toolResults: Record<string, unknown>[] = []
200200
const currentMessages = [...allMessages]
201201
let iterationCount = 0
202202

apps/sim/providers/deepseek/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const deepseekProvider: ProviderConfig = {
206206
total: currentResponse.usage?.total_tokens || 0,
207207
}
208208
const toolCalls = []
209-
const toolResults: any[] = []
209+
const toolResults: Record<string, unknown>[] = []
210210
const currentMessages = [...allMessages]
211211
let iterationCount = 0
212212
let hasUsedForcedTool = false

apps/sim/providers/groq/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const groqProvider: ProviderConfig = {
202202
total: currentResponse.usage?.total_tokens || 0,
203203
}
204204
const toolCalls = []
205-
const toolResults: any[] = []
205+
const toolResults: Record<string, unknown>[] = []
206206
const currentMessages = [...allMessages]
207207
let iterationCount = 0
208208
let modelTime = firstResponseTime

apps/sim/providers/mistral/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export const mistralProvider: ProviderConfig = {
259259
total: currentResponse.usage?.total_tokens || 0,
260260
}
261261
const toolCalls = []
262-
const toolResults: any[] = []
262+
const toolResults: Record<string, unknown>[] = []
263263
const currentMessages = [...allMessages]
264264
let iterationCount = 0
265265

apps/sim/providers/ollama/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export const ollamaProvider: ProviderConfig = {
271271
total: currentResponse.usage?.total_tokens || 0,
272272
}
273273
const toolCalls = []
274-
const toolResults: any[] = []
274+
const toolResults: Record<string, unknown>[] = []
275275
const currentMessages = [...allMessages]
276276
let iterationCount = 0
277277

apps/sim/providers/openai/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export async function executeResponsesProviderRequest(
406406
}
407407

408408
const toolCalls = []
409-
const toolResults: any[] = []
409+
const toolResults: Record<string, unknown>[] = []
410410
let iterationCount = 0
411411
let modelTime = firstResponseTime
412412
let toolsTime = 0

apps/sim/providers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export interface ProviderResponse {
7979
total?: number
8080
}
8181
toolCalls?: FunctionCallResponse[]
82-
toolResults?: any[]
82+
toolResults?: Record<string, unknown>[]
8383
timing?: {
8484
startTime: string
8585
endTime: string

apps/sim/providers/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,12 @@ export function calculateCost(
654654
* Sums the `cost.total` from each tool result returned during a provider tool loop.
655655
* Tool results may carry a `cost` object injected by `applyHostedKeyCostToResult`.
656656
*/
657-
export function sumToolCosts(toolResults?: any[]): number {
657+
export function sumToolCosts(toolResults?: Record<string, unknown>[]): number {
658658
if (!toolResults?.length) return 0
659659
let total = 0
660660
for (const tr of toolResults) {
661-
if (tr?.cost?.total) total += tr.cost.total
661+
const cost = tr?.cost as Record<string, unknown> | undefined
662+
if (cost?.total && typeof cost.total === 'number') total += cost.total
662663
}
663664
return total
664665
}

apps/sim/providers/vllm/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export const vllmProvider: ProviderConfig = {
316316
total: currentResponse.usage?.total_tokens || 0,
317317
}
318318
const toolCalls = []
319-
const toolResults: any[] = []
319+
const toolResults: Record<string, unknown>[] = []
320320
const currentMessages = [...allMessages]
321321
let iterationCount = 0
322322

0 commit comments

Comments
 (0)