Skip to content

Commit e2e2d91

Browse files
author
Val Brodsky
committed
Add FactCheckingTool
1 parent 664fe4d commit e2e2d91

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import labelbox.schema.tool_building.tool_type
2+
import labelbox.schema.tool_building.variant
23
import labelbox.schema.tool_building.step_reasoning_tool
34
import labelbox.schema.tool_building.fact_checking_tool
45
import labelbox.schema.tool_building.tool_type_mapping
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)