mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 13:22:41 +02:00
refactor(chat): implement turn cancellation and status management in new chat routes for improved user experience and error handling
This commit is contained in:
parent
4056bd1d69
commit
af66fbf106
12 changed files with 671 additions and 81 deletions
|
|
@ -565,7 +565,12 @@ class VercelStreamingService:
|
|||
# Error Part
|
||||
# =========================================================================
|
||||
|
||||
def format_error(self, error_text: str, error_code: str | None = None) -> str:
|
||||
def format_error(
|
||||
self,
|
||||
error_text: str,
|
||||
error_code: str | None = None,
|
||||
extra: dict[str, object] | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Format an error message.
|
||||
|
||||
|
|
@ -579,9 +584,11 @@ class VercelStreamingService:
|
|||
Example output:
|
||||
data: {"type":"error","errorText":"Something went wrong","errorCode":"SOME_CODE"}
|
||||
"""
|
||||
payload: dict[str, str] = {"type": "error", "errorText": error_text}
|
||||
payload: dict[str, object] = {"type": "error", "errorText": error_text}
|
||||
if error_code:
|
||||
payload["errorCode"] = error_code
|
||||
if extra:
|
||||
payload.update(extra)
|
||||
return self._format_sse(payload)
|
||||
|
||||
# =========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue