From 1066246ab5d9860e4732632b5ac802e32ba533e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Sat, 7 Dec 2024 19:37:55 -0800 Subject: [PATCH] fix validation of format field to allow empty strings as it did previously (#369) --- ollama/_client.py | 12 ++++++------ ollama/_types.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ollama/_client.py b/ollama/_client.py index 2ca4513..87fa881 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -188,7 +188,7 @@ def generate( context: Optional[Sequence[int]] = None, stream: Literal[False] = False, raw: bool = False, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, images: Optional[Sequence[Union[str, bytes]]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, @@ -206,7 +206,7 @@ def generate( context: Optional[Sequence[int]] = None, stream: Literal[True] = True, raw: bool = False, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, images: Optional[Sequence[Union[str, bytes]]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, @@ -223,7 +223,7 @@ def generate( context: Optional[Sequence[int]] = None, stream: bool = False, raw: Optional[bool] = None, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, images: Optional[Sequence[Union[str, bytes]]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, @@ -267,7 +267,7 @@ def chat( *, tools: Optional[Sequence[Union[Mapping[str, Any], Tool, Callable]]] = None, stream: Literal[False] = False, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, ) -> ChatResponse: ... @@ -280,7 +280,7 @@ def chat( *, tools: Optional[Sequence[Union[Mapping[str, Any], Tool, Callable]]] = None, stream: Literal[True] = True, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, ) -> Iterator[ChatResponse]: ... @@ -292,7 +292,7 @@ def chat( *, tools: Optional[Sequence[Union[Mapping[str, Any], Tool, Callable]]] = None, stream: bool = False, - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None, + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None, options: Optional[Union[Mapping[str, Any], Options]] = None, keep_alive: Optional[Union[float, str]] = None, ) -> Union[ChatResponse, Iterator[ChatResponse]]: diff --git a/ollama/_types.py b/ollama/_types.py index 11a0a59..3be80a7 100644 --- a/ollama/_types.py +++ b/ollama/_types.py @@ -151,7 +151,7 @@ class BaseGenerateRequest(BaseStreamableRequest): options: Optional[Union[Mapping[str, Any], Options]] = None 'Options to use for the request.' - format: Optional[Union[Literal['json'], JsonSchemaValue]] = None + format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None 'Format of the response.' keep_alive: Optional[Union[float, str]] = None