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,16 @@ 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 ]] = {QualityMode .Benchmark , QualityMode .Consensus },
608
+ is_benchmark_enabled : Optional [bool ] = None ,
609
+ is_consensus_enabled : Optional [bool ] = None ) -> Project :
601
610
"""Creates a Project object on the server.
602
611
603
612
Attribute values are passed as keyword arguments.
@@ -628,39 +637,30 @@ def create_project(self, **kwargs) -> Project:
628
637
dataset_name_or_id, append_to_existing_dataset, data_row_count, editor_task_type
629
638
They are not used for general projects and not supported in this method
630
639
"""
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
- return self ._create_project (_CoreProjectInput (** kwargs ))
637
-
638
- @overload
639
- def create_model_evaluation_project (
640
- self ,
641
- dataset_name : str ,
642
- dataset_id : str = None ,
643
- data_row_count : int = 100 ,
644
- ** kwargs ,
645
- ) -> Project :
646
- pass
647
-
648
- @overload
649
- def create_model_evaluation_project (
650
- self ,
651
- dataset_id : str ,
652
- dataset_name : str = None ,
653
- data_row_count : int = 100 ,
654
- ** kwargs ,
655
- ) -> Project :
656
- pass
640
+ input = {
641
+ "name" : name ,
642
+ "description" : description ,
643
+ "media_type" : media_type ,
644
+ "auto_audit_percentage" : auto_audit_percentage ,
645
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
646
+ "quality_modes" : quality_modes ,
647
+ "is_benchmark_enabled" : is_benchmark_enabled ,
648
+ "is_consensus_enabled" : is_consensus_enabled ,
649
+ }
650
+ return self ._create_project (_CoreProjectInput (** input ))
657
651
658
652
def create_model_evaluation_project (
659
653
self ,
654
+ name : str ,
655
+ description : Optional [str ] = None ,
656
+ auto_audit_percentage : Optional [float ] = None ,
657
+ auto_audit_number_of_labels : Optional [int ] = None ,
658
+ quality_modes : Optional [Set [QualityMode ]] = {QualityMode .Benchmark , QualityMode .Consensus },
659
+ is_benchmark_enabled : Optional [bool ] = None ,
660
+ is_consensus_enabled : Optional [bool ] = None ,
660
661
dataset_id : Optional [str ] = None ,
661
662
dataset_name : Optional [str ] = None ,
662
663
data_row_count : int = 100 ,
663
- ** kwargs ,
664
664
) -> Project :
665
665
"""
666
666
Use this method exclusively to create a chat model evaluation project.
@@ -691,8 +691,6 @@ def create_model_evaluation_project(
691
691
raise ValueError (
692
692
"dataset_name or data_set_id must be present and not be an empty string."
693
693
)
694
- if data_row_count <= 0 :
695
- raise ValueError ("data_row_count must be a positive integer." )
696
694
697
695
if dataset_id :
698
696
append_to_existing_dataset = True
@@ -701,13 +699,24 @@ def create_model_evaluation_project(
701
699
append_to_existing_dataset = False
702
700
dataset_name_or_id = dataset_name
703
701
704
- kwargs ["media_type" ] = MediaType .Conversational
705
- kwargs ["dataset_name_or_id" ] = dataset_name_or_id
706
- kwargs ["append_to_existing_dataset" ] = append_to_existing_dataset
707
- kwargs ["data_row_count" ] = data_row_count
708
- kwargs ["editor_task_type" ] = EditorTaskType .ModelChatEvaluation .value
702
+ media_type = MediaType .Conversational
703
+ editor_task_type = EditorTaskType .ModelChatEvaluation
709
704
710
- return self ._create_project (_CoreProjectInput (** kwargs ))
705
+ input = {
706
+ "name" : name ,
707
+ "description" : description ,
708
+ "media_type" : media_type ,
709
+ "auto_audit_percentage" : auto_audit_percentage ,
710
+ "auto_audit_number_of_labels" : auto_audit_number_of_labels ,
711
+ "quality_modes" : quality_modes ,
712
+ "is_benchmark_enabled" : is_benchmark_enabled ,
713
+ "is_consensus_enabled" : is_consensus_enabled ,
714
+ "dataset_name_or_id" : dataset_name_or_id ,
715
+ "append_to_existing_dataset" : append_to_existing_dataset ,
716
+ "data_row_count" : data_row_count ,
717
+ "editor_task_type" : editor_task_type ,
718
+ }
719
+ return self ._create_project (_CoreProjectInput (** input ))
711
720
712
721
def create_offline_model_evaluation_project (self , ** kwargs ) -> Project :
713
722
"""
0 commit comments