From e44b04b039c4a3b0950cf7e22bb2c11d0fdb5aa4 Mon Sep 17 00:00:00 2001 From: nguu0123 Date: Thu, 12 Dec 2024 21:01:39 +0200 Subject: [PATCH 1/2] update /api/delete to use POST method instead of DELETE --- ollama/_client.py | 2 +- tests/test_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ollama/_client.py b/ollama/_client.py index 87fa881..faa6666 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -571,7 +571,7 @@ def list(self) -> ListResponse: def delete(self, model: str) -> StatusResponse: r = self._request_raw( - 'DELETE', + 'POST', '/api/delete', json=DeleteRequest( model=model, diff --git a/tests/test_client.py b/tests/test_client.py index aab2f2e..d1bbd59 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -700,7 +700,7 @@ def test_client_create_blob_exists(httpserver: HTTPServer): def test_client_delete(httpserver: HTTPServer): - httpserver.expect_ordered_request(PrefixPattern('/api/delete'), method='DELETE').respond_with_response(Response(status=200)) + httpserver.expect_ordered_request(PrefixPattern('/api/delete'), method='POST').respond_with_response(Response(status=200)) client = Client(httpserver.url_for('/api/delete')) response = client.delete('dummy') assert response['status'] == 'success' From d129151a130f77265230af0d8b1dcee21db1e460 Mon Sep 17 00:00:00 2001 From: nguu0123 Date: Thu, 12 Dec 2024 21:12:46 +0200 Subject: [PATCH 2/2] update the async client --- ollama/_client.py | 2 +- tests/test_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ollama/_client.py b/ollama/_client.py index faa6666..7ea345b 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -1080,7 +1080,7 @@ async def list(self) -> ListResponse: async def delete(self, model: str) -> StatusResponse: r = await self._request_raw( - 'DELETE', + 'POST', '/api/delete', json=DeleteRequest( model=model, diff --git a/tests/test_client.py b/tests/test_client.py index d1bbd59..c2bd036 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1179,7 +1179,7 @@ async def test_async_client_create_blob_exists(httpserver: HTTPServer): @pytest.mark.asyncio async def test_async_client_delete(httpserver: HTTPServer): - httpserver.expect_ordered_request(PrefixPattern('/api/delete'), method='DELETE').respond_with_response(Response(status=200)) + httpserver.expect_ordered_request(PrefixPattern('/api/delete'), method='POST').respond_with_response(Response(status=200)) client = AsyncClient(httpserver.url_for('/api/delete')) response = await client.delete('dummy') assert response['status'] == 'success'