mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔄 refactor: Select OpenRouter LLM Class Dynamically by baseURL (#8898)
This commit is contained in:
parent
4175a3ea19
commit
36c8947029
2 changed files with 8 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { ProxyAgent } from 'undici';
|
import { ProxyAgent } from 'undici';
|
||||||
|
import { Providers } from '@librechat/agents';
|
||||||
import { KnownEndpoints, removeNullishValues } from 'librechat-data-provider';
|
import { KnownEndpoints, removeNullishValues } from 'librechat-data-provider';
|
||||||
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
||||||
import type { AzureOpenAIInput } from '@langchain/openai';
|
import type { AzureOpenAIInput } from '@langchain/openai';
|
||||||
|
|
@ -222,9 +223,13 @@ export function getOpenAIConfig(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
const result: t.LLMConfigResult = {
|
||||||
llmConfig,
|
llmConfig,
|
||||||
configOptions,
|
configOptions,
|
||||||
tools,
|
tools,
|
||||||
};
|
};
|
||||||
|
if (useOpenRouter) {
|
||||||
|
result.provider = Providers.OPENROUTER;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||||
import { openAISchema, EModelEndpoint } from 'librechat-data-provider';
|
import { openAISchema, EModelEndpoint } from 'librechat-data-provider';
|
||||||
import type { TEndpointOption, TAzureConfig, TEndpoint } from 'librechat-data-provider';
|
import type { TEndpointOption, TAzureConfig, TEndpoint } from 'librechat-data-provider';
|
||||||
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
||||||
import type { OpenAIClientOptions } from '@librechat/agents';
|
import type { OpenAIClientOptions, Providers } from '@librechat/agents';
|
||||||
import type { AzureOptions } from './azure';
|
import type { AzureOptions } from './azure';
|
||||||
|
|
||||||
export type OpenAIParameters = z.infer<typeof openAISchema>;
|
export type OpenAIParameters = z.infer<typeof openAISchema>;
|
||||||
|
|
@ -35,6 +35,7 @@ export interface LLMConfigResult {
|
||||||
llmConfig: ClientOptions;
|
llmConfig: ClientOptions;
|
||||||
configOptions: OpenAIConfiguration;
|
configOptions: OpenAIConfiguration;
|
||||||
tools?: BindToolsInput[];
|
tools?: BindToolsInput[];
|
||||||
|
provider?: Providers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue