8
8
import urllib .parse
9
9
from collections import defaultdict
10
10
from types import MappingProxyType
11
- from typing import Any , Callable , Dict , List , Optional , Union , overload
11
+ from typing import Any , Callable , Dict , List , Optional , Set , Union , overload
12
12
13
13
import lbox .exceptions
14
14
import requests
@@ -597,7 +597,20 @@ def create_dataset(
597
597
raise e
598
598
return dataset
599
599
600
- def create_project (self , ** kwargs ) -> Project :
600
+ def create_project (
601
+ self ,
602
+ name : str ,
603
+ media_type : MediaType ,
604
+ description : Optional [str ] = None ,
605
+ auto_audit_percentage : Optional [float ] = None ,
606
+ auto_audit_number_of_labels : Optional [int ] = None ,
607
+ quality_modes : Optional [Set [QualityMode ]] = {
608
+ QualityMode .Benchmark ,
609
+ QualityMode .Consensus ,
610
+ },
611
+ is_benchmark_enabled : Optional [bool ] = None ,
612
+ is_consensus_enabled : Optional [bool ] = None ,
613
+ ) -> Project :
601
614
"""Creates a Project object on the server.
602
615
603
616
Attribute values are passed as keyword arguments.
@@ -628,40 +641,33 @@ def create_project(self, **kwargs) -> Project:
628
641
dataset_name_or_id, append_to_existing_dataset, data_row_count, editor_task_type
629
642
They are not used for general projects and not supported in this method
630
643
"""
631
- # The following arguments are not supported for general projects, only for chat model evaluation projects
632
- kwargs .pop ("dataset_name_or_id" , None )
633
- kwargs .pop ("append_to_existing_dataset" , None )
634
- kwargs .pop ("data_row_count" , None )
635
- kwargs .pop ("editor_task_type" , None )
636
- input = _CoreProjectInput (** kwargs )
637
- return self ._create_project (input )
638
-
639
- @overload
640
- def create_model_evaluation_project (
641
- self ,
642
- dataset_name : str ,
643
- dataset_id : str = None ,
644
- data_row_count : int = 100 ,
645
- ** kwargs ,
646
- ) -> Project :
647
- pass
648
-
649
- @overload
650
- def create_model_evaluation_project (
651
- self ,
652
- dataset_id : str ,
653
- dataset_name : str = None ,
654
- data_row_count : int = 100 ,
655
- ** kwargs ,
656
- ) -> Project :
657
- pass
644
+ input = {
645
+ "name" : name ,
646
+ "description" : description ,
647
+ "media_type" : media_type ,
648
+ "auto_audit_percentage" : auto_audit_percentage ,
649
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
650
+ "quality_modes" : quality_modes ,
651
+ "is_benchmark_enabled" : is_benchmark_enabled ,
652
+ "is_consensus_enabled" : is_consensus_enabled ,
653
+ }
654
+ return self ._create_project (_CoreProjectInput (** input ))
658
655
659
656
def create_model_evaluation_project (
660
657
self ,
658
+ name : str ,
659
+ description : Optional [str ] = None ,
660
+ auto_audit_percentage : Optional [float ] = None ,
661
+ auto_audit_number_of_labels : Optional [int ] = None ,
662
+ quality_modes : Optional [Set [QualityMode ]] = {
663
+ QualityMode .Benchmark ,
664
+ QualityMode .Consensus ,
665
+ },
666
+ is_benchmark_enabled : Optional [bool ] = None ,
667
+ is_consensus_enabled : Optional [bool ] = None ,
661
668
dataset_id : Optional [str ] = None ,
662
669
dataset_name : Optional [str ] = None ,
663
670
data_row_count : int = 100 ,
664
- ** kwargs ,
665
671
) -> Project :
666
672
"""
667
673
Use this method exclusively to create a chat model evaluation project.
@@ -692,8 +698,6 @@ def create_model_evaluation_project(
692
698
raise ValueError (
693
699
"dataset_name or data_set_id must be present and not be an empty string."
694
700
)
695
- if data_row_count <= 0 :
696
- raise ValueError ("data_row_count must be a positive integer." )
697
701
698
702
if dataset_id :
699
703
append_to_existing_dataset = True
@@ -702,42 +706,74 @@ def create_model_evaluation_project(
702
706
append_to_existing_dataset = False
703
707
dataset_name_or_id = dataset_name
704
708
705
- kwargs ["media_type" ] = MediaType .Conversational
706
- kwargs ["dataset_name_or_id" ] = dataset_name_or_id
707
- kwargs ["append_to_existing_dataset" ] = append_to_existing_dataset
708
- kwargs ["data_row_count" ] = data_row_count
709
- kwargs ["editor_task_type" ] = EditorTaskType .ModelChatEvaluation .value
709
+ media_type = MediaType .Conversational
710
+ editor_task_type = EditorTaskType .ModelChatEvaluation
710
711
711
- return self ._create_project (** kwargs )
712
+ input = {
713
+ "name" : name ,
714
+ "description" : description ,
715
+ "media_type" : media_type ,
716
+ "auto_audit_percentage" : auto_audit_percentage ,
717
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
718
+ "quality_modes" : quality_modes ,
719
+ "is_benchmark_enabled" : is_benchmark_enabled ,
720
+ "is_consensus_enabled" : is_consensus_enabled ,
721
+ "dataset_name_or_id" : dataset_name_or_id ,
722
+ "append_to_existing_dataset" : append_to_existing_dataset ,
723
+ "data_row_count" : data_row_count ,
724
+ "editor_task_type" : editor_task_type ,
725
+ }
726
+ return self ._create_project (_CoreProjectInput (** input ))
712
727
713
- def create_offline_model_evaluation_project (self , ** kwargs ) -> Project :
728
+ def create_offline_model_evaluation_project (
729
+ self ,
730
+ name : str ,
731
+ description : Optional [str ] = None ,
732
+ auto_audit_percentage : Optional [float ] = None ,
733
+ auto_audit_number_of_labels : Optional [int ] = None ,
734
+ quality_modes : Optional [Set [QualityMode ]] = {
735
+ QualityMode .Benchmark ,
736
+ QualityMode .Consensus ,
737
+ },
738
+ is_benchmark_enabled : Optional [bool ] = None ,
739
+ is_consensus_enabled : Optional [bool ] = None ,
740
+ ) -> Project :
714
741
"""
715
742
Creates a project for offline model evaluation.
716
743
Args:
717
744
**kwargs: Additional parameters to pass see the create_project method
718
745
Returns:
719
746
Project: The created project
720
747
"""
721
- kwargs ["media_type" ] = (
722
- MediaType .Conversational
723
- ) # Only Conversational is supported
724
- kwargs ["editor_task_type" ] = (
725
- EditorTaskType .OfflineModelChatEvaluation .value
726
- ) # Special editor task type for offline model evaluation
727
-
728
- # The following arguments are not supported for offline model evaluation
729
- kwargs .pop ("dataset_name_or_id" , None )
730
- kwargs .pop ("append_to_existing_dataset" , None )
731
- kwargs .pop ("data_row_count" , None )
732
-
733
- return self ._create_project (** kwargs )
748
+ input = {
749
+ "name" : name ,
750
+ "description" : description ,
751
+ "media_type" : MediaType .Conversational ,
752
+ "auto_audit_percentage" : auto_audit_percentage ,
753
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
754
+ "quality_modes" : quality_modes ,
755
+ "is_benchmark_enabled" : is_benchmark_enabled ,
756
+ "is_consensus_enabled" : is_consensus_enabled ,
757
+ "editor_task_type" : EditorTaskType .OfflineModelChatEvaluation ,
758
+ }
759
+ return self ._create_project (_CoreProjectInput (** input ))
734
760
735
761
def create_prompt_response_generation_project (
736
762
self ,
763
+ name : str ,
764
+ media_type : MediaType ,
765
+ description : Optional [str ] = None ,
766
+ auto_audit_percentage : Optional [float ] = None ,
767
+ auto_audit_number_of_labels : Optional [int ] = None ,
768
+ quality_modes : Optional [Set [QualityMode ]] = {
769
+ QualityMode .Benchmark ,
770
+ QualityMode .Consensus ,
771
+ },
772
+ is_benchmark_enabled : Optional [bool ] = None ,
773
+ is_consensus_enabled : Optional [bool ] = None ,
737
774
dataset_id : Optional [str ] = None ,
738
775
dataset_name : Optional [str ] = None ,
739
776
data_row_count : int = 100 ,
740
- ** kwargs ,
741
777
) -> Project :
742
778
"""
743
779
Use this method exclusively to create a prompt and response generation project.
@@ -776,51 +812,68 @@ def create_prompt_response_generation_project(
776
812
"Only provide a dataset_name or dataset_id, not both."
777
813
)
778
814
779
- if data_row_count <= 0 :
780
- raise ValueError ("data_row_count must be a positive integer." )
781
-
782
815
if dataset_id :
783
816
append_to_existing_dataset = True
784
817
dataset_name_or_id = dataset_id
785
818
else :
786
819
append_to_existing_dataset = False
787
820
dataset_name_or_id = dataset_name
788
821
789
- if " media_type" in kwargs and kwargs . get ( "media_type" ) not in [
822
+ if media_type not in [
790
823
MediaType .LLMPromptCreation ,
791
824
MediaType .LLMPromptResponseCreation ,
792
825
]:
793
826
raise ValueError (
794
827
"media_type must be either LLMPromptCreation or LLMPromptResponseCreation"
795
828
)
796
829
797
- kwargs ["dataset_name_or_id" ] = dataset_name_or_id
798
- kwargs ["append_to_existing_dataset" ] = append_to_existing_dataset
799
- kwargs ["data_row_count" ] = data_row_count
800
-
801
- kwargs .pop ("editor_task_type" , None )
802
-
803
- return self ._create_project (** kwargs )
830
+ input = {
831
+ "name" : name ,
832
+ "description" : description ,
833
+ "media_type" : media_type ,
834
+ "auto_audit_percentage" : auto_audit_percentage ,
835
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
836
+ "quality_modes" : quality_modes ,
837
+ "is_benchmark_enabled" : is_benchmark_enabled ,
838
+ "is_consensus_enabled" : is_consensus_enabled ,
839
+ "dataset_name_or_id" : dataset_name_or_id ,
840
+ "append_to_existing_dataset" : append_to_existing_dataset ,
841
+ "data_row_count" : data_row_count ,
842
+ }
843
+ return self ._create_project (_CoreProjectInput (** input ))
804
844
805
- def create_response_creation_project (self , ** kwargs ) -> Project :
845
+ def create_response_creation_project (
846
+ self ,
847
+ name : str ,
848
+ description : Optional [str ] = None ,
849
+ auto_audit_percentage : Optional [float ] = None ,
850
+ auto_audit_number_of_labels : Optional [int ] = None ,
851
+ quality_modes : Optional [Set [QualityMode ]] = {
852
+ QualityMode .Benchmark ,
853
+ QualityMode .Consensus ,
854
+ },
855
+ is_benchmark_enabled : Optional [bool ] = None ,
856
+ is_consensus_enabled : Optional [bool ] = None ,
857
+ ) -> Project :
806
858
"""
807
859
Creates a project for response creation.
808
860
Args:
809
861
**kwargs: Additional parameters to pass see the create_project method
810
862
Returns:
811
863
Project: The created project
812
864
"""
813
- kwargs ["media_type" ] = MediaType .Text # Only Text is supported
814
- kwargs ["editor_task_type" ] = (
815
- EditorTaskType .ResponseCreation .value
816
- ) # Special editor task type for response creation projects
817
-
818
- # The following arguments are not supported for response creation projects
819
- kwargs .pop ("dataset_name_or_id" , None )
820
- kwargs .pop ("append_to_existing_dataset" , None )
821
- kwargs .pop ("data_row_count" , None )
822
-
823
- return self ._create_project (** kwargs )
865
+ input = {
866
+ "name" : name ,
867
+ "description" : description ,
868
+ "media_type" : MediaType .Text , # Only Text is supported
869
+ "auto_audit_percentage" : auto_audit_percentage ,
870
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
871
+ "quality_modes" : quality_modes ,
872
+ "is_benchmark_enabled" : is_benchmark_enabled ,
873
+ "is_consensus_enabled" : is_consensus_enabled ,
874
+ "editor_task_type" : EditorTaskType .ResponseCreation .value , # Special editor task type for response creation projects
875
+ }
876
+ return self ._create_project (_CoreProjectInput (** input ))
824
877
825
878
def _create_project (self , input : _CoreProjectInput ) -> Project :
826
879
media_type_value = input .media_type .value
0 commit comments