diff --git a/ollama/_client.py b/ollama/_client.py index be3bd5c..7958adb 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -559,12 +559,12 @@ def _parse_modelfile(self, modelfile: str, base: Optional[Path] = None) -> str: path = Path(args.strip()).expanduser() path = path if path.is_absolute() else base / path if path.exists(): - args = f'@{self._create_blob(path)}\n' + args = f'@{self.create_blob(path)}\n' print(command, args, end='', file=out) return out.getvalue() - def _create_blob(self, path: Union[str, Path]) -> str: + def create_blob(self, path: Union[str, Path]) -> str: sha256sum = sha256() with open(path, 'rb') as r: while True: @@ -1061,12 +1061,12 @@ async def _parse_modelfile(self, modelfile: str, base: Optional[Path] = None) -> path = Path(args.strip()).expanduser() path = path if path.is_absolute() else base / path if path.exists(): - args = f'@{await self._create_blob(path)}\n' + args = f'@{await self.create_blob(path)}\n' print(command, args, end='', file=out) return out.getvalue() - async def _create_blob(self, path: Union[str, Path]) -> str: + async def create_blob(self, path: Union[str, Path]) -> str: sha256sum = sha256() with open(path, 'rb') as r: while True: diff --git a/tests/test_client.py b/tests/test_client.py index 7ef2aa8..8085cf7 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -622,7 +622,7 @@ def test_client_create_blob(httpserver: HTTPServer): client = Client(httpserver.url_for('/')) with tempfile.NamedTemporaryFile() as blob: - response = client._create_blob(blob.name) + response = client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -632,7 +632,7 @@ def test_client_create_blob_exists(httpserver: HTTPServer): client = Client(httpserver.url_for('/')) with tempfile.NamedTemporaryFile() as blob: - response = client._create_blob(blob.name) + response = client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -1098,7 +1098,7 @@ async def test_async_client_create_blob(httpserver: HTTPServer): client = AsyncClient(httpserver.url_for('/')) with tempfile.NamedTemporaryFile() as blob: - response = await client._create_blob(blob.name) + response = await client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -1109,7 +1109,7 @@ async def test_async_client_create_blob_exists(httpserver: HTTPServer): client = AsyncClient(httpserver.url_for('/')) with tempfile.NamedTemporaryFile() as blob: - response = await client._create_blob(blob.name) + response = await client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'