refac
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2025-01-10 16:27:37 -08:00
parent dd08b457d8
commit 21abe43f3b

View File

@ -770,14 +770,17 @@ async def process_chat_response(
) )
if res and isinstance(res, dict): if res and isinstance(res, dict):
title = ( if len(res.get("choices", [])) == 1:
res.get("choices", [])[0] title = (
.get("message", {}) res.get("choices", [])[0]
.get( .get("message", {})
"content", .get(
message.get("content", "New Chat"), "content",
) message.get("content", "New Chat"),
).strip() )
).strip()
else:
title = None
if not title: if not title:
title = messages[0].get("content", "New Chat") title = messages[0].get("content", "New Chat")
@ -814,11 +817,14 @@ async def process_chat_response(
) )
if res and isinstance(res, dict): if res and isinstance(res, dict):
tags_string = ( if len(res.get("choices", [])) == 1:
res.get("choices", [])[0] tags_string = (
.get("message", {}) res.get("choices", [])[0]
.get("content", "") .get("message", {})
) .get("content", "")
)
else:
tags_string = ""
tags_string = tags_string[ tags_string = tags_string[
tags_string.find("{") : tags_string.rfind("}") + 1 tags_string.find("{") : tags_string.rfind("}") + 1
@ -837,7 +843,7 @@ async def process_chat_response(
} }
) )
except Exception as e: except Exception as e:
print(f"Error: {e}") pass
event_emitter = None event_emitter = None
if ( if (