mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-18 14:44:40 +00:00
fix(app): improve agent selection logic passing in configured models and variants correctly (#16072)
This commit is contained in:
@@ -35,6 +35,8 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
|
|
||||||
const agent = (() => {
|
const agent = (() => {
|
||||||
const list = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden))
|
const list = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden))
|
||||||
|
const models = useModels()
|
||||||
|
|
||||||
const [store, setStore] = createStore<{
|
const [store, setStore] = createStore<{
|
||||||
current?: string
|
current?: string
|
||||||
}>({
|
}>({
|
||||||
@@ -53,11 +55,17 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
setStore("current", undefined)
|
setStore("current", undefined)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (name && available.some((x) => x.name === name)) {
|
const match = name ? available.find((x) => x.name === name) : undefined
|
||||||
setStore("current", name)
|
const value = match ?? available[0]
|
||||||
return
|
if (!value) return
|
||||||
}
|
setStore("current", value.name)
|
||||||
setStore("current", available[0].name)
|
if (!value.model) return
|
||||||
|
setModel({
|
||||||
|
providerID: value.model.providerID,
|
||||||
|
modelID: value.model.modelID,
|
||||||
|
})
|
||||||
|
if (value.variant)
|
||||||
|
models.variant.set({ providerID: value.model.providerID, modelID: value.model.modelID }, value.variant)
|
||||||
},
|
},
|
||||||
move(direction: 1 | -1) {
|
move(direction: 1 | -1) {
|
||||||
const available = list()
|
const available = list()
|
||||||
@@ -71,11 +79,13 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
const value = available[next]
|
const value = available[next]
|
||||||
if (!value) return
|
if (!value) return
|
||||||
setStore("current", value.name)
|
setStore("current", value.name)
|
||||||
if (value.model)
|
if (!value.model) return
|
||||||
setModel({
|
setModel({
|
||||||
providerID: value.model.providerID,
|
providerID: value.model.providerID,
|
||||||
modelID: value.model.modelID,
|
modelID: value.model.modelID,
|
||||||
})
|
})
|
||||||
|
if (value.variant)
|
||||||
|
models.variant.set({ providerID: value.model.providerID, modelID: value.model.modelID }, value.variant)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -416,7 +416,10 @@ export default function Page() {
|
|||||||
() => {
|
() => {
|
||||||
const msg = lastUserMessage()
|
const msg = lastUserMessage()
|
||||||
if (!msg) return
|
if (!msg) return
|
||||||
if (msg.agent) local.agent.set(msg.agent)
|
if (msg.agent) {
|
||||||
|
local.agent.set(msg.agent)
|
||||||
|
if (local.agent.current()?.model) return
|
||||||
|
}
|
||||||
if (msg.model) local.model.set(msg.model)
|
if (msg.model) local.model.set(msg.model)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user