Skip to content

Commit

Permalink
Merge pull request #150 from ollama/mxyng/quantization
Browse files Browse the repository at this point in the history
add quantization to create requests
  • Loading branch information
mxyng authored May 10, 2024
2 parents 3b69774 + 309007d commit 5dc857e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def create(
model: str,
path: Optional[Union[str, PathLike]] = None,
modelfile: Optional[str] = None,
quantize: Optional[str] = None,
stream: bool = False,
) -> Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]:
"""
Expand All @@ -276,6 +277,7 @@ def create(
'name': model,
'modelfile': modelfile,
'stream': stream,
'quantize': quantize,
},
stream=stream,
)
Expand Down Expand Up @@ -537,6 +539,7 @@ async def create(
model: str,
path: Optional[Union[str, PathLike]] = None,
modelfile: Optional[str] = None,
quantize: Optional[str] = None,
stream: bool = False,
) -> Union[Mapping[str, Any], AsyncIterator[Mapping[str, Any]]]:
"""
Expand All @@ -558,6 +561,7 @@ async def create(
'name': model,
'modelfile': modelfile,
'stream': stream,
'quantize': quantize,
},
stream=stream,
)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def test_client_create_path(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand All @@ -357,6 +358,7 @@ def test_client_create_path_relative(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -389,6 +391,7 @@ def test_client_create_path_user_home(httpserver: HTTPServer, userhomedir):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand All @@ -412,6 +415,7 @@ def test_client_create_modelfile(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -442,6 +446,7 @@ def test_client_create_modelfile_roundtrip(httpserver: HTTPServer):
PARAMETER stop <<SYS>>
PARAMETER stop <</SYS>>''',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -478,6 +483,7 @@ def test_client_create_from_library(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM llama2',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -798,6 +804,7 @@ async def test_async_client_create_path(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand All @@ -822,6 +829,7 @@ async def test_async_client_create_path_relative(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand All @@ -846,6 +854,7 @@ async def test_async_client_create_path_user_home(httpserver: HTTPServer, userho
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand All @@ -870,6 +879,7 @@ async def test_async_client_create_modelfile(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -901,6 +911,7 @@ async def test_async_client_create_modelfile_roundtrip(httpserver: HTTPServer):
PARAMETER stop <<SYS>>
PARAMETER stop <</SYS>>''',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down Expand Up @@ -938,6 +949,7 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
'name': 'dummy',
'modelfile': 'FROM llama2',
'stream': False,
'quantize': None,
},
).respond_with_json({})

Expand Down

0 comments on commit 5dc857e

Please sign in to comment.