mirror of
https://github.com/open-webui/open-webui
synced 2025-02-22 21:32:32 +00:00
refac: direct connections
This commit is contained in:
parent
eb568695e7
commit
6d899b80d0
@ -947,6 +947,7 @@ async def chat_completion(
|
||||
else {}
|
||||
),
|
||||
}
|
||||
|
||||
request.state.metadata = metadata
|
||||
form_data["metadata"] = metadata
|
||||
|
||||
|
@ -279,8 +279,8 @@ def get_event_emitter(request_info):
|
||||
await sio.emit(
|
||||
"chat-events",
|
||||
{
|
||||
"chat_id": request_info["chat_id"],
|
||||
"message_id": request_info["message_id"],
|
||||
"chat_id": request_info.get("chat_id", None),
|
||||
"message_id": request_info.get("message_id", None),
|
||||
"data": event_data,
|
||||
},
|
||||
to=session_id,
|
||||
@ -329,8 +329,8 @@ def get_event_call(request_info):
|
||||
response = await sio.call(
|
||||
"chat-events",
|
||||
{
|
||||
"chat_id": request_info["chat_id"],
|
||||
"message_id": request_info["message_id"],
|
||||
"chat_id": request_info.get("chat_id", None),
|
||||
"message_id": request_info.get("message_id", None),
|
||||
"data": event_data,
|
||||
},
|
||||
to=request_info["session_id"],
|
||||
|
@ -164,10 +164,14 @@ async def generate_chat_completion(
|
||||
if BYPASS_MODEL_ACCESS_CONTROL:
|
||||
bypass_filter = True
|
||||
|
||||
if hasattr(request.state, "metadata"):
|
||||
form_data["metadata"] = request.state.metadata
|
||||
|
||||
if getattr(request.state, "direct", False) and hasattr(request.state, "model"):
|
||||
models = {
|
||||
request.state.model["id"]: request.state.model,
|
||||
}
|
||||
log.debug(f"direct connection to model: {models}")
|
||||
else:
|
||||
models = request.app.state.MODELS
|
||||
|
||||
|
@ -266,8 +266,6 @@
|
||||
if (directConnections) {
|
||||
const urlIdx = model?.urlIdx;
|
||||
|
||||
console.log(model, directConnections);
|
||||
|
||||
const OPENAI_API_URL = directConnections.OPENAI_API_BASE_URLS[urlIdx];
|
||||
const OPENAI_API_KEY = directConnections.OPENAI_API_KEYS[urlIdx];
|
||||
const API_CONFIG = directConnections.OPENAI_API_CONFIGS[urlIdx];
|
||||
@ -315,6 +313,7 @@
|
||||
const lines = chunk.split('\n').filter((line) => line.trim() !== '');
|
||||
|
||||
for (const line of lines) {
|
||||
console.log(line);
|
||||
$socket?.emit(channel, line);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user