Add the missing `tool_prompt` to Python client

This commit is contained in:
Maziyar Panahi 2024-04-28 22:04:19 +02:00 committed by drbh
parent eade737714
commit 1f30217aec
2 changed files with 10 additions and 0 deletions

View File

@ -80,6 +80,7 @@ class Client:
temperature: Optional[float] = None, temperature: Optional[float] = None,
top_p: Optional[float] = None, top_p: Optional[float] = None,
tools: Optional[List[Tool]] = None, tools: Optional[List[Tool]] = None,
tool_prompt: Optional[str] = None,
tool_choice: Optional[str] = None, tool_choice: Optional[str] = None,
): ):
""" """
@ -119,6 +120,8 @@ class Client:
higher are kept for generation higher are kept for generation
tools (`List[Tool]`): tools (`List[Tool]`):
List of tools to use List of tools to use
tool_prompt (`str`):
A prompt to be appended before the tools
tool_choice (`str`): tool_choice (`str`):
The tool to use The tool to use
@ -139,6 +142,7 @@ class Client:
temperature=temperature, temperature=temperature,
top_p=top_p, top_p=top_p,
tools=tools, tools=tools,
tool_prompt=tool_prompt,
tool_choice=tool_choice, tool_choice=tool_choice,
) )
if not stream: if not stream:
@ -466,6 +470,7 @@ class AsyncClient:
temperature: Optional[float] = None, temperature: Optional[float] = None,
top_p: Optional[float] = None, top_p: Optional[float] = None,
tools: Optional[List[Tool]] = None, tools: Optional[List[Tool]] = None,
tool_prompt: Optional[str] = None,
tool_choice: Optional[str] = None, tool_choice: Optional[str] = None,
) -> Union[ChatComplete, AsyncIterator[ChatCompletionChunk]]: ) -> Union[ChatComplete, AsyncIterator[ChatCompletionChunk]]:
""" """
@ -505,6 +510,8 @@ class AsyncClient:
higher are kept for generation higher are kept for generation
tools (`List[Tool]`): tools (`List[Tool]`):
List of tools to use List of tools to use
tool_prompt (`str`):
A prompt to be appended before the tools
tool_choice (`str`): tool_choice (`str`):
The tool to use The tool to use
@ -525,6 +532,7 @@ class AsyncClient:
temperature=temperature, temperature=temperature,
top_p=top_p, top_p=top_p,
tools=tools, tools=tools,
tool_prompt=tool_prompt,
tool_choice=tool_choice, tool_choice=tool_choice,
) )
if not stream: if not stream:

View File

@ -159,6 +159,8 @@ class ChatRequest(BaseModel):
top_p: Optional[float] = None top_p: Optional[float] = None
# List of tools to be used # List of tools to be used
tools: Optional[List[Tool]] = None tools: Optional[List[Tool]] = None
# A prompt to be appended before the tools
tool_prompt: Optional[str] = None
# Choice of tool to be used # Choice of tool to be used
tool_choice: Optional[str] = None tool_choice: Optional[str] = None