mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-03 12:22:37 +02:00
Update to add streaming tests (#600)
This commit is contained in:
parent
f0c95a4c5e
commit
f79d0603f7
9 changed files with 1062 additions and 57 deletions
|
|
@ -51,7 +51,8 @@ class PromptClient(RequestResponse):
|
|||
|
||||
end_stream = getattr(resp, 'end_of_stream', False)
|
||||
|
||||
if resp.text:
|
||||
# Always call callback if there's text OR if it's the final message
|
||||
if resp.text is not None:
|
||||
last_text = resp.text
|
||||
# Call chunk callback if provided with both chunk and end_of_stream flag
|
||||
if chunk_callback:
|
||||
|
|
|
|||
|
|
@ -28,14 +28,17 @@ class TextCompletionResponseTranslator(MessageTranslator):
|
|||
|
||||
def from_pulsar(self, obj: TextCompletionResponse) -> Dict[str, Any]:
|
||||
result = {"response": obj.response}
|
||||
|
||||
|
||||
if obj.in_token:
|
||||
result["in_token"] = obj.in_token
|
||||
if obj.out_token:
|
||||
result["out_token"] = obj.out_token
|
||||
if obj.model:
|
||||
result["model"] = obj.model
|
||||
|
||||
|
||||
# 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: TextCompletionResponse) -> Tuple[Dict[str, Any], bool]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue