mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-09 13:22:10 +02:00
Set end-of-stream cleanly
This commit is contained in:
parent
f1180ecda2
commit
e02b834b22
4 changed files with 14 additions and 18 deletions
|
|
@ -173,7 +173,14 @@ class LibraryResponseTranslator(MessageTranslator):
|
|||
return result
|
||||
|
||||
def from_response_with_completion(self, obj: LibrarianResponse) -> Tuple[Dict[str, Any], bool]:
|
||||
"""Returns (response_dict, is_final)"""
|
||||
# For streaming responses, check end_of_stream to determine if this is the final message
|
||||
is_final = getattr(obj, 'end_of_stream', True)
|
||||
"""Returns (response_dict, is_final)
|
||||
|
||||
For chunked streaming responses (total_chunks > 0), completion is
|
||||
determined by whether we've reached the final chunk.
|
||||
For non-streaming responses (total_chunks = 0), always final.
|
||||
"""
|
||||
if obj.total_chunks > 0:
|
||||
is_final = (obj.chunk_index >= obj.total_chunks - 1)
|
||||
else:
|
||||
is_final = True
|
||||
return self.from_pulsar(obj), is_final
|
||||
|
|
|
|||
|
|
@ -212,10 +212,6 @@ class LibrarianResponse:
|
|||
# list-uploads response
|
||||
upload_sessions: list[UploadSession] = field(default_factory=list)
|
||||
|
||||
# stream-document response - indicates final chunk in stream
|
||||
# Default True so non-streaming operations are treated as final
|
||||
end_of_stream: bool = True
|
||||
|
||||
# FIXME: Is this right? Using persistence on librarian so that
|
||||
# message chunking works
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue