Studio: keep web search/code pills off on model load if user disabled them (#5851)
* Studio: keep web search/code pills off on model load if user disabled them * Studio: avoid redundant localStorage reads when resolving tool pills on load
This commit is contained in:
parent
ee6695118c
commit
db5a9880b0
3 changed files with 28 additions and 14 deletions
|
|
@ -34,6 +34,7 @@ import {
|
|||
} from "../provider-capabilities";
|
||||
import {
|
||||
type PendingImageEditReference,
|
||||
resolveToolsEnabledOnLoad,
|
||||
useChatRuntimeStore,
|
||||
} from "../stores/chat-runtime-store";
|
||||
import { useExternalProvidersStore } from "../stores/external-providers-store";
|
||||
|
|
@ -1034,8 +1035,7 @@ async function autoLoadSmallestModel(): Promise<{
|
|||
supportsPreserveThinking:
|
||||
loadResp.supports_preserve_thinking ?? false,
|
||||
supportsTools: loadResp.supports_tools ?? false,
|
||||
toolsEnabled: loadResp.supports_tools ?? false,
|
||||
codeToolsEnabled: loadResp.supports_tools ?? false,
|
||||
...resolveToolsEnabledOnLoad(loadResp.supports_tools ?? false),
|
||||
kvCacheDtype: loadResp.cache_type_kv ?? null,
|
||||
loadedKvCacheDtype: loadResp.cache_type_kv ?? null,
|
||||
defaultChatTemplate: loadResp.chat_template ?? null,
|
||||
|
|
@ -1098,8 +1098,7 @@ async function autoLoadSmallestModel(): Promise<{
|
|||
sfLoadResp.supports_preserve_thinking ?? false,
|
||||
supportsTools: sfLoadResp.supports_tools ?? false,
|
||||
// Parity with the GGUF branch above.
|
||||
toolsEnabled: sfLoadResp.supports_tools ?? false,
|
||||
codeToolsEnabled: sfLoadResp.supports_tools ?? false,
|
||||
...resolveToolsEnabledOnLoad(sfLoadResp.supports_tools ?? false),
|
||||
defaultChatTemplate: sfLoadResp.chat_template ?? null,
|
||||
chatTemplateOverride: null,
|
||||
loadedChatTemplateOverride: null,
|
||||
|
|
@ -1197,8 +1196,7 @@ async function autoLoadSmallestModel(): Promise<{
|
|||
reasoningStyle: loadResp.reasoning_style ?? "enable_thinking",
|
||||
supportsPreserveThinking: loadResp.supports_preserve_thinking ?? false,
|
||||
supportsTools: loadResp.supports_tools ?? false,
|
||||
toolsEnabled: loadResp.supports_tools ?? false,
|
||||
codeToolsEnabled: loadResp.supports_tools ?? false,
|
||||
...resolveToolsEnabledOnLoad(loadResp.supports_tools ?? false),
|
||||
kvCacheDtype: loadResp.cache_type_kv ?? null,
|
||||
loadedKvCacheDtype: loadResp.cache_type_kv ?? null,
|
||||
defaultChatTemplate: loadResp.chat_template ?? null,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import {
|
|||
CHAT_REASONING_ENABLED_KEY,
|
||||
loadOptionalBool,
|
||||
type ReasoningEffort,
|
||||
resolveToolsEnabledOnLoad,
|
||||
useChatRuntimeStore,
|
||||
} from "../stores/chat-runtime-store";
|
||||
import {
|
||||
|
|
@ -698,14 +699,12 @@ export function useChatModelRuntime() {
|
|||
reasoningEffort: clampedReasoningEffort,
|
||||
supportsPreserveThinking: loadResponse.supports_preserve_thinking ?? false,
|
||||
supportsTools,
|
||||
toolsEnabled:
|
||||
reloadingSameModel && supportsTools
|
||||
? stateBeforeUnload.toolsEnabled
|
||||
: supportsTools,
|
||||
codeToolsEnabled:
|
||||
reloadingSameModel && supportsTools
|
||||
? stateBeforeUnload.codeToolsEnabled
|
||||
: supportsTools,
|
||||
...(reloadingSameModel && supportsTools
|
||||
? {
|
||||
toolsEnabled: stateBeforeUnload.toolsEnabled,
|
||||
codeToolsEnabled: stateBeforeUnload.codeToolsEnabled,
|
||||
}
|
||||
: resolveToolsEnabledOnLoad(supportsTools)),
|
||||
kvCacheDtype: loadedKv,
|
||||
loadedKvCacheDtype: loadedKv,
|
||||
speculativeType: loadedSpec,
|
||||
|
|
|
|||
|
|
@ -184,6 +184,23 @@ export function loadOptionalBool(key: string): boolean | null {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the web-search / code-execution pill state to apply when a model
|
||||
* loads. Honors the user's persisted preference so loading a tool-capable
|
||||
* model never silently re-enables a pill the user turned off; falls back to
|
||||
* the model's capability only when no preference has been expressed.
|
||||
*/
|
||||
export function resolveToolsEnabledOnLoad(supportsTools: boolean): {
|
||||
toolsEnabled: boolean;
|
||||
codeToolsEnabled: boolean;
|
||||
} {
|
||||
if (!supportsTools) return { toolsEnabled: false, codeToolsEnabled: false };
|
||||
return {
|
||||
toolsEnabled: loadOptionalBool(CHAT_TOOLS_ENABLED_KEY) ?? true,
|
||||
codeToolsEnabled: loadOptionalBool(CHAT_CODE_TOOLS_ENABLED_KEY) ?? true,
|
||||
};
|
||||
}
|
||||
|
||||
function saveBool(key: string, value: boolean): void {
|
||||
if (!canUseStorage()) return;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue