Skip to content

support tool calls #212

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def generate(
raw: bool = False,
format: Literal['', 'json'] = '',
images: Optional[Sequence[AnyStr]] = None,
tools: Optional[Sequence[Any]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

tools isn't implemented for generate. it's implemented for Client.chat and AsyncClient.chat

options: Optional[Options] = None,
keep_alive: Optional[Union[float, str]] = None,
) -> Mapping[str, Any]: ...
Expand All @@ -125,6 +126,7 @@ def generate(
raw: bool = False,
format: Literal['', 'json'] = '',
images: Optional[Sequence[AnyStr]] = None,
tools: Optional[Sequence[Any]] = None,
options: Optional[Options] = None,
keep_alive: Optional[Union[float, str]] = None,
) -> Iterator[Mapping[str, Any]]: ...
Expand All @@ -140,6 +142,7 @@ def generate(
raw: bool = False,
format: Literal['', 'json'] = '',
images: Optional[Sequence[AnyStr]] = None,
tools: Optional[Sequence[Any]] = None,
options: Optional[Options] = None,
keep_alive: Optional[Union[float, str]] = None,
) -> Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]:
Expand Down Expand Up @@ -168,6 +171,7 @@ def generate(
'stream': stream,
'raw': raw,
'images': [_encode_image(image) for image in images or []],
'tools': tools or [],
'format': format,
'options': options or {},
'keep_alive': keep_alive,
Expand Down
2 changes: 2 additions & 0 deletions ollama/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class GenerateResponse(BaseGenerateResponse):
context: Sequence[int]
'Tokenized history up to the point of the response.'

tool_calls: Sequence[Any]
'List of tool calls made by the model.'

class Message(TypedDict):
"""
Expand Down
Loading