File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
libs/labelbox/src/labelbox/schema/tool_building Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
import labelbox .schema .tool_building .tool_type
2
+ import labelbox .schema .tool_building .variant
2
3
import labelbox .schema .tool_building .step_reasoning_tool
3
4
import labelbox .schema .tool_building .fact_checking_tool
4
5
import labelbox .schema .tool_building .tool_type_mapping
Original file line number Diff line number Diff line change
1
+ from dataclasses import dataclass , field
2
+ from typing import Any , Dict , List , Set
3
+
4
+
5
+ @dataclass
6
+ class Variant :
7
+ """
8
+ A variant is a single option in step-by-step reasoning or fact-checking tool.
9
+ """
10
+
11
+ id : int
12
+ name : str
13
+
14
+ def asdict (self ) -> Dict [str , Any ]:
15
+ return {"id" : self .id , "name" : self .name }
16
+
17
+
18
+ @dataclass
19
+ class VariantWithActions :
20
+ id : int
21
+ name : str
22
+ actions : List [str ] = field (default_factory = list )
23
+ _available_actions : Set [str ] = field (default_factory = set )
24
+
25
+ def set_actions (self , actions : Set [str ]) -> None :
26
+ for action in actions :
27
+ if action in self ._available_actions :
28
+ self .actions .append (action )
29
+
30
+ def reset_actions (self ) -> None :
31
+ self .actions = []
32
+
33
+ def asdict (self ) -> Dict [str , Any ]:
34
+ return {
35
+ "id" : self .id ,
36
+ "name" : self .name ,
37
+ "actions" : list (set (self .actions )),
38
+ }
You can’t perform that action at this time.
0 commit comments