diff --git a/ollama/_client.py b/ollama/_client.py index d3b2a4a..1ac5372 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -7,7 +7,7 @@ from pathlib import Path from hashlib import sha256 from base64 import b64encode -from typing import Any, AnyStr, Union, Optional, Sequence, Mapping +from typing import Any, AnyStr, Union, Optional, Sequence, Mapping, Literal import sys @@ -81,7 +81,7 @@ class Client(BaseClient): context: Optional[Sequence[int]] = None, stream: bool = False, raw: bool = False, - format: str = '', + format: Literal['', 'json'] = '', images: Optional[Sequence[AnyStr]] = None, options: Optional[Options] = None, ) -> Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]: @@ -121,7 +121,7 @@ class Client(BaseClient): model: str = '', messages: Optional[Sequence[Message]] = None, stream: bool = False, - format: str = '', + format: Literal['', 'json'] = '', options: Optional[Options] = None, ) -> Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]: """ @@ -338,7 +338,7 @@ class AsyncClient(BaseClient): context: Optional[Sequence[int]] = None, stream: bool = False, raw: bool = False, - format: str = '', + format: Literal['', 'json'] = '', images: Optional[Sequence[AnyStr]] = None, options: Optional[Options] = None, ) -> Union[Mapping[str, Any], AsyncIterator[Mapping[str, Any]]]: @@ -377,7 +377,7 @@ class AsyncClient(BaseClient): model: str = '', messages: Optional[Sequence[Message]] = None, stream: bool = False, - format: str = '', + format: Literal['', 'json'] = '', options: Optional[Options] = None, ) -> Union[Mapping[str, Any], AsyncIterator[Mapping[str, Any]]]: """ diff --git a/ollama/_types.py b/ollama/_types.py index 226626e..8258825 100644 --- a/ollama/_types.py +++ b/ollama/_types.py @@ -1,4 +1,4 @@ -from typing import Any, TypedDict, Sequence +from typing import Any, TypedDict, Sequence, Literal import sys @@ -27,7 +27,8 @@ class GenerateResponse(BaseGenerateResponse): class Message(TypedDict): - role: str + role: Literal['user', 'assistant', 'system'] + content: str images: NotRequired[Sequence[Any]]