Skip to content

Commit fc60bd7

Browse files
authored
Merge pull request #8 from jmorganca/brucemacd/remote-create
fix: remote create new file
2 parents e0ee198 + e3733a2 commit fc60bd7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

ollama/_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def _parse_modelfile(self, modelfile: str, base: Optional[Path] = None) -> str:
262262
for line in io.StringIO(modelfile):
263263
command, _, args = line.partition(' ')
264264
if command.upper() in ['FROM', 'ADAPTER']:
265-
path = Path(args).expanduser()
265+
path = Path(args.strip()).expanduser()
266266
path = path if path.is_absolute() else base / path
267267
if path.exists():
268268
args = f'@{self._create_blob(path)}'
@@ -288,7 +288,7 @@ def _create_blob(self, path: Union[str, Path]) -> str:
288288
raise
289289

290290
with open(path, 'rb') as r:
291-
self._request('PUT', f'/api/blobs/{digest}', content=r)
291+
self._request('POST', f'/api/blobs/{digest}', content=r)
292292

293293
return digest
294294

@@ -563,7 +563,7 @@ async def upload_bytes():
563563
break
564564
yield chunk
565565

566-
await self._request('PUT', f'/api/blobs/{digest}', content=upload_bytes())
566+
await self._request('POST', f'/api/blobs/{digest}', content=upload_bytes())
567567

568568
return digest
569569

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def test_client_create_from_library(httpserver: HTTPServer):
418418

419419
def test_client_create_blob(httpserver: HTTPServer):
420420
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='HEAD').respond_with_response(Response(status=404))
421-
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='PUT').respond_with_response(Response(status=201))
421+
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='POST').respond_with_response(Response(status=201))
422422

423423
client = Client(httpserver.url_for('/'))
424424

@@ -759,7 +759,7 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
759759
@pytest.mark.asyncio
760760
async def test_async_client_create_blob(httpserver: HTTPServer):
761761
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='HEAD').respond_with_response(Response(status=404))
762-
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='PUT').respond_with_response(Response(status=201))
762+
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='POST').respond_with_response(Response(status=201))
763763

764764
client = AsyncClient(httpserver.url_for('/'))
765765

0 commit comments

Comments
 (0)