Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine requester util #15

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions jetstream/core/tools/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
_SESSION_CACHE = flags.DEFINE_string(
'session_cache', '', 'Location of any pre-cached results'
)
_TEXT = flags.DEFINE_string('text', 'AB', 'The message')
_TEXT = flags.DEFINE_string('text', 'Today is a good day', 'The message')
_PRIORITY = flags.DEFINE_integer('priority', 0, 'Message priority')
_MAX_TOKENS = flags.DEFINE_integer('max_tokens', 3, 'Maximum number of tokens')

Expand All @@ -41,22 +41,23 @@ def _GetResponseAsync(
"""Gets an async response."""

response = stub.Decode(request)
output = ""
for token_list in response:
print(token_list.response[0], end='', flush=True)
print('\n')
output += token_list.response[0]
print(f'Prompt: {_TEXT.value}')
print(f'Response: {output}')


def main(argv: Sequence[str]) -> None:
del argv
# Note: Uses insecure_channel only for local testing. Please add grpc credentials for Production.
address = f'{_SERVER.value}:{_PORT.value}'
print(address)
with grpc.insecure_channel(
address
) as channel:
grpc.channel_ready_future(channel).result()
stub = jetstream_pb2_grpc.OrchestratorStub(channel)
print('Making request')
print(f'Sending request to: {address}')
request = jetstream_pb2.DecodeRequest(
session_cache=_SESSION_CACHE.value,
additional_text=_TEXT.value,
Expand Down
Loading