Skip to content

Commit a1dc266

Browse files
committed
refac
1 parent c28d82b commit a1dc266

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

backend/open_webui/utils/chat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ async def generate_direct_chat_completion(
7474
session_id = metadata.get("session_id")
7575
request_id = str(uuid.uuid4()) # Generate a unique request ID
7676

77-
event_emitter = get_event_emitter(metadata)
7877
event_caller = get_event_call(metadata)
7978

8079
channel = f"{user_id}:{session_id}:{request_id}"
@@ -191,7 +190,7 @@ async def generate_chat_completion(
191190
except Exception as e:
192191
raise e
193192

194-
if request.state.direct:
193+
if getattr(request.state, "direct", False):
195194
return await generate_direct_chat_completion(
196195
request, form_data, user=user, models=models
197196
)

backend/open_webui/utils/middleware.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -778,17 +778,7 @@ async def process_chat_payload(request, form_data, metadata, user, model):
778778

779779
if "document" in source:
780780
for doc_idx, doc_context in enumerate(source["document"]):
781-
doc_metadata = source.get("metadata")
782-
doc_source_id = None
783-
784-
if doc_metadata:
785-
doc_source_id = doc_metadata[doc_idx].get("source", source_id)
786-
787-
if source_id:
788-
context_string += f"<source><source_id>{doc_source_id if doc_source_id is not None else source_id}</source_id><source_context>{doc_context}</source_context></source>\n"
789-
else:
790-
# If there is no source_id, then do not include the source_id tag
791-
context_string += f"<source><source_context>{doc_context}</source_context></source>\n"
781+
context_string += f"<source><source_id>{doc_idx}</source_id><source_context>{doc_context}</source_context></source>\n"
792782

793783
context_string = context_string.strip()
794784
prompt = get_last_user_message(form_data["messages"])

src/routes/+layout.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
cb({
295295
status: true
296296
});
297+
console.log({ status: true });
297298
298299
// res will either be SSE or JSON
299300
const reader = res.body.getReader();

0 commit comments

Comments
 (0)