-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
59 lines (47 loc) · 1.47 KB
/
Copy pathmodels.py
File metadata and controls
59 lines (47 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from __future__ import annotations
from typing import Any, Literal, Optional
from pydantic import BaseModel, Field
class WorkerAnswer(BaseModel):
question_id: int
question: str
answer: str
has_error: bool = Field(exclude=True)
error_type: Optional[Literal["wrong_value", "wrong_inference", "omission"]] = Field(
default=None, exclude=True
)
correct_answer: str = Field(exclude=True)
relevant_field: str = Field(exclude=True)
class OversightObservation(BaseModel):
source_json: dict[str, Any]
questions: list[str]
worker_answers: list[str]
step_number: int
flags_used: int
flags_remaining: int
episode_id: str
done: bool
message: str
class OversightAction(BaseModel):
action_type: Literal["approve", "flag"]
question_id: int
error_type: Optional[Literal["wrong_value", "wrong_inference", "omission"]] = None
reasoning: str
confidence: float = Field(ge=0.0, le=1.0)
# EpisodeState is a plain dict — mutated freely by the environment each step.
EpisodeState = dict[str, Any]
def make_episode_state(
episode_id: str,
task_id: str,
source_json: dict[str, Any],
worker_answers: list[WorkerAnswer],
) -> EpisodeState:
return {
"episode_id": episode_id,
"task_id": task_id,
"source_json": source_json,
"worker_answers": worker_answers,
"agent_decisions": [],
"flags_used": 0,
"step_number": 0,
"total_reward": 0.0,
}