Skip to content

Commit 469b769

Browse files
committed
test(xai): type the provider test helper instead of casting to any
1 parent 2cf0072 commit 469b769

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

apps/sim/providers/xai/index.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ vi.mock('@/providers/utils', () => ({
8484
})),
8585
}))
8686

87+
import type { StreamingExecution } from '@/executor/types'
88+
import type { ProviderRequest, ProviderResponse, ProviderToolConfig } from '@/providers/types'
8789
import { xAIProvider } from '@/providers/xai'
8890

8991
interface ChatOptions {
@@ -103,17 +105,25 @@ function chat({ content = null, toolCalls }: ChatOptions = {}) {
103105
}
104106
}
105107

106-
function tool(name: string) {
107-
return { id: name, name, description: 'd', parameters: {} }
108+
function tool(name: string): ProviderToolConfig {
109+
return {
110+
id: name,
111+
name,
112+
description: 'd',
113+
params: {},
114+
parameters: { type: 'object', properties: {}, required: [] },
115+
}
108116
}
109117

110-
function run(request: Record<string, unknown>) {
118+
function run(
119+
request: Partial<ProviderRequest> = {}
120+
): Promise<ProviderResponse | StreamingExecution> {
111121
return xAIProvider.executeRequest!({
112122
model: 'grok-4.6',
113123
apiKey: 'test-key',
114124
messages: [{ role: 'user', content: 'Hi' }],
115125
...request,
116-
} as never) as Promise<any>
126+
})
117127
}
118128

119129
const firstPayload = () => mockCreate.mock.calls[0][0]

0 commit comments

Comments
 (0)