mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 08:56:39 +00:00
feat: use the conversation's model instead of the first model for query gen
This commit is contained in:
parent
eb509c460a
commit
69bac2a20e
@ -316,7 +316,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useWebSearch) {
|
if (useWebSearch) {
|
||||||
await runWebSearchForPrompt(parentId, responseMessageId);
|
await runWebSearchForPrompt(model.id, parentId, responseMessageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model?.external) {
|
if (model?.external) {
|
||||||
@ -334,11 +334,11 @@
|
|||||||
await chats.set(await getChatList(localStorage.token));
|
await chats.set(await getChatList(localStorage.token));
|
||||||
};
|
};
|
||||||
|
|
||||||
const runWebSearchForPrompt = async (parentId: string, responseId: string) => {
|
const runWebSearchForPrompt = async (model: string, parentId: string, responseId: string) => {
|
||||||
const responseMessage = history.messages[responseId];
|
const responseMessage = history.messages[responseId];
|
||||||
responseMessage.progress = $i18n.t('Generating search query');
|
responseMessage.progress = $i18n.t('Generating search query');
|
||||||
messages = messages;
|
messages = messages;
|
||||||
const searchQuery = await generateChatSearchQuery(parentId);
|
const searchQuery = await generateChatSearchQuery(model, parentId);
|
||||||
if (!searchQuery) {
|
if (!searchQuery) {
|
||||||
toast.warning($i18n.t('No search query generated'));
|
toast.warning($i18n.t('No search query generated'));
|
||||||
responseMessage.progress = undefined;
|
responseMessage.progress = undefined;
|
||||||
@ -913,13 +913,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateChatSearchQuery = async (messageId: string) => {
|
const generateChatSearchQuery = async (modelId: string, messageId: string) => {
|
||||||
const model = $models.find((model) => model.id === selectedModels[0]);
|
const model = $models.find((model) => model.id === modelId);
|
||||||
|
|
||||||
const taskModelId =
|
const taskModelId =
|
||||||
model?.external ?? false
|
model?.external ?? false
|
||||||
? $settings?.title?.modelExternal ?? selectedModels[0]
|
? $settings?.title?.modelExternal ?? modelId
|
||||||
: $settings?.title?.model ?? selectedModels[0];
|
: $settings?.title?.model ?? modelId;
|
||||||
const taskModel = $models.find((model) => model.id === taskModelId);
|
const taskModel = $models.find((model) => model.id === taskModelId);
|
||||||
|
|
||||||
const userMessage = history.messages[messageId];
|
const userMessage = history.messages[messageId];
|
||||||
|
@ -323,7 +323,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useWebSearch) {
|
if (useWebSearch) {
|
||||||
await runWebSearchForPrompt(parentId, responseMessageId);
|
await runWebSearchForPrompt(model.id, parentId, responseMessageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model?.external) {
|
if (model?.external) {
|
||||||
@ -334,17 +334,18 @@
|
|||||||
} else {
|
} else {
|
||||||
toast.error($i18n.t(`Model {{modelId}} not found`, { modelId }));
|
toast.error($i18n.t(`Model {{modelId}} not found`, { modelId }));
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
await chats.set(await getChatList(localStorage.token));
|
await chats.set(await getChatList(localStorage.token));
|
||||||
};
|
};
|
||||||
|
|
||||||
const runWebSearchForPrompt = async (parentId: string, responseId: string) => {
|
const runWebSearchForPrompt = async (model: string, parentId: string, responseId: string) => {
|
||||||
const responseMessage = history.messages[responseId];
|
const responseMessage = history.messages[responseId];
|
||||||
responseMessage.progress = $i18n.t('Generating search query');
|
responseMessage.progress = $i18n.t('Generating search query');
|
||||||
messages = messages;
|
messages = messages;
|
||||||
const searchQuery = await generateChatSearchQuery(parentId);
|
const searchQuery = await generateChatSearchQuery(model, parentId);
|
||||||
if (!searchQuery) {
|
if (!searchQuery) {
|
||||||
toast.warning($i18n.t('No search query generated'));
|
toast.warning($i18n.t('No search query generated'));
|
||||||
responseMessage.progress = undefined;
|
responseMessage.progress = undefined;
|
||||||
@ -369,7 +370,7 @@
|
|||||||
type: 'websearch',
|
type: 'websearch',
|
||||||
upload_status: true,
|
upload_status: true,
|
||||||
error: '',
|
error: '',
|
||||||
urls: searchDocument.filenames,
|
urls: searchDocument.filenames
|
||||||
});
|
});
|
||||||
responseMessage.progress = undefined;
|
responseMessage.progress = undefined;
|
||||||
messages = messages;
|
messages = messages;
|
||||||
@ -919,13 +920,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateChatSearchQuery = async (messageId: string) => {
|
const generateChatSearchQuery = async (modelId: string, messageId: string) => {
|
||||||
const model = $models.find((model) => model.id === selectedModels[0]);
|
const model = $models.find((model) => model.id === modelId);
|
||||||
|
|
||||||
const taskModelId =
|
const taskModelId =
|
||||||
model?.external ?? false
|
model?.external ?? false
|
||||||
? $settings?.title?.modelExternal ?? selectedModels[0]
|
? $settings?.title?.modelExternal ?? modelId
|
||||||
: $settings?.title?.model ?? selectedModels[0];
|
: $settings?.title?.model ?? modelId;
|
||||||
const taskModel = $models.find((model) => model.id === taskModelId);
|
const taskModel = $models.find((model) => model.id === taskModelId);
|
||||||
|
|
||||||
const userMessage = history.messages[messageId];
|
const userMessage = history.messages[messageId];
|
||||||
|
Loading…
Reference in New Issue
Block a user