mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 20:21:03 +02:00
Fix gateway translators dropping responses
This commit is contained in:
parent
00292940c4
commit
9df4f59b2c
2 changed files with 13 additions and 8 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