Fix streaming API niggles (#599)

* Fix end-of-stream anomally with some graph-rag and document-rag

* Fix gateway translators dropping responses
This commit is contained in:
cybermaggedon 2026-01-06 16:41:35 +00:00 committed by GitHub
parent 3c675b8cfc
commit f0c95a4c5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 42 deletions

View file

@ -42,12 +42,17 @@ class PromptResponseTranslator(MessageTranslator):
def from_pulsar(self, obj: PromptResponse) -> Dict[str, Any]:
result = {}
if obj.text:
# Include text field if present (even if empty string)
if obj.text is not None:
result["text"] = obj.text
if obj.object:
# Include object field if present
if obj.object is not None:
result["object"] = obj.object
# Always include end_of_stream flag for streaming support
result["end_of_stream"] = getattr(obj, "end_of_stream", False)
return result
def from_response_with_completion(self, obj: PromptResponse) -> Tuple[Dict[str, Any], bool]:

View file

@ -34,8 +34,8 @@ class DocumentRagResponseTranslator(MessageTranslator):
def from_pulsar(self, obj: DocumentRagResponse) -> Dict[str, Any]:
result = {}
# Include response content (chunk or complete)
if obj.response:
# Include response content (even if empty string)
if obj.response is not None:
result["response"] = obj.response
# Include end_of_stream flag
@ -90,8 +90,8 @@ class GraphRagResponseTranslator(MessageTranslator):
def from_pulsar(self, obj: GraphRagResponse) -> Dict[str, Any]:
result = {}
# Include response content (chunk or complete)
if obj.response:
# Include response content (even if empty string)
if obj.response is not None:
result["response"] = obj.response
# Include end_of_stream flag