MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / setDraftComposerModel

Function setDraftComposerModel

desktop/runtime/composer-service.ts:162–184  ·  view source on GitHub ↗
(cwd: string, provider: string, modelId: string)

Source from the content-addressed store, hash-verified

160}
161
162async function setDraftComposerModel(cwd: string, provider: string, modelId: string) {
163 const { AuthStorage, ModelRegistry, SettingsManager, getAgentDir } = await getPiModule()
164 const agentDir = getAgentDir()
165 const authStorage = AuthStorage.create()
166 const modelRegistry = normalizeModelRegistryContextWindows(
167 ModelRegistry.create(authStorage, `${agentDir}/models.json`),
168 )
169 const model = modelRegistry.find(provider, modelId)
170
171 if (!model) {
172 throw new Error(`Unknown Pi model: ${provider}/${modelId}`)
173 }
174
175 const currentComposer = await buildComposerStateSnapshot({ projectId: cwd, sessionPath: null })
176 const nextThinkingLevel = clampThinkingLevel(
177 currentComposer.currentThinkingLevel,
178 getAvailableThinkingLevelsForModel(model),
179 )
180 const settingsManager = SettingsManager.create(cwd, agentDir)
181
182 settingsManager.setDefaultModelAndProvider(provider, modelId)
183 settingsManager.setDefaultThinkingLevel(nextThinkingLevel)
184}
185
186async function setDraftComposerThinkingLevel(cwd: string, level: ComposerThinkingLevel) {
187 const { SettingsManager, getAgentDir } = await getPiModule()

Callers 1

setComposerModelFunction · 0.85

Calls 5

getPiModuleFunction · 0.90
clampThinkingLevelFunction · 0.90

Tested by

no test coverage detected