Python API PS (#177)

* Python API PS

* PS Rename

* Readme
This commit is contained in:
royjhan
2024-06-05 11:12:32 -07:00
committed by GitHub
parent 14d7f8c1b7
commit d5316d023a
3 changed files with 15 additions and 0 deletions
+6
View File
@@ -125,6 +125,12 @@ ollama.push('user/llama3')
ollama.embeddings(model='llama3', prompt='The sky is blue because of rayleigh scattering')
```
### Ps
```python
ollama.ps()
```
## Custom client
A custom client can be created with the following fields:
+2
View File
@@ -29,6 +29,7 @@ __all__ = [
'list',
'copy',
'show',
'ps',
]
_client = Client()
@@ -43,3 +44,4 @@ delete = _client.delete
list = _client.list
copy = _client.copy
show = _client.show
ps = _client.ps
+7
View File
@@ -336,6 +336,9 @@ class Client(BaseClient):
def show(self, model: str) -> Mapping[str, Any]:
return self._request('POST', '/api/show', json={'name': model}).json()
def ps(self) -> Mapping[str, Any]:
return self._request('GET', '/api/ps').json()
class AsyncClient(BaseClient):
def __init__(self, host: Optional[str] = None, **kwargs) -> None:
@@ -629,6 +632,10 @@ class AsyncClient(BaseClient):
response = await self._request('POST', '/api/show', json={'name': model})
return response.json()
async def ps(self) -> Mapping[str, Any]:
response = await self._request('GET', '/api/ps')
return response.json()
def _encode_image(image) -> str:
"""