ai-cut/app/composables/useAIProvider.ts

25 lines
718 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* AI Provider Selector Composable
* 根據模型名稱自動選擇對應的 provider
*/
import type { AIProvider } from '~/types/ai'
import { GeminiClient } from '~/utils/clients/gemini'
import { GrokClient } from '~/utils/clients/grok'
import { getProviderForModel } from '~/utils/clients/all-models'
/**
* 取得指定模型對應的 AI Provider 實例
* @param modelName - 模型名稱如果不提供則使用預設Gemini
*/
export function useAIProvider(modelName?: string): AIProvider {
if (modelName) {
const provider = getProviderForModel(modelName)
return provider === 'grok' ? new GrokClient() : new GeminiClient()
}
// 預設使用 Gemini
return new GeminiClient()
}