fix api calls

This commit is contained in:
Michael Yang 2023-12-21 16:48:15 -08:00
parent 187bd29b0e
commit de61864358
2 changed files with 28 additions and 28 deletions

View File

@ -122,7 +122,7 @@ class Client(BaseClient):
'POST',
'/api/pull',
json={
'model': model,
'name': model,
'insecure': insecure,
'stream': stream,
},
@ -139,7 +139,7 @@ class Client(BaseClient):
'POST',
'/api/push',
json={
'model': model,
'name': model,
'insecure': insecure,
'stream': stream,
},
@ -164,7 +164,7 @@ class Client(BaseClient):
'POST',
'/api/create',
json={
'model': model,
'name': model,
'modelfile': modelfile,
'stream': stream,
},
@ -208,7 +208,7 @@ class Client(BaseClient):
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 @@ class Client(BaseClient):
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 @@ class AsyncClient(BaseClient):
'POST',
'/api/pull',
json={
'model': model,
'name': model,
'insecure': insecure,
'stream': stream,
},
@ -342,7 +342,7 @@ class AsyncClient(BaseClient):
'POST',
'/api/push',
json={
'model': model,
'name': model,
'insecure': insecure,
'stream': stream,
},
@ -367,7 +367,7 @@ class AsyncClient(BaseClient):
'POST',
'/api/create',
json={
'model': model,
'name': model,
'modelfile': modelfile,
'stream': stream,
},
@ -418,7 +418,7 @@ class AsyncClient(BaseClient):
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 @@ class AsyncClient(BaseClient):
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:

View File

@ -229,7 +229,7 @@ def test_client_pull(httpserver: HTTPServer):
'/api/pull',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': False,
},
@ -259,7 +259,7 @@ def test_client_pull_stream(httpserver: HTTPServer):
'/api/pull',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': True,
},
@ -275,7 +275,7 @@ def test_client_push(httpserver: HTTPServer):
'/api/push',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': False,
},
@ -291,7 +291,7 @@ def test_client_push_stream(httpserver: HTTPServer):
'/api/push',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': True,
},
@ -308,7 +308,7 @@ def test_client_create_path(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -331,7 +331,7 @@ def test_client_create_path_relative(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -363,7 +363,7 @@ def test_client_create_path_user_home(httpserver: HTTPServer, userhomedir):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -386,7 +386,7 @@ def test_client_create_modelfile(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -404,7 +404,7 @@ def test_client_create_from_library(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM llama2\n',
'stream': False,
},
@ -584,7 +584,7 @@ async def test_async_client_pull(httpserver: HTTPServer):
'/api/pull',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': False,
},
@ -601,7 +601,7 @@ async def test_async_client_pull_stream(httpserver: HTTPServer):
'/api/pull',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': True,
},
@ -618,7 +618,7 @@ async def test_async_client_push(httpserver: HTTPServer):
'/api/push',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': False,
},
@ -635,7 +635,7 @@ async def test_async_client_push_stream(httpserver: HTTPServer):
'/api/push',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'insecure': False,
'stream': True,
},
@ -653,7 +653,7 @@ async def test_async_client_create_path(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -677,7 +677,7 @@ async def test_async_client_create_path_relative(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -701,7 +701,7 @@ async def test_async_client_create_path_user_home(httpserver: HTTPServer, userho
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -725,7 +725,7 @@ async def test_async_client_create_modelfile(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
},
@ -744,7 +744,7 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
'/api/create',
method='POST',
json={
'model': 'dummy',
'name': 'dummy',
'modelfile': 'FROM llama2\n',
'stream': False,
},