From cfc1dc2c434d303b6ab00d218a3cd23a78f96187 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 21 Dec 2023 16:48:15 -0800 Subject: [PATCH] fix api calls --- ollama/_client.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ollama/_client.py b/ollama/_client.py index d0fa30f..26c4202 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -122,7 +122,7 @@ def pull( 'POST', '/api/pull', json={ - 'model': model, + 'name': model, 'insecure': insecure, 'stream': stream, }, @@ -139,7 +139,7 @@ def push( 'POST', '/api/push', json={ - 'model': model, + 'name': model, 'insecure': insecure, 'stream': stream, }, @@ -164,7 +164,7 @@ def create( 'POST', '/api/create', json={ - 'model': model, + 'name': model, 'modelfile': modelfile, 'stream': stream, }, @@ -208,7 +208,7 @@ def _create_blob(self, path: Union[str, Path]) -> str: return digest def delete(self, model: str) -> Mapping[str, Any]: - response = self._request('DELETE', '/api/delete', json={'model': model}) + response = self._request('DELETE', '/api/delete', json={'name': model}) return {'status': 'success' if response.status_code == 200 else 'error'} def list(self) -> Mapping[str, Any]: @@ -219,7 +219,7 @@ def copy(self, source: str, target: str) -> Mapping[str, Any]: return {'status': 'success' if response.status_code == 200 else 'error'} def show(self, model: str) -> Mapping[str, Any]: - return self._request_json('GET', '/api/show', json={'model': model}) + return self._request_json('GET', '/api/show', json={'name': model}) class AsyncClient(BaseClient): @@ -325,7 +325,7 @@ async def pull( 'POST', '/api/pull', json={ - 'model': model, + 'name': model, 'insecure': insecure, 'stream': stream, }, @@ -342,7 +342,7 @@ async def push( 'POST', '/api/push', json={ - 'model': model, + 'name': model, 'insecure': insecure, 'stream': stream, }, @@ -367,7 +367,7 @@ async def create( 'POST', '/api/create', json={ - 'model': model, + 'name': model, 'modelfile': modelfile, 'stream': stream, }, @@ -418,7 +418,7 @@ async def upload_bytes(): return digest async def delete(self, model: str) -> Mapping[str, Any]: - response = await self._request('DELETE', '/api/delete', json={'model': model}) + response = await self._request('DELETE', '/api/delete', json={'name': model}) return {'status': 'success' if response.status_code == 200 else 'error'} async def list(self) -> Mapping[str, Any]: @@ -430,7 +430,7 @@ async def copy(self, source: str, target: str) -> Mapping[str, Any]: return {'status': 'success' if response.status_code == 200 else 'error'} async def show(self, model: str) -> Mapping[str, Any]: - return await self._request_json('GET', '/api/show', json={'model': model}) + return await self._request_json('GET', '/api/show', json={'name': model}) def _encode_image(image) -> str: