@@ -536,51 +536,6 @@ def generate():
536
536
assert part ['status' ] == next (it )
537
537
538
538
539
- def test_client_create_path (httpserver : HTTPServer ):
540
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
541
- httpserver .expect_ordered_request (
542
- '/api/create' ,
543
- method = 'POST' ,
544
- json = {
545
- 'model' : 'dummy' ,
546
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
547
- 'stream' : False ,
548
- },
549
- ).respond_with_json ({'status' : 'success' })
550
-
551
- client = Client (httpserver .url_for ('/' ))
552
-
553
- with tempfile .NamedTemporaryFile () as modelfile :
554
- with tempfile .NamedTemporaryFile () as blob :
555
- modelfile .write (f'FROM { blob .name } ' .encode ('utf-8' ))
556
- modelfile .flush ()
557
-
558
- response = client .create ('dummy' , path = modelfile .name )
559
- assert response ['status' ] == 'success'
560
-
561
-
562
- def test_client_create_path_relative (httpserver : HTTPServer ):
563
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
564
- httpserver .expect_ordered_request (
565
- '/api/create' ,
566
- method = 'POST' ,
567
- json = {
568
- 'model' : 'dummy' ,
569
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
570
- 'stream' : False ,
571
- },
572
- ).respond_with_json ({'status' : 'success' })
573
-
574
- client = Client (httpserver .url_for ('/' ))
575
-
576
- with tempfile .NamedTemporaryFile () as modelfile :
577
- with tempfile .NamedTemporaryFile (dir = Path (modelfile .name ).parent ) as blob :
578
- modelfile .write (f'FROM { Path (blob .name ).name } ' .encode ('utf-8' ))
579
- modelfile .flush ()
580
-
581
- response = client .create ('dummy' , path = modelfile .name )
582
- assert response ['status' ] == 'success'
583
-
584
539
585
540
@pytest .fixture
586
541
def userhomedir ():
@@ -591,67 +546,38 @@ def userhomedir():
591
546
os .environ ['HOME' ] = home
592
547
593
548
594
- def test_client_create_path_user_home (httpserver : HTTPServer , userhomedir ):
595
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
596
- httpserver .expect_ordered_request (
597
- '/api/create' ,
598
- method = 'POST' ,
599
- json = {
600
- 'model' : 'dummy' ,
601
- 'modelfile' : 'FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
602
- 'stream' : False ,
603
- },
604
- ).respond_with_json ({'status' : 'success' })
605
-
606
- client = Client (httpserver .url_for ('/' ))
607
-
608
- with tempfile .NamedTemporaryFile () as modelfile :
609
- with tempfile .NamedTemporaryFile (dir = userhomedir ) as blob :
610
- modelfile .write (f'FROM ~/{ Path (blob .name ).name } ' .encode ('utf-8' ))
611
- modelfile .flush ()
612
-
613
- response = client .create ('dummy' , path = modelfile .name )
614
- assert response ['status' ] == 'success'
615
-
616
-
617
- def test_client_create_modelfile (httpserver : HTTPServer ):
618
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
549
+ def test_client_create_with_blob (httpserver : HTTPServer ):
619
550
httpserver .expect_ordered_request (
620
551
'/api/create' ,
621
552
method = 'POST' ,
622
553
json = {
623
554
'model' : 'dummy' ,
624
- 'modelfile ' : 'FROM @ sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n ' ,
555
+ 'files ' : { 'test.gguf' : ' sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' } ,
625
556
'stream' : False ,
626
557
},
627
558
).respond_with_json ({'status' : 'success' })
628
559
629
560
client = Client (httpserver .url_for ('/' ))
630
561
631
562
with tempfile .NamedTemporaryFile () as blob :
632
- response = client .create ('dummy' , modelfile = f'FROM { blob . name } ' )
563
+ response = client .create ('dummy' , files = { 'test.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' } )
633
564
assert response ['status' ] == 'success'
634
565
635
566
636
- def test_client_create_modelfile_roundtrip (httpserver : HTTPServer ):
637
- httpserver .expect_ordered_request (PrefixPattern ('/api/blobs/' ), method = 'POST' ).respond_with_response (Response (status = 200 ))
567
+ def test_client_create_with_parameters_roundtrip (httpserver : HTTPServer ):
638
568
httpserver .expect_ordered_request (
639
569
'/api/create' ,
640
570
method = 'POST' ,
641
571
json = {
642
572
'model' : 'dummy' ,
643
- 'modelfile' : '''FROM @sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
644
- TEMPLATE """[INST] <<SYS>>{{.System}}<</SYS>>
645
- {{.Prompt}} [/INST]"""
646
- SYSTEM """
647
- Use
648
- multiline
649
- strings.
650
- """
651
- PARAMETER stop [INST]
652
- PARAMETER stop [/INST]
653
- PARAMETER stop <<SYS>>
654
- PARAMETER stop <</SYS>>''' ,
573
+ 'quantize' : 'q4_k_m' ,
574
+ 'from' : 'mymodel' ,
575
+ 'adapters' : {'someadapter.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' },
576
+ 'template' : '[INST] <<SYS>>{{.System}}<</SYS>>\n {{.Prompt}} [/INST]' ,
577
+ 'license' : 'this is my license' ,
578
+ 'system' : '\n Use\n multiline\n strings.\n ' ,
579
+ 'parameters' : {'stop' : ['[INST]' , '[/INST]' , '<<SYS>>' , '<</SYS>>' ], 'pi' : 3.14159 },
580
+ 'messages' : [{'role' : 'user' , 'content' : 'Hello there!' }, {'role' : 'assistant' , 'content' : 'Hello there yourself!' }],
655
581
'stream' : False ,
656
582
},
657
583
).respond_with_json ({'status' : 'success' })
@@ -661,22 +587,15 @@ def test_client_create_modelfile_roundtrip(httpserver: HTTPServer):
661
587
with tempfile .NamedTemporaryFile () as blob :
662
588
response = client .create (
663
589
'dummy' ,
664
- modelfile = '\n ' .join (
665
- [
666
- f'FROM { blob .name } ' ,
667
- 'TEMPLATE """[INST] <<SYS>>{{.System}}<</SYS>>' ,
668
- '{{.Prompt}} [/INST]"""' ,
669
- 'SYSTEM """' ,
670
- 'Use' ,
671
- 'multiline' ,
672
- 'strings.' ,
673
- '"""' ,
674
- 'PARAMETER stop [INST]' ,
675
- 'PARAMETER stop [/INST]' ,
676
- 'PARAMETER stop <<SYS>>' ,
677
- 'PARAMETER stop <</SYS>>' ,
678
- ]
679
- ),
590
+ quantize = 'q4_k_m' ,
591
+ from_ = 'mymodel' ,
592
+ adapters = {'someadapter.gguf' : 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' },
593
+ template = '[INST] <<SYS>>{{.System}}<</SYS>>\n {{.Prompt}} [/INST]' ,
594
+ license = 'this is my license' ,
595
+ system = '\n Use\n multiline\n strings.\n ' ,
596
+ parameters = {'stop' : ['[INST]' , '[/INST]' , '<<SYS>>' , '<</SYS>>' ], 'pi' : 3.14159 },
597
+ messages = [{'role' : 'user' , 'content' : 'Hello there!' }, {'role' : 'assistant' , 'content' : 'Hello there yourself!' }],
598
+ stream = False ,
680
599
)
681
600
assert response ['status' ] == 'success'
682
601
@@ -687,14 +606,14 @@ def test_client_create_from_library(httpserver: HTTPServer):
687
606
method = 'POST' ,
688
607
json = {
689
608
'model' : 'dummy' ,
690
- 'modelfile ' : 'FROM llama2' ,
609
+ 'from ' : 'llama2' ,
691
610
'stream' : False ,
692
611
},
693
612
).respond_with_json ({'status' : 'success' })
694
613
695
614
client = Client (httpserver .url_for ('/' ))
696
615
697
- response = client .create ('dummy' , modelfile = 'FROM llama2' )
616
+ response = client .create ('dummy' , from_ = ' llama2' )
698
617
assert response ['status' ] == 'success'
699
618
700
619
0 commit comments