mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 14:52:23 +00:00
refac
This commit is contained in:
parent
e51722348a
commit
cd86161f33
@ -742,8 +742,6 @@ async def process_chat_payload(request, form_data, metadata, user, model):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"form_data, events")
|
|
||||||
|
|
||||||
return form_data, events
|
return form_data, events
|
||||||
|
|
||||||
|
|
||||||
@ -810,8 +808,22 @@ async def process_chat_response(request, response, user, events, metadata, tasks
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
|
|
||||||
|
if "selected_model_id" in data:
|
||||||
|
Chats.upsert_message_to_chat_by_id_and_message_id(
|
||||||
|
metadata["chat_id"],
|
||||||
|
metadata["message_id"],
|
||||||
|
{
|
||||||
|
"selectedModelId": data["selected_model_id"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
value = (
|
value = (
|
||||||
data.get("choices", [])[0].get("delta", {}).get("content")
|
data.get("choices", [])[0]
|
||||||
|
.get("delta", {})
|
||||||
|
.get("content")
|
||||||
)
|
)
|
||||||
|
|
||||||
if value:
|
if value:
|
||||||
|
@ -1052,7 +1052,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const chatCompletionEventHandler = async (data, message, chatId) => {
|
const chatCompletionEventHandler = async (data, message, chatId) => {
|
||||||
const { id, done, choices, sources, selectedModelId, error, usage } = data;
|
const { id, done, choices, sources, selected_model_id, error, usage } = data;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
await handleOpenAIError(error, message);
|
await handleOpenAIError(error, message);
|
||||||
@ -1060,12 +1060,6 @@
|
|||||||
|
|
||||||
if (sources) {
|
if (sources) {
|
||||||
message.sources = sources;
|
message.sources = sources;
|
||||||
// Only remove status if it was initially set
|
|
||||||
if (model?.info?.meta?.knowledge ?? false) {
|
|
||||||
message.statusHistory = message.statusHistory.filter(
|
|
||||||
(status) => status.action !== 'knowledge_search'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (choices) {
|
if (choices) {
|
||||||
@ -1103,8 +1097,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedModelId) {
|
if (selected_model_id) {
|
||||||
message.selectedModelId = selectedModelId;
|
message.selectedModelId = selected_model_id;
|
||||||
message.arena = true;
|
message.arena = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user