MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / useMainLoopModel

Function useMainLoopModel

src/hooks/useMainLoopModel.ts:14–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12// API calls. Use this over getMainLoopModel() when the component needs to
13// update upon a model config change.
14export function useMainLoopModel(): ModelName {
15 const mainLoopModel = useAppState(s => s.mainLoopModel)
16 const mainLoopModelForSession = useAppState(s => s.mainLoopModelForSession)
17
18 // parseUserSpecifiedModel reads tengu_ant_model_override via
19 // _CACHED_MAY_BE_STALE (in resolveAntModel). Until GB init completes,
20 // that's the stale disk cache; after, it's the in-memory remoteEval map.
21 // AppState doesn't change when GB init finishes, so we subscribe to the
22 // refresh signal and force a re-render to re-resolve with fresh values.
23 // Without this, the alias resolution is frozen until something else
24 // happens to re-render the component — the API would sample one model
25 // while /model (which also re-resolves) displays another.
26 const [, forceRerender] = useReducer(x => x + 1, 0)
27 useEffect(() => onGrowthBookRefresh(forceRerender), [])
28
29 const model = parseUserSpecifiedModel(
30 mainLoopModelForSession ??
31 mainLoopModel ??
32 readCurrentCustomApiProvider()?.model ??
33 readCustomApiStorage().model ??
34 getDefaultMainLoopModelSetting(),
35 )
36 return model
37}

Callers 9

StatusLineInnerFunction · 0.85
LogoV2Function · 0.85
CondensedLogoFunction · 0.85
PromptInputFunction · 0.85
NotificationsFunction · 0.85
GenerateStepFunction · 0.85
ShowCurrentEffortFunction · 0.85
LoginFunction · 0.85
REPLFunction · 0.85

Calls 6

useAppStateFunction · 0.85
onGrowthBookRefreshFunction · 0.85
parseUserSpecifiedModelFunction · 0.85
readCustomApiStorageFunction · 0.85

Tested by

no test coverage detected