Skip to content

Commit 190cf90

Browse files
fix: built in websearch
1 parent adf6814 commit 190cf90

5 files changed

Lines changed: 1463 additions & 592 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const { Providers } = require('@librechat/agents');
2+
const { EModelEndpoint } = require('librechat-data-provider');
3+
const initAnthropic = require('~/server/services/Endpoints/anthropic/initialize');
4+
const getBedrockOptions = require('~/server/services/Endpoints/bedrock/options');
5+
const initOpenAI = require('~/server/services/Endpoints/openAI/initialize');
6+
const initCustom = require('~/server/services/Endpoints/custom/initialize');
7+
const initGoogle = require('~/server/services/Endpoints/google/initialize');
8+
const { getCustomEndpointConfig } = require('~/server/services/Config');
9+
10+
/** Check if the provider is a known custom provider
11+
* @param {string | undefined} [provider] - The provider string
12+
* @returns {boolean} - True if the provider is a known custom provider, false otherwise
13+
*/
14+
function isKnownCustomProvider(provider) {
15+
return [Providers.XAI, Providers.OLLAMA, Providers.DEEPSEEK, Providers.OPENROUTER].includes(
16+
provider?.toLowerCase() || '',
17+
);
18+
}
19+
20+
const providerConfigMap = {
21+
[Providers.XAI]: initCustom,
22+
[Providers.OLLAMA]: initCustom,
23+
[Providers.DEEPSEEK]: initCustom,
24+
[Providers.OPENROUTER]: initCustom,
25+
[EModelEndpoint.openAI]: initOpenAI,
26+
[EModelEndpoint.google]: initGoogle,
27+
[EModelEndpoint.azureOpenAI]: initOpenAI,
28+
[EModelEndpoint.anthropic]: initAnthropic,
29+
[EModelEndpoint.bedrock]: getBedrockOptions,
30+
};
31+
32+
/**
33+
* Get the provider configuration and override endpoint based on the provider string
34+
* @param {string} provider - The provider string
35+
* @returns {Promise<{
36+
* getOptions: Function,
37+
* overrideProvider: string,
38+
* customEndpointConfig?: TEndpoint
39+
* }>}
40+
*/
41+
async function getProviderConfig(provider) {
42+
let getOptions = providerConfigMap[provider];
43+
let overrideProvider = provider;
44+
/** @type {TEndpoint | undefined} */
45+
let customEndpointConfig;
46+
47+
if (!getOptions && providerConfigMap[provider.toLowerCase()] != null) {
48+
overrideProvider = provider.toLowerCase();
49+
getOptions = providerConfigMap[overrideProvider];
50+
} else if (!getOptions) {
51+
customEndpointConfig = await getCustomEndpointConfig(provider);
52+
if (!customEndpointConfig) {
53+
throw new Error(`Provider ${provider} not supported`);
54+
}
55+
getOptions = initCustom;
56+
overrideProvider = Providers.OPENAI;
57+
}
58+
59+
if (isKnownCustomProvider(overrideProvider) && !customEndpointConfig) {
60+
customEndpointConfig = await getCustomEndpointConfig(provider);
61+
if (!customEndpointConfig) {
62+
throw new Error(`Provider ${provider} not supported`);
63+
}
64+
}
65+
66+
return {
67+
getOptions,
68+
overrideProvider,
69+
customEndpointConfig,
70+
};
71+
}
72+
73+
module.exports = {
74+
getProviderConfig,
75+
};

client/src/locales/en/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@
226226
"com_endpoint_openai_stop": "Up to 4 sequences where the API will stop generating further tokens.",
227227
"com_endpoint_openai_temp": "Higher values = more random, while lower values = more focused and deterministic. We recommend altering this or Top P but not both.",
228228
"com_endpoint_openai_topp": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We recommend altering this or temperature but not both.",
229+
"com_endpoint_openai_use_responses_api": "Use the Responses API instead of Chat Completions, which includes extended features from OpenAI. Required for o1-pro, o3-pro, and to enable reasoning summaries.",
230+
"com_endpoint_openai_use_web_search": "Enable web search functionality using OpenAI's built-in search capabilities. This allows the model to search the web for up-to-date information and provide more accurate, current responses.",
229231
"com_endpoint_output": "Output",
230232
"com_endpoint_plug_image_detail": "Image Detail",
231233
"com_endpoint_plug_resend_files": "Resend Files",

0 commit comments

Comments
 (0)