From 51ee60da74700d051a2b35ca236be53dac0caea2 Mon Sep 17 00:00:00 2001 From: Maziyar Panahi Date: Tue, 30 Apr 2024 11:07:17 +0200 Subject: [PATCH] Add the missing `tool_prompt` parameter to Python client (#1825) # What does this PR do? This PR adds the missing `tool_prompt` parameter in Python client ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section? - [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case. - [x] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation). - [ ] Did you write any new necessary tests? ## Who can review? Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR. @Narsil --- clients/python/text_generation/client.py | 8 ++++++++ clients/python/text_generation/types.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/clients/python/text_generation/client.py b/clients/python/text_generation/client.py index 95d23901..0e86901d 100644 --- a/clients/python/text_generation/client.py +++ b/clients/python/text_generation/client.py @@ -80,6 +80,7 @@ class Client: temperature: Optional[float] = None, top_p: Optional[float] = None, tools: Optional[List[Tool]] = None, + tool_prompt: Optional[str] = None, tool_choice: Optional[str] = None, ): """ @@ -119,6 +120,8 @@ class Client: higher are kept for generation tools (`List[Tool]`): List of tools to use + tool_prompt (`str`): + A prompt to be appended before the tools tool_choice (`str`): The tool to use @@ -139,6 +142,7 @@ class Client: temperature=temperature, top_p=top_p, tools=tools, + tool_prompt=tool_prompt, tool_choice=tool_choice, ) if not stream: @@ -466,6 +470,7 @@ class AsyncClient: temperature: Optional[float] = None, top_p: Optional[float] = None, tools: Optional[List[Tool]] = None, + tool_prompt: Optional[str] = None, tool_choice: Optional[str] = None, ) -> Union[ChatComplete, AsyncIterator[ChatCompletionChunk]]: """ @@ -505,6 +510,8 @@ class AsyncClient: higher are kept for generation tools (`List[Tool]`): List of tools to use + tool_prompt (`str`): + A prompt to be appended before the tools tool_choice (`str`): The tool to use @@ -525,6 +532,7 @@ class AsyncClient: temperature=temperature, top_p=top_p, tools=tools, + tool_prompt=tool_prompt, tool_choice=tool_choice, ) if not stream: diff --git a/clients/python/text_generation/types.py b/clients/python/text_generation/types.py index cfa2a9ed..5e32bc6f 100644 --- a/clients/python/text_generation/types.py +++ b/clients/python/text_generation/types.py @@ -159,6 +159,8 @@ class ChatRequest(BaseModel): top_p: Optional[float] = None # List of tools to be used tools: Optional[List[Tool]] = None + # A prompt to be appended before the tools + tool_prompt: Optional[str] = None # Choice of tool to be used tool_choice: Optional[str] = None