Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,21 @@ def add_two_numbers(a: int, b: int) -> int:

Returns `ChatResponse` if `stream` is `False`, otherwise returns a `ChatResponse` generator.
"""
request_data = ChatRequest(
model=model,
messages=[message for message in _copy_messages(messages)],
tools=[tool for tool in _copy_tools(tools)],
stream=stream,
format=format,
options=options,
keep_alive=keep_alive,
).model_dump(exclude_none=True)
print('Sending chat request to Ollama API:', request_data)
return self._request(
ChatResponse,
'POST',
'/api/chat',
json=ChatRequest(
model=model,
messages=[message for message in _copy_messages(messages)],
tools=[tool for tool in _copy_tools(tools)],
stream=stream,
format=format,
options=options,
keep_alive=keep_alive,
).model_dump(exclude_none=True),
json=request_data,
stream=stream,
)

Expand Down
2 changes: 1 addition & 1 deletion ollama/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Parameters(SubscriptableBaseModel):
class Property(SubscriptableBaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)

type: Optional[str] = None
type: Optional[Union[str, Sequence[str]]] = None
description: Optional[str] = None

properties: Optional[Mapping[str, Property]] = None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def func2(y: str) -> int:
'description': 'Test function',
'parameters': {
'type': 'object',
'properties': {'x': {'type': 'string', 'description': 'A string'}},
'properties': {'x': {'type': 'string', 'description': 'A string', 'enum': ['a', 'b', 'c']}, 'y': {'type': ['integer', 'number'], 'description': 'An integer'}},
'required': ['x'],
},
},
Expand Down