picking right model
This commit is contained in:
@@ -15,14 +15,23 @@ export function getAnthropicModel(apiKey: string, model: string) {
|
||||
|
||||
return anthropic(model);
|
||||
}
|
||||
export function getOpenAILikeModel(baseURL:string,apiKey: string, model: string) {
|
||||
|
||||
export function getOpenAILikeModel(baseURL: string, apiKey: string, model: string) {
|
||||
// console.log('OpenAILike config:', { baseURL, hasApiKey: !!apiKey, model });
|
||||
const openai = createOpenAI({
|
||||
baseURL,
|
||||
apiKey,
|
||||
});
|
||||
|
||||
return openai(model);
|
||||
// console.log('OpenAI client created:', !!openai);
|
||||
const client = openai(model);
|
||||
// console.log('OpenAI model client:', !!client);
|
||||
return client;
|
||||
// return {
|
||||
// model: client,
|
||||
// provider: 'OpenAILike' // Correctly identifying the actual provider
|
||||
// };
|
||||
}
|
||||
|
||||
export function getOpenAIModel(apiKey: string, model: string) {
|
||||
const openai = createOpenAI({
|
||||
apiKey,
|
||||
@@ -74,7 +83,7 @@ export function getOllamaModel(baseURL: string, model: string) {
|
||||
return Ollama;
|
||||
}
|
||||
|
||||
export function getDeepseekModel(apiKey: string, model: string){
|
||||
export function getDeepseekModel(apiKey: string, model: string) {
|
||||
const openai = createOpenAI({
|
||||
baseURL: 'https://api.deepseek.com/beta',
|
||||
apiKey,
|
||||
@@ -108,9 +117,15 @@ export function getXAIModel(apiKey: string, model: string) {
|
||||
|
||||
return openai(model);
|
||||
}
|
||||
|
||||
export function getModel(provider: string, model: string, env: Env, apiKeys?: Record<string, string>) {
|
||||
const apiKey = getAPIKey(env, provider, apiKeys);
|
||||
const baseURL = getBaseURL(env, provider);
|
||||
let apiKey; // Declare first
|
||||
let baseURL;
|
||||
|
||||
apiKey = getAPIKey(env, provider, apiKeys); // Then assign
|
||||
baseURL = getBaseURL(env, provider);
|
||||
|
||||
// console.log('getModel inputs:', { provider, model, baseURL, hasApiKey: !!apiKey });
|
||||
|
||||
switch (provider) {
|
||||
case 'Anthropic':
|
||||
@@ -126,11 +141,11 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
|
||||
case 'Google':
|
||||
return getGoogleModel(apiKey, model);
|
||||
case 'OpenAILike':
|
||||
return getOpenAILikeModel(baseURL,apiKey, model);
|
||||
return getOpenAILikeModel(baseURL, apiKey, model);
|
||||
case 'Deepseek':
|
||||
return getDeepseekModel(apiKey, model);
|
||||
case 'Mistral':
|
||||
return getMistralModel(apiKey, model);
|
||||
return getMistralModel(apiKey, model);
|
||||
case 'LMStudio':
|
||||
return getLMStudioModel(baseURL, model);
|
||||
case 'xAI':
|
||||
@@ -138,4 +153,4 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
|
||||
default:
|
||||
return getOllamaModel(baseURL, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user