mirror of
https://github.com/ollama/ollama-python.git
synced 2026-10-13 20:37:27 +00:00
Add better messaging for chat
This commit is contained in:
+44
-4
@@ -298,12 +298,28 @@ class Client(BaseClient):
|
|||||||
Create a chat response using the requested model.
|
Create a chat response using the requested model.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tools (Sequence[Union[Mapping[str, Any], Tool, Callable]]):
|
tools:
|
||||||
A JSON schema as a dict, an Ollama Tool or a Python Function.
|
A JSON schema as a dict, an Ollama Tool or a Python Function.
|
||||||
Python functions need to follow Google style docstrings to be converted to an Ollama Tool.
|
Python functions need to follow Google style docstrings to be converted to an Ollama Tool.
|
||||||
For more information, see: https://google.github.io/styleguide/pyguide.html#38-Docstrings
|
For more information, see: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
|
||||||
stream (bool): Whether to stream the response.
|
stream: Whether to stream the response.
|
||||||
format (Optional[Literal['', 'json']]): The format of the response.
|
format: The format of the response.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
def add_two_numbers(a: int, b: int) -> int:
|
||||||
|
\"""
|
||||||
|
Add two numbers together.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
a: First number to add
|
||||||
|
b: Second number to add
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: The sum of a and b
|
||||||
|
\"""
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
client.chat(model='llama3.1:8b', tools=[add_two_numbers], messages=[...])
|
||||||
|
|
||||||
Raises `RequestError` if a model is not provided.
|
Raises `RequestError` if a model is not provided.
|
||||||
|
|
||||||
@@ -783,6 +799,30 @@ class AsyncClient(BaseClient):
|
|||||||
"""
|
"""
|
||||||
Create a chat response using the requested model.
|
Create a chat response using the requested model.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
tools:
|
||||||
|
A JSON schema as a dict, an Ollama Tool or a Python Function.
|
||||||
|
Python functions need to follow Google style docstrings to be converted to an Ollama Tool.
|
||||||
|
For more information, see: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
|
||||||
|
stream: Whether to stream the response.
|
||||||
|
format: The format of the response.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
def add_two_numbers(a: int, b: int) -> int:
|
||||||
|
\"""
|
||||||
|
Add two numbers together.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
a: First number to add
|
||||||
|
b: Second number to add
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: The sum of a and b
|
||||||
|
\"""
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
client.chat(model='llama3.1:8b', tools=[add_two_numbers], messages=[...])
|
||||||
|
|
||||||
Raises `RequestError` if a model is not provided.
|
Raises `RequestError` if a model is not provided.
|
||||||
|
|
||||||
Raises `ResponseError` if the request could not be fulfilled.
|
Raises `ResponseError` if the request could not be fulfilled.
|
||||||
|
|||||||
Reference in New Issue
Block a user