File size: 1,199 Bytes
1f77aa7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import {
  getScenarioWorkbenchConfig,
  type WorkbenchConfig,
  type WorkbenchScenarioId,
} from './workbench'

export type ViewOptions = {
  debug: boolean
  snapshot: boolean
  scenario: WorkbenchScenarioId
}

const SCENARIOS = new Set<WorkbenchScenarioId>([
  'default',
  'olmo-pretraining',
  'olmo-long-context',
  'llama-pretraining',
  'llama-long-context',
  'trinity-pretraining',
  'trinity-long-context',
  'infeasible-memory',
])

const truthyValues = new Set(['1', 'true', 'yes', 'on'])

function isTruthy(value: string | null) {
  if (value === null) {
    return false
  }

  return truthyValues.has(value.toLowerCase())
}

export function getViewOptions(search = window.location.search): ViewOptions {
  const params = new URLSearchParams(search)
  const scenarioParam = params.get('scenario')
  const scenario = SCENARIOS.has(scenarioParam as WorkbenchScenarioId)
    ? (scenarioParam as WorkbenchScenarioId)
    : 'default'

  return {
    debug: isTruthy(params.get('debug')),
    snapshot: isTruthy(params.get('snapshot')),
    scenario,
  }
}

export function getScenarioConfig(scenario: WorkbenchScenarioId): WorkbenchConfig {
  return getScenarioWorkbenchConfig(scenario)
}