mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +08:00
fix api calls
This commit is contained in:
parent
187bd29b0e
commit
de61864358
@ -122,7 +122,7 @@ class Client(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/pull',
|
'/api/pull',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'insecure': insecure,
|
'insecure': insecure,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -139,7 +139,7 @@ class Client(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/push',
|
'/api/push',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'insecure': insecure,
|
'insecure': insecure,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -164,7 +164,7 @@ class Client(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/create',
|
'/api/create',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'modelfile': modelfile,
|
'modelfile': modelfile,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -208,7 +208,7 @@ class Client(BaseClient):
|
|||||||
return digest
|
return digest
|
||||||
|
|
||||||
def delete(self, model: str) -> Mapping[str, Any]:
|
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'}
|
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||||
|
|
||||||
def list(self) -> Mapping[str, Any]:
|
def list(self) -> Mapping[str, Any]:
|
||||||
@ -219,7 +219,7 @@ class Client(BaseClient):
|
|||||||
return {'status': 'success' if response.status_code == 200 else 'error'}
|
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||||
|
|
||||||
def show(self, model: str) -> Mapping[str, Any]:
|
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):
|
class AsyncClient(BaseClient):
|
||||||
@ -325,7 +325,7 @@ class AsyncClient(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/pull',
|
'/api/pull',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'insecure': insecure,
|
'insecure': insecure,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -342,7 +342,7 @@ class AsyncClient(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/push',
|
'/api/push',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'insecure': insecure,
|
'insecure': insecure,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -367,7 +367,7 @@ class AsyncClient(BaseClient):
|
|||||||
'POST',
|
'POST',
|
||||||
'/api/create',
|
'/api/create',
|
||||||
json={
|
json={
|
||||||
'model': model,
|
'name': model,
|
||||||
'modelfile': modelfile,
|
'modelfile': modelfile,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
},
|
},
|
||||||
@ -418,7 +418,7 @@ class AsyncClient(BaseClient):
|
|||||||
return digest
|
return digest
|
||||||
|
|
||||||
async def delete(self, model: str) -> Mapping[str, Any]:
|
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'}
|
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||||
|
|
||||||
async def list(self) -> Mapping[str, Any]:
|
async def list(self) -> Mapping[str, Any]:
|
||||||
@ -430,7 +430,7 @@ class AsyncClient(BaseClient):
|
|||||||
return {'status': 'success' if response.status_code == 200 else 'error'}
|
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||||
|
|
||||||
async def show(self, model: str) -> Mapping[str, Any]:
|
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:
|
def _encode_image(image) -> str:
|
||||||
|
|||||||
@ -229,7 +229,7 @@ def test_client_pull(httpserver: HTTPServer):
|
|||||||
'/api/pull',
|
'/api/pull',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -259,7 +259,7 @@ def test_client_pull_stream(httpserver: HTTPServer):
|
|||||||
'/api/pull',
|
'/api/pull',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': True,
|
'stream': True,
|
||||||
},
|
},
|
||||||
@ -275,7 +275,7 @@ def test_client_push(httpserver: HTTPServer):
|
|||||||
'/api/push',
|
'/api/push',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -291,7 +291,7 @@ def test_client_push_stream(httpserver: HTTPServer):
|
|||||||
'/api/push',
|
'/api/push',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': True,
|
'stream': True,
|
||||||
},
|
},
|
||||||
@ -308,7 +308,7 @@ def test_client_create_path(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -331,7 +331,7 @@ def test_client_create_path_relative(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -363,7 +363,7 @@ def test_client_create_path_user_home(httpserver: HTTPServer, userhomedir):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -386,7 +386,7 @@ def test_client_create_modelfile(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -404,7 +404,7 @@ def test_client_create_from_library(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM llama2\n',
|
'modelfile': 'FROM llama2\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -584,7 +584,7 @@ async def test_async_client_pull(httpserver: HTTPServer):
|
|||||||
'/api/pull',
|
'/api/pull',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -601,7 +601,7 @@ async def test_async_client_pull_stream(httpserver: HTTPServer):
|
|||||||
'/api/pull',
|
'/api/pull',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': True,
|
'stream': True,
|
||||||
},
|
},
|
||||||
@ -618,7 +618,7 @@ async def test_async_client_push(httpserver: HTTPServer):
|
|||||||
'/api/push',
|
'/api/push',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -635,7 +635,7 @@ async def test_async_client_push_stream(httpserver: HTTPServer):
|
|||||||
'/api/push',
|
'/api/push',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'insecure': False,
|
'insecure': False,
|
||||||
'stream': True,
|
'stream': True,
|
||||||
},
|
},
|
||||||
@ -653,7 +653,7 @@ async def test_async_client_create_path(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -677,7 +677,7 @@ async def test_async_client_create_path_relative(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -701,7 +701,7 @@ async def test_async_client_create_path_user_home(httpserver: HTTPServer, userho
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -725,7 +725,7 @@ async def test_async_client_create_modelfile(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
@ -744,7 +744,7 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
|
|||||||
'/api/create',
|
'/api/create',
|
||||||
method='POST',
|
method='POST',
|
||||||
json={
|
json={
|
||||||
'model': 'dummy',
|
'name': 'dummy',
|
||||||
'modelfile': 'FROM llama2\n',
|
'modelfile': 'FROM llama2\n',
|
||||||
'stream': False,
|
'stream': False,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user