mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
🕸️ refactor: Drop/Add web_search Param Handling for Custom Endpoints (#9852)
- Added tests to validate behavior of web_search parameter in getOpenAIConfig function. - Implemented logic to handle web_search in addParams and dropParams, ensuring correct precedence and behavior. - Ensured web_search does not appear in modelKwargs or llmConfig when not applicable. - Improved overall configuration management for OpenAI API integration.
This commit is contained in:
parent
3219734b9e
commit
823015160c
2 changed files with 123 additions and 1 deletions
|
|
@ -129,8 +129,17 @@ export function getOpenAILLMConfig({
|
|||
hasModelKwargs = true;
|
||||
}
|
||||
|
||||
let enableWebSearch = web_search;
|
||||
|
||||
if (addParams && typeof addParams === 'object') {
|
||||
for (const [key, value] of Object.entries(addParams)) {
|
||||
/** Handle web_search directly here instead of adding to modelKwargs or llmConfig */
|
||||
if (key === 'web_search') {
|
||||
if (typeof value === 'boolean') {
|
||||
enableWebSearch = value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (knownOpenAIParams.has(key)) {
|
||||
(llmConfig as Record<string, unknown>)[key] = value;
|
||||
} else {
|
||||
|
|
@ -166,7 +175,12 @@ export function getOpenAILLMConfig({
|
|||
|
||||
const tools: BindToolsInput[] = [];
|
||||
|
||||
if (web_search) {
|
||||
/** Check if web_search should be disabled via dropParams */
|
||||
if (dropParams && dropParams.includes('web_search')) {
|
||||
enableWebSearch = false;
|
||||
}
|
||||
|
||||
if (enableWebSearch) {
|
||||
llmConfig.useResponsesApi = true;
|
||||
tools.push({ type: 'web_search_preview' });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue