File size: 2,172 Bytes
1b83e76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export type ExplorePhase = "explore" | "generate" | "repair" | "done";

export type ExploreTool =
  | "search_wikipedia"
  | "search_hf_papers"
  | "search_arxiv"
  | "search_scholar"
  | "fetch_docs"
  | "search_hf_hub";

export type GenerateFormat = "marimo" | "manim";

export interface TopChunk {
  rank?: number;
  source?: string;
  title?: string;
  url?: string;
  score?: number | string;
  snippet?: string;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  [k: string]: any;
}

export interface ExplainerObservation {
  done: boolean;
  reward: number | null;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  metadata: Record<string, any>;
  topic: string;
  content: string;
  tier: "beginner" | "intermediate" | "advanced" | string;
  keywords: string;
  data_available: boolean;
  difficulty: "easy" | "medium" | "hard" | string;
  phase: ExplorePhase;
  feedback: string;
  search_results: string;
  top_chunks: TopChunk[];
  explored_context: string;
  explore_steps_left: number;
  repair_attempts_left: number;
  last_errors: string;
  available_tools: string[];
}

export interface ExplainerAction {
  action_type: "explore" | "generate" | "repair";
  tool?: ExploreTool | null;
  query?: string;
  intent?: string;
  format?: GenerateFormat | null;
  code?: string;
  narration?: string;
  repair_notes?: string;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  metadata?: Record<string, any>;
}

export interface StepResult {
  observation: ExplainerObservation;
  reward: number | null;
  done: boolean;
}

export interface ParsedExplore {
  kind: "explore";
  tool: ExploreTool;
  query: string;
  intent: string;
  skip?: boolean;
}

export interface ParsedGenerate {
  kind: "generate" | "repair";
  format: GenerateFormat;
  code: string;
  narration: string;
}

export type ParsedAction = ParsedExplore | ParsedGenerate;

export interface RewardEntry {
  step: number;
  phase: string;
  total: number | null;
  components: Record<string, number | string>;
}

export interface LogEntry {
  ts: number;
  tag: "START" | "LLM" | "STEP" | "END" | "WARN" | "ERROR" | "INFO";
  message: string;
}