Skip to content

Conversation

@this
Copy link
Contributor

@this this commented May 15, 2023

Fixes #80

Usage

from h2ogpt_client import Client

client = Client("http://0.0.0.0:7860")

# text completion
response = client.text_completion.create("Hello world")
response = await client.text_completion.create_async("Hello world")

# chat completion
chat_context = client.chat_completion.create()
chat = chat_context.chat("Hey!")
print(chat["user"])  # prints user prompt, i.e. "Hey!"
print(chat["gpt"])   # prints reply of the h2oGPT
chat_history = chat_context.chat_history()

@this this requested a review from pseudotensor May 15, 2023 20:43
@pseudotensor
Copy link
Collaborator

pseudotensor commented May 17, 2023

@this Looking great! Make sure you merge main into your PR as the langchain had breaking changes with 1 extra API item.

Also, gradio team fixed the Chat part:

gradio-app/gradio#4081 (comment)

I'll finish this PR now: #117

@pseudotensor
Copy link
Collaborator

@this How's this PR going?

@this
Copy link
Contributor Author

this commented May 25, 2023

How's this PR going?

@pseudotensor I'm currently working on the chat_completion API. I was hoping to include that in this PR, but we can merge this and I can create a new PR.

@this this marked this pull request as ready for review May 25, 2023 19:33
INSTRUCT_VICUNA = "instruct_vicuna"
INSTRUCT_WITH_END = "instruct_with_end"
OPEN_ASSISTANT = "open_assistant"
PLAIN = "plain"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid dup with rest of code as this is constantly extended. I moved to enum the original version. Is there some reason to stick to FOO_BAR = "foo_bar" format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason to stick to FOO_BAR = "foo_bar" format?

@pseudotensor I simply capitalized the value to derive the name of the enum. Id these names are not appropriate, please suggest good names.

All capitalized names were used by following the Python convention https://docs.python.org/3.8/library/enum.html#creating-an-enum. I noticed that PromptType enum names are all simple. Shall we change that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's change to whatever is normal convention. Requires going through and changing conditionals where PromptType used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a separate PR for this.

max_time: int = 180,
repetition_penalty: float = 1.07,
number_returns: int = 1,
system_pre_context: str = "",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the list of parameters, can you (when building the client) verify that the parameters match those passed to evaluate, so it is up to date? i.e. using eval_func_param_names . It won't break things when they are not up to date if you are using string version of API, but would be good when building client that everything is synced so everything possible can be done with this client. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g. you can at build time check in python that set of inspection arguments for "create" is larger than set from eval_func_param_names . I do stuff like that in h2oGPT.

Copy link
Contributor Author

@this this Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, we can do that. Shall we create a new PR for this? In order to make eval_func_param_names isolated (so that it can be used in the client) I had to make changes in places where eval_func_param_names is used. I fell like if I add those changes into this PR, it will clutter the PR.

@pseudotensor pseudotensor self-requested a review June 12, 2023 20:20
Copy link
Collaborator

@pseudotensor pseudotensor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge! Thanks! Let's do more testing and refactors in another PR.

@this this merged commit fd84164 into main Jun 12, 2023
@pseudotensor
Copy link
Collaborator

Non-manual test failures on this branch:

============================================================================================================ short test summary info ============================================================================================================
FAILED tests/test_pipeline.py::test_export_copy - ImportError: cannot import name 'inject_newline' from 'test_output.h2oai_pipeline' (/home/jon/h2ogpt/test_output/h2oai_pipeline.py)
FAILED tests/test_requirements.py::test_requirements - ValueError: ['accelerate==0.19.0', 'transformers==4.28.1', 'git+https://github.com/huggingface/peft.git@3714aa2fff158fdfa637b2b65952580801d890b2']
FAILED tests/test_ui.py::test_newline_replace - AssertionError: assert 'You can use ... sorted list.' == 'You can use ... sorted list.'
=========================================================================== 15 failed, 99 passed, 36 skipped, 1 xfailed, 1 xpassed, 12 warnings in 3745.08s (1:02:25) ===========================================================================
(h2ollm) jon@pseudotensor:~/h2ogpt$ 

Unrelated to this PR.

@this this deleted the sajith/main/add-client branch July 12, 2023 16:00
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.

Create API wrapper so like OpenAI's API

3 participants