mirror of
https://github.com/ollama/ollama-python.git
synced 2026-05-01 11:48:17 +08:00
Merge 5ecfaab50a into dbccf192ac
This commit is contained in:
commit
da101a1343
@ -1,44 +1,49 @@
|
||||
from importlib.metadata import version as _pkg_version
|
||||
from ollama._client import AsyncClient, Client
|
||||
from ollama._types import (
|
||||
ChatResponse,
|
||||
EmbeddingsResponse,
|
||||
EmbedResponse,
|
||||
GenerateResponse,
|
||||
Image,
|
||||
ListResponse,
|
||||
Message,
|
||||
Options,
|
||||
ProcessResponse,
|
||||
ProgressResponse,
|
||||
RequestError,
|
||||
ResponseError,
|
||||
ShowResponse,
|
||||
StatusResponse,
|
||||
Tool,
|
||||
WebFetchResponse,
|
||||
WebSearchResponse,
|
||||
ChatResponse,
|
||||
EmbeddingsResponse,
|
||||
EmbedResponse,
|
||||
GenerateResponse,
|
||||
Image,
|
||||
ListResponse,
|
||||
Message,
|
||||
Options,
|
||||
ProcessResponse,
|
||||
ProgressResponse,
|
||||
RequestError,
|
||||
ResponseError,
|
||||
ShowResponse,
|
||||
StatusResponse,
|
||||
Tool,
|
||||
WebFetchResponse,
|
||||
WebSearchResponse,
|
||||
)
|
||||
|
||||
__version__ = _pkg_version('ollama')
|
||||
|
||||
__all__ = [
|
||||
'AsyncClient',
|
||||
'ChatResponse',
|
||||
'Client',
|
||||
'EmbedResponse',
|
||||
'EmbeddingsResponse',
|
||||
'GenerateResponse',
|
||||
'Image',
|
||||
'ListResponse',
|
||||
'Message',
|
||||
'Options',
|
||||
'ProcessResponse',
|
||||
'ProgressResponse',
|
||||
'RequestError',
|
||||
'ResponseError',
|
||||
'ShowResponse',
|
||||
'StatusResponse',
|
||||
'Tool',
|
||||
'WebFetchResponse',
|
||||
'WebSearchResponse',
|
||||
'AsyncClient',
|
||||
'ChatResponse',
|
||||
'Client',
|
||||
'EmbedResponse',
|
||||
'EmbeddingsResponse',
|
||||
'GenerateResponse',
|
||||
'Image',
|
||||
'ListResponse',
|
||||
'Message',
|
||||
'Options',
|
||||
'ProcessResponse',
|
||||
'ProgressResponse',
|
||||
'RequestError',
|
||||
'ResponseError',
|
||||
'ShowResponse',
|
||||
'StatusResponse',
|
||||
'Tool',
|
||||
'WebFetchResponse',
|
||||
'WebSearchResponse',
|
||||
'__version__',
|
||||
'version',
|
||||
]
|
||||
|
||||
_client = Client()
|
||||
@ -52,8 +57,7 @@ push = _client.push
|
||||
create = _client.create
|
||||
delete = _client.delete
|
||||
list = _client.list
|
||||
copy = _client.copy
|
||||
show = _client.show
|
||||
copy = _client.copy
|
||||
ps = _client.ps
|
||||
web_search = _client.web_search
|
||||
web_fetch = _client.web_fetch
|
||||
version = _client.version # Expose the version method for users to check the Ollama version
|
||||
|
||||
@ -670,6 +670,9 @@ class Client(BaseClient):
|
||||
'GET',
|
||||
'/api/ps',
|
||||
)
|
||||
def version(self) -> str:
|
||||
response = self._request_raw('GET', '/api/version')
|
||||
return response.json().get('version', '')
|
||||
|
||||
def web_search(self, query: str, max_results: int = 3) -> WebSearchResponse:
|
||||
"""
|
||||
@ -1311,6 +1314,9 @@ class AsyncClient(BaseClient):
|
||||
'GET',
|
||||
'/api/ps',
|
||||
)
|
||||
async def version(self) -> str:
|
||||
response = await self._request_raw('GET', '/api/version')
|
||||
return response.json().get('version', '')
|
||||
|
||||
|
||||
def _copy_images(images: Optional[Sequence[Union[Image, Any]]]) -> Iterator[Image]:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user