mirror of
https://github.com/ollama/ollama-python.git
synced 2026-06-17 05:34:44 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a60f07e28 | |||
| 27e2ef1161 | |||
| 53b10f7c00 | |||
| 582839f24f | |||
| fc60bd74e9 | |||
| e3733a235d | |||
| b232a6c04d | |||
| e0ee198195 | |||
| 99df3c3a07 |
@@ -22,6 +22,6 @@ jobs:
|
||||
poetry version ${GITHUB_REF_NAME#v}
|
||||
poetry build
|
||||
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||
- run: gh release upload $GIT_REF_NAME dist/*
|
||||
- run: gh release upload $GITHUB_REF_NAME dist/*
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
+9
-9
@@ -262,7 +262,7 @@ class Client(BaseClient):
|
||||
for line in io.StringIO(modelfile):
|
||||
command, _, args = line.partition(' ')
|
||||
if command.upper() in ['FROM', 'ADAPTER']:
|
||||
path = Path(args).expanduser()
|
||||
path = Path(args.strip()).expanduser()
|
||||
path = path if path.is_absolute() else base / path
|
||||
if path.exists():
|
||||
args = f'@{self._create_blob(path)}'
|
||||
@@ -288,7 +288,7 @@ class Client(BaseClient):
|
||||
raise
|
||||
|
||||
with open(path, 'rb') as r:
|
||||
self._request('PUT', f'/api/blobs/{digest}', content=r)
|
||||
self._request('POST', f'/api/blobs/{digest}', content=r)
|
||||
|
||||
return digest
|
||||
|
||||
@@ -299,12 +299,12 @@ class Client(BaseClient):
|
||||
def list(self) -> Mapping[str, Any]:
|
||||
return self._request('GET', '/api/tags').json()
|
||||
|
||||
def copy(self, source: str, target: str) -> Mapping[str, Any]:
|
||||
response = self._request('POST', '/api/copy', json={'source': source, 'destination': target})
|
||||
def copy(self, source: str, destination: str) -> Mapping[str, Any]:
|
||||
response = self._request('POST', '/api/copy', json={'source': source, 'destination': destination})
|
||||
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||
|
||||
def show(self, model: str) -> Mapping[str, Any]:
|
||||
return self._request('GET', '/api/show', json={'name': model}).json()
|
||||
return self._request('POST', '/api/show', json={'name': model}).json()
|
||||
|
||||
|
||||
class AsyncClient(BaseClient):
|
||||
@@ -563,7 +563,7 @@ class AsyncClient(BaseClient):
|
||||
break
|
||||
yield chunk
|
||||
|
||||
await self._request('PUT', f'/api/blobs/{digest}', content=upload_bytes())
|
||||
await self._request('POST', f'/api/blobs/{digest}', content=upload_bytes())
|
||||
|
||||
return digest
|
||||
|
||||
@@ -575,12 +575,12 @@ class AsyncClient(BaseClient):
|
||||
response = await self._request('GET', '/api/tags')
|
||||
return response.json()
|
||||
|
||||
async def copy(self, source: str, target: str) -> Mapping[str, Any]:
|
||||
response = await self._request('POST', '/api/copy', json={'source': source, 'destination': target})
|
||||
async def copy(self, source: str, destination: str) -> Mapping[str, Any]:
|
||||
response = await self._request('POST', '/api/copy', json={'source': source, 'destination': destination})
|
||||
return {'status': 'success' if response.status_code == 200 else 'error'}
|
||||
|
||||
async def show(self, model: str) -> Mapping[str, Any]:
|
||||
response = await self._request('GET', '/api/show', json={'name': model})
|
||||
response = await self._request('POST', '/api/show', json={'name': model})
|
||||
return response.json()
|
||||
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ def test_client_create_from_library(httpserver: HTTPServer):
|
||||
|
||||
def test_client_create_blob(httpserver: HTTPServer):
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='HEAD').respond_with_response(Response(status=404))
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='PUT').respond_with_response(Response(status=201))
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='POST').respond_with_response(Response(status=201))
|
||||
|
||||
client = Client(httpserver.url_for('/'))
|
||||
|
||||
@@ -759,7 +759,7 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_client_create_blob(httpserver: HTTPServer):
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='HEAD').respond_with_response(Response(status=404))
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='PUT').respond_with_response(Response(status=201))
|
||||
httpserver.expect_ordered_request(PrefixPattern('/api/blobs/'), method='POST').respond_with_response(Response(status=201))
|
||||
|
||||
client = AsyncClient(httpserver.url_for('/'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user