mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 12:41:02 +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
|
|
@ -43,11 +43,16 @@ class PromptResponseTranslator(MessageTranslator):
|
||||||
def from_pulsar(self, obj: PromptResponse) -> Dict[str, Any]:
|
def from_pulsar(self, obj: PromptResponse) -> Dict[str, Any]:
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if obj.text:
|
# Include text field if present (even if empty string)
|
||||||
|
if obj.text is not None:
|
||||||
result["text"] = obj.text
|
result["text"] = obj.text
|
||||||
if obj.object:
|
# Include object field if present
|
||||||
|
if obj.object is not None:
|
||||||
result["object"] = obj.object
|
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
|
return result
|
||||||
|
|
||||||
def from_response_with_completion(self, obj: PromptResponse) -> Tuple[Dict[str, Any], bool]:
|
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]:
|
def from_pulsar(self, obj: DocumentRagResponse) -> Dict[str, Any]:
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
# Include response content (chunk or complete)
|
# Include response content (even if empty string)
|
||||||
if obj.response:
|
if obj.response is not None:
|
||||||
result["response"] = obj.response
|
result["response"] = obj.response
|
||||||
|
|
||||||
# Include end_of_stream flag
|
# Include end_of_stream flag
|
||||||
|
|
@ -90,8 +90,8 @@ class GraphRagResponseTranslator(MessageTranslator):
|
||||||
def from_pulsar(self, obj: GraphRagResponse) -> Dict[str, Any]:
|
def from_pulsar(self, obj: GraphRagResponse) -> Dict[str, Any]:
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
# Include response content (chunk or complete)
|
# Include response content (even if empty string)
|
||||||
if obj.response:
|
if obj.response is not None:
|
||||||
result["response"] = obj.response
|
result["response"] = obj.response
|
||||||
|
|
||||||
# Include end_of_stream flag
|
# Include end_of_stream flag
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue