@@ -933,117 +933,39 @@ def generate():
933933
934934
935935@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 ):
962937 httpserver .expect_ordered_request (
963938 '/api/create' ,
964939 method = 'POST' ,
965940 json = {
966941 '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' },
1016943 'stream' : False ,
1017944 },
1018945 ).respond_with_json ({'status' : 'success' })
1019946
1020947 client = AsyncClient (httpserver .url_for ('/' ))
1021948
1022949 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' } )
1024951 assert response ['status' ] == 'success'
1025952
1026953
1027954@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 ):
1030956 httpserver .expect_ordered_request (
1031957 '/api/create' ,
1032958 method = 'POST' ,
1033959 json = {
1034960 '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!' }],
1047969 'stream' : False ,
1048970 },
1049971 ).respond_with_json ({'status' : 'success' })
@@ -1053,22 +975,15 @@ async def test_async_client_create_modelfile_roundtrip(httpserver: HTTPServer):
1053975 with tempfile .NamedTemporaryFile () as blob :
1054976 response = await client .create (
1055977 '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 ,
1072987 )
1073988 assert response ['status' ] == 'success'
1074989
@@ -1080,14 +995,14 @@ async def test_async_client_create_from_library(httpserver: HTTPServer):
1080995 method = 'POST' ,
1081996 json = {
1082997 'model' : 'dummy' ,
1083- 'modelfile ' : 'FROM llama2' ,
998+ 'from ' : 'llama2' ,
1084999 'stream' : False ,
10851000 },
10861001 ).respond_with_json ({'status' : 'success' })
10871002
10881003 client = AsyncClient (httpserver .url_for ('/' ))
10891004
1090- response = await client .create ('dummy' , modelfile = 'FROM llama2' )
1005+ response = await client .create ('dummy' , from_ = ' llama2' )
10911006 assert response ['status' ] == 'success'
10921007
10931008
0 commit comments