mirror of
https://github.com/open-webui/open-webui
synced 2025-03-19 19:48:14 +00:00
refac
This commit is contained in:
parent
dbc352f01b
commit
d258523a3c
@ -618,6 +618,12 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
|
||||
content={"detail": str(e)},
|
||||
)
|
||||
|
||||
# Extract valves from the request body
|
||||
valves = None
|
||||
if "valves" in body:
|
||||
valves = body["valves"]
|
||||
del body["valves"]
|
||||
|
||||
# Extract session_id, chat_id and message_id from the request body
|
||||
session_id = None
|
||||
if "session_id" in body:
|
||||
@ -695,6 +701,7 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
|
||||
"session_id": session_id,
|
||||
"chat_id": chat_id,
|
||||
"message_id": message_id,
|
||||
"valves": valves,
|
||||
}
|
||||
|
||||
modified_body_bytes = json.dumps(body).encode("utf-8")
|
||||
@ -982,16 +989,17 @@ async def get_all_models():
|
||||
if action_id in enabled_action_ids
|
||||
]
|
||||
|
||||
model["actions"] = [
|
||||
{
|
||||
"id": action_id,
|
||||
"name": Functions.get_function_by_id(action_id).name,
|
||||
"description": Functions.get_function_by_id(
|
||||
action_id
|
||||
).meta.description,
|
||||
}
|
||||
for action_id in action_ids
|
||||
]
|
||||
model["actions"] = []
|
||||
for action_id in action_ids:
|
||||
action = Functions.get_function_by_id(action_id)
|
||||
model["actions"].append(
|
||||
{
|
||||
"id": action_id,
|
||||
"name": action.name,
|
||||
"description": action.meta.description,
|
||||
"icon_url": action.meta.manifest.get("icon_url", None),
|
||||
}
|
||||
)
|
||||
|
||||
else:
|
||||
owned_by = "openai"
|
||||
|
@ -804,6 +804,7 @@
|
||||
keep_alive: $settings.keepAlive ?? undefined,
|
||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||
files: files.length > 0 ? files : undefined,
|
||||
...(Object.keys(valves).length ? { valves } : {}),
|
||||
session_id: $socket?.id,
|
||||
chat_id: $chatId,
|
||||
id: responseMessageId
|
||||
@ -1108,6 +1109,7 @@
|
||||
max_tokens: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
|
||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||
files: files.length > 0 ? files : undefined,
|
||||
...(Object.keys(valves).length ? { valves } : {}),
|
||||
session_id: $socket?.id,
|
||||
chat_id: $chatId,
|
||||
id: responseMessageId
|
||||
|
Loading…
Reference in New Issue
Block a user