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

Reform chatbot client API code #117

Merged
merged 7 commits into from
May 17, 2023
Merged

Reform chatbot client API code #117

merged 7 commits into from
May 17, 2023

Conversation

pseudotensor
Copy link
Collaborator

@pseudotensor pseudotensor commented May 6, 2023

but serialize=False doesn't work due to gr.state issue: gradio-app/gradio#4081

Original here that had to use json files due to serialize=True default:

h2ogpt/client_test.py

Lines 81 to 107 in 05c742a

else:
api_name = '/instruction'
import json
foofile = '/tmp/foo.json'
with open(foofile, 'wt') as f:
json.dump([['', None]], f)
args += [foofile]
if not stream_output:
for res in client.predict(
*tuple(args),
api_name=api_name,
):
print(res)
res_file = client.predict(*tuple(args), api_name='/instruction_bot')
res = json.load(open(res_file, "rt"))[-1][-1]
print(md_to_text(res))
else:
print("streaming instruction_bot", flush=True)
job = client.submit(*tuple(args), api_name='/instruction_bot')
while not job.done():
outputs_list = job.communicator.job.outputs
if outputs_list:
res_file = job.communicator.job.outputs[-1]
res = json.load(open(res_file, "rt"))[-1][-1]
print(md_to_text(res))
time.sleep(0.1)
print(job.outputs())

@pseudotensor pseudotensor changed the title Reform chatbot client API code, but serialize=False doesn't work due … Reform chatbot client API code May 6, 2023
@pseudotensor pseudotensor mentioned this pull request May 17, 2023
@pseudotensor
Copy link
Collaborator Author


==================================================================================== 4 passed, 1 skipped in 310.72s (0:05:10) =====================================================================================
(h2ollm) jon@pseudotensor:~/h2o-llm$ 

@pseudotensor pseudotensor marked this pull request as ready for review May 17, 2023 19:09
@pseudotensor pseudotensor merged commit 00d717c into main May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant