mirror of
https://github.com/open-webui/open-webui
synced 2025-06-04 03:37:35 +00:00
refac
This commit is contained in:
parent
bffbf7e238
commit
13c7d96515
@ -1252,6 +1252,8 @@ async def process_chat_response(
|
|||||||
end_tag_pattern = rf"</{tag}>"
|
end_tag_pattern = rf"</{tag}>"
|
||||||
|
|
||||||
if re.search(end_tag_pattern, content):
|
if re.search(end_tag_pattern, content):
|
||||||
|
end_flag = True
|
||||||
|
|
||||||
block_content = content_blocks[-1]["content"]
|
block_content = content_blocks[-1]["content"]
|
||||||
# Strip start and end tags from the content
|
# Strip start and end tags from the content
|
||||||
start_tag_pattern = rf"<{tag}(.*?)>"
|
start_tag_pattern = rf"<{tag}(.*?)>"
|
||||||
@ -1276,7 +1278,6 @@ async def process_chat_response(
|
|||||||
print(f"leftover_content: {leftover_content}")
|
print(f"leftover_content: {leftover_content}")
|
||||||
|
|
||||||
if block_content:
|
if block_content:
|
||||||
end_flag = True
|
|
||||||
content_blocks[-1]["content"] = block_content
|
content_blocks[-1]["content"] = block_content
|
||||||
content_blocks[-1]["ended_at"] = time.time()
|
content_blocks[-1]["ended_at"] = time.time()
|
||||||
content_blocks[-1]["duration"] = int(
|
content_blocks[-1]["duration"] = int(
|
||||||
@ -1290,9 +1291,7 @@ async def process_chat_response(
|
|||||||
"content": leftover_content,
|
"content": leftover_content,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
end_flag = True
|
|
||||||
# Remove the block if content is empty
|
# Remove the block if content is empty
|
||||||
content_blocks.pop()
|
content_blocks.pop()
|
||||||
|
|
||||||
@ -1377,7 +1376,6 @@ async def process_chat_response(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
print(data)
|
|
||||||
|
|
||||||
if "selected_model_id" in data:
|
if "selected_model_id" in data:
|
||||||
model_id = data["selected_model_id"]
|
model_id = data["selected_model_id"]
|
||||||
|
Loading…
Reference in New Issue
Block a user