mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
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:
parent
3c675b8cfc
commit
f0c95a4c5e
5 changed files with 29 additions and 42 deletions
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue