Files
sim/providers/types.ts
2025-03-03 14:00:32 -08:00

100 lines
1.8 KiB
TypeScript

export type ProviderId =
| 'openai'
| 'anthropic'
| 'google'
| 'deepseek'
| 'xai'
| 'cerebras'
| 'groq'
export interface TokenInfo {
prompt?: number
completion?: number
total?: number
}
export interface TransformedResponse {
content: string
tokens?: TokenInfo
}
export interface ProviderConfig {
id: string
name: string
description: string
version: string
models: string[]
defaultModel: string
executeRequest?: (request: ProviderRequest) => Promise<ProviderResponse>
}
export interface FunctionCallResponse {
name: string
arguments: Record<string, any>
}
export interface ProviderResponse {
content: string
model: string
tokens?: {
prompt?: number
completion?: number
total?: number
}
toolCalls?: FunctionCallResponse[]
toolResults?: any[]
}
export interface ProviderToolConfig {
id: string
name: string
description: string
params: Record<string, any>
parameters: {
type: string
properties: Record<string, any>
required: string[]
}
}
export interface Message {
role: 'system' | 'user' | 'assistant' | 'function' | 'tool'
content: string | null
name?: string
function_call?: {
name: string
arguments: string
}
tool_calls?: Array<{
id: string
type: 'function'
function: {
name: string
arguments: string
}
}>
tool_call_id?: string
}
export interface ProviderRequest {
model: string
systemPrompt: string
context?: string
tools?: ProviderToolConfig[]
temperature?: number
maxTokens?: number
apiKey: string
messages?: Message[]
responseFormat?: {
fields: Array<{
name: string
type: 'string' | 'number' | 'boolean' | 'array' | 'object'
description?: string
}>
}
local_execution?: boolean
}
// Map of provider IDs to their configurations
export const providers: Record<string, ProviderConfig> = {}