29
29
_SESSION_CACHE = flags .DEFINE_string (
30
30
'session_cache' , '' , 'Location of any pre-cached results'
31
31
)
32
- _TEXT = flags .DEFINE_string ('text' , 'AB ' , 'The message' )
32
+ _TEXT = flags .DEFINE_string ('text' , 'Today is a good day ' , 'The message' )
33
33
_PRIORITY = flags .DEFINE_integer ('priority' , 0 , 'Message priority' )
34
34
_MAX_TOKENS = flags .DEFINE_integer ('max_tokens' , 3 , 'Maximum number of tokens' )
35
35
@@ -41,22 +41,23 @@ def _GetResponseAsync(
41
41
"""Gets an async response."""
42
42
43
43
response = stub .Decode (request )
44
+ output = ""
44
45
for token_list in response :
45
- print (token_list .response [0 ], end = '' , flush = True )
46
- print ('\n ' )
46
+ output += token_list .response [0 ]
47
+ print (f'Prompt: { _TEXT .value } ' )
48
+ print (f'Response: { output } ' )
47
49
48
50
49
51
def main (argv : Sequence [str ]) -> None :
50
52
del argv
51
53
# Note: Uses insecure_channel only for local testing. Please add grpc credentials for Production.
52
54
address = f'{ _SERVER .value } :{ _PORT .value } '
53
- print (address )
54
55
with grpc .insecure_channel (
55
56
address
56
57
) as channel :
57
58
grpc .channel_ready_future (channel ).result ()
58
59
stub = jetstream_pb2_grpc .OrchestratorStub (channel )
59
- print ('Making request' )
60
+ print (f'Sending request to: { address } ' )
60
61
request = jetstream_pb2 .DecodeRequest (
61
62
session_cache = _SESSION_CACHE .value ,
62
63
additional_text = _TEXT .value ,
0 commit comments