Skip to content
Open
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
8 changes: 8 additions & 0 deletions ollama/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ollama._client import AsyncClient, Client
from importlib.metadata import version, PackageNotFoundError
from ollama._types import (
ChatResponse,
EmbeddingsResponse,
Expand Down Expand Up @@ -57,3 +58,10 @@
ps = _client.ps
web_search = _client.web_search
web_fetch = _client.web_fetch
exists = _client.exists


try:
__version__ = version("ollama")
except PackageNotFoundError:
__version__ = "unknown"
6 changes: 6 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,12 @@ def ps(self) -> ProcessResponse:
'GET',
'/api/ps',
)
def exists(self, model: str) -> bool:
try:
self.show(model)
return True
except Exception:
return False

def web_search(self, query: str, max_results: int = 3) -> WebSearchResponse:
"""
Expand Down