@@ -933,117 +933,39 @@ def generate():
933
933
934
934
935
935
@pytest .mark .asyncio
936
- async def test_async_client_create_path (httpserver : HTTPServer ):
937
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
938
- httpserver .expect_ordered_request (
939
- '/api/create' ,
940
- method = 'POST' ,
941
- json = {
942
- 'model' : 'dummy' ,
943
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
944
- 'stream' : False ,
945
- },
946
- ).respond_with_json ({'status' : 'success' })
947
-
948
- client = AsyncClient (httpserver .url_for ('/' ))
949
-
950
- with tempfile .NamedTemporaryFile () as modelfile :
951
- with tempfile .NamedTemporaryFile () as blob :
952
- modelfile .write (f'FROM { blob .name } ' .encode ('utf-8' ))
953
- modelfile .flush ()
954
-
955
- response = await client .create ('dummy' , path = modelfile .name )
956
- assert response ['status' ] == 'success'
957
-
958
-
959
- @pytest .mark .asyncio
960
- async def test_async_client_create_path_relative (httpserver : HTTPServer ):
961
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
936
+ async def test_async_client_create_with_blob (httpserver : HTTPServer ):
962
937
httpserver .expect_ordered_request (
963
938
'/api/create' ,
964
939
method = 'POST' ,
965
940
json = {
966
941
'model' : 'dummy' ,
967
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
968
- 'stream' : False ,
969
- },
970
- ).respond_with_json ({'status' : 'success' })
971
-
972
- client = AsyncClient (httpserver .url_for ('/' ))
973
-
974
- with tempfile .NamedTemporaryFile () as modelfile :
975
- with tempfile .NamedTemporaryFile (dir = Path (modelfile .name ).parent ) as blob :
976
- modelfile .write (f'FROM { Path (blob .name ).name } ' .encode ('utf-8' ))
977
- modelfile .flush ()
978
-
979
- response = await client .create ('dummy' , path = modelfile .name )
980
- assert response ['status' ] == 'success'
981
-
982
-
983
- @pytest .mark .asyncio
984
- async def test_async_client_create_path_user_home (httpserver : HTTPServer , userhomedir ):
985
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
986
- httpserver .expect_ordered_request (
987
- '/api/create' ,
988
- method = 'POST' ,
989
- json = {
990
- 'model' : 'dummy' ,
991
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
992
- 'stream' : False ,
993
- },
994
- ).respond_with_json ({'status' : 'success' })
995
-
996
- client = AsyncClient (httpserver .url_for ('/' ))
997
-
998
- with tempfile .NamedTemporaryFile () as modelfile :
999
- with tempfile .NamedTemporaryFile (dir = userhomedir ) as blob :
1000
- modelfile .write (f'FROM ~/{ Path (blob .name ).name } ' .encode ('utf-8' ))
1001
- modelfile .flush ()
1002
-
1003
- response = await client .create ('dummy' , path = modelfile .name )
1004
- assert response ['status' ] == 'success'
1005
-
1006
-
1007
- @pytest .mark .asyncio
1008
- async def test_async_client_create_modelfile (httpserver : HTTPServer ):
1009
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
1010
- httpserver .expect_ordered_request (
1011
- '/api/create' ,
1012
- method = 'POST' ,
1013
- json = {
1014
- 'model' : 'dummy' ,
1015
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
942
+ 'files' : {'test.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' },
1016
943
'stream' : False ,
1017
944
},
1018
945
).respond_with_json ({'status' : 'success' })
1019
946
1020
947
client = AsyncClient (httpserver .url_for ('/' ))
1021
948
1022
949
with tempfile .NamedTemporaryFile () as blob :
1023
- response = await client .create ('dummy' , modelfile = f'FROM { blob . name } ' )
950
+ response = await client .create ('dummy' , files = { 'test.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' } )
1024
951
assert response ['status' ] == 'success'
1025
952
1026
953
1027
954
@pytest .mark .asyncio
1028
- async def test_async_client_create_modelfile_roundtrip (httpserver : HTTPServer ):
1029
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
955
+ async def test_async_client_create_with_parameters_roundtrip (httpserver : HTTPServer ):
1030
956
httpserver .expect_ordered_request (
1031
957
'/api/create' ,
1032
958
method = 'POST' ,
1033
959
json = {
1034
960
'model' : 'dummy' ,
1035
- 'modelfile' : '''FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
1036
- TEMPLATE """[INST] <<SYS>>{{.System}}<</SYS>>
1037
- {{.Prompt}} [/INST]"""
1038
- SYSTEM """
1039
- Use
1040
- multiline
1041
- strings.
1042
- """
1043
- PARAMETER stop [INST]
1044
- PARAMETER stop [/INST]
1045
- PARAMETER stop <<SYS>>
1046
- PARAMETER stop <</SYS>>''' ,
961
+ 'quantize' : 'q4_k_m' ,
962
+ 'from' : 'mymodel' ,
963
+ 'adapters' : {'someadapter.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' },
964
+ 'template' : '[INST] <<SYS>>{{.System}}<</SYS>>\n {{.Prompt}} [/INST]' ,
965
+ 'license' : 'this is my license' ,
966
+ 'system' : '\n Use\n multiline\n strings.\n ' ,
967
+ 'parameters' : {'stop' : ['[INST]' , '[/INST]' , '<<SYS>>' , '<</SYS>>' ], 'pi' : 3.14159 },
968
+ 'messages' : [{'role' : 'user' , 'content' : 'Hello there!' }, {'role' : 'assistant' , 'content' : 'Hello there yourself!' }],
1047
969
'stream' : False ,
1048
970
},
1049
971
).respond_with_json ({'status' : 'success' })
@@ -1053,22 +975,15 @@ async def test_async_client_create_modelfile_roundtrip(httpserver: HTTPServer):
1053
975
with tempfile .NamedTemporaryFile () as blob :
1054
976
response = await client .create (
1055
977
'dummy' ,
1056
- modelfile = '\n ' .join (
1057
- [
1058
- f'FROM { blob .name } ' ,
1059
- 'TEMPLATE """[INST] <<SYS>>{{.System}}<</SYS>>' ,
1060
- '{{.Prompt}} [/INST]"""' ,
1061
- 'SYSTEM """' ,
1062
- 'Use' ,
1063
- 'multiline' ,
1064
- 'strings.' ,
1065
- '"""' ,
1066
- 'PARAMETER stop [INST]' ,
1067
- 'PARAMETER stop [/INST]' ,
1068
- 'PARAMETER stop <<SYS>>' ,
1069
- 'PARAMETER stop <</SYS>>' ,
1070
- ]
1071
- ),
978
+ quantize = 'q4_k_m' ,
979
+ from_ = 'mymodel' ,
980
+ adapters = {'someadapter.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' },
981
+ template = '[INST] <<SYS>>{{.System}}<</SYS>>\n {{.Prompt}} [/INST]' ,
982
+ license = 'this is my license' ,
983
+ system = '\n Use\n multiline\n strings.\n ' ,
984
+ parameters = {'stop' : ['[INST]' , '[/INST]' , '<<SYS>>' , '<</SYS>>' ], 'pi' : 3.14159 },
985
+ messages = [{'role' : 'user' , 'content' : 'Hello there!' }, {'role' : 'assistant' , 'content' : 'Hello there yourself!' }],
986
+ stream = False ,
1072
987
)
1073
988
assert response ['status' ] == 'success'
1074
989
@@ -1080,14 +995,14 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
1080
995
method = 'POST' ,
1081
996
json = {
1082
997
'model' : 'dummy' ,
1083
- 'modelfile ' : 'FROM llama2' ,
998
+ 'from ' : 'llama2' ,
1084
999
'stream' : False ,
1085
1000
},
1086
1001
).respond_with_json ({'status' : 'success' })
1087
1002
1088
1003
client = AsyncClient (httpserver .url_for ('/' ))
1089
1004
1090
- response = await client .create ('dummy' , modelfile = 'FROM llama2' )
1005
+ response = await client .create ('dummy' , from_ = ' llama2' )
1091
1006
assert response ['status' ] == 'success'
1092
1007
1093
1008
0 commit comments