mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(models): consolidate provider and model into /model command
This commit is contained in:
parent
ac0325c257
commit
a0b62e0c5a
6 changed files with 83 additions and 34 deletions
|
|
@ -17,12 +17,29 @@ import type { SlashCommand } from '../types.js'
|
|||
|
||||
const GLOBAL_MODEL_FLAG_RE = /(?:^|\s)--global(?:\s|$)/
|
||||
|
||||
/** Stripped before `config.set`; TUI model picker uses this for session-scoped switches. */
|
||||
const TUI_SESSION_MODEL_RE = /(?:^|\s)--tui-session(?:\s|$)/
|
||||
|
||||
const persistedModelArg = (arg: string) => {
|
||||
const trimmed = arg.trim()
|
||||
|
||||
return !trimmed || GLOBAL_MODEL_FLAG_RE.test(trimmed) ? trimmed : `${trimmed} --global`
|
||||
}
|
||||
|
||||
const modelValueForConfigSet = (arg: string) => {
|
||||
const trimmed = arg.trim()
|
||||
|
||||
if (!trimmed) {
|
||||
return trimmed
|
||||
}
|
||||
|
||||
if (TUI_SESSION_MODEL_RE.test(trimmed)) {
|
||||
return trimmed.replace(/\s*--tui-session\b\s*/g, ' ').replace(/\s+/g, ' ').trim()
|
||||
}
|
||||
|
||||
return persistedModelArg(trimmed)
|
||||
}
|
||||
|
||||
export const sessionCommands: SlashCommand[] = [
|
||||
{
|
||||
aliases: ['bg', 'btw'],
|
||||
|
|
@ -60,7 +77,7 @@ export const sessionCommands: SlashCommand[] = [
|
|||
}
|
||||
|
||||
ctx.gateway
|
||||
.rpc<ConfigSetResponse>('config.set', { key: 'model', session_id: ctx.sid, value: persistedModelArg(arg) })
|
||||
.rpc<ConfigSetResponse>('config.set', { key: 'model', session_id: ctx.sid, value: modelValueForConfigSet(arg) })
|
||||
.then(
|
||||
ctx.guarded<ConfigSetResponse>(r => {
|
||||
if (!r.value) {
|
||||
|
|
|
|||
|
|
@ -662,7 +662,7 @@ export function useMainApp(gw: GatewayClient) {
|
|||
|
||||
const onModelSelect = useCallback((value: string) => {
|
||||
patchOverlayState({ modelPicker: false })
|
||||
slashRef.current(`/model ${value} --global`)
|
||||
slashRef.current(`/model ${value}`)
|
||||
}, [])
|
||||
|
||||
const hasReasoning = useTurnSelector(state => Boolean(state.reasoning.trim()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue