95
95
triggerStyle =" ghost"
96
96
/>
97
97
<div
98
- v-if =" isThinkingToggleable"
98
+ v-if =" isThinkingToggleable && isModelSupportsThinking "
99
99
class =" h-4 w-px bg-[#E5E7EB]"
100
100
/>
101
- <ThinkingModeSwitch v-if =" isThinkingToggleable" />
101
+ <ThinkingModeSwitch v-if =" isThinkingToggleable && isModelSupportsThinking " />
102
102
</div >
103
103
<div
104
104
ref =" sendButtonContainerRef"
128
128
129
129
<script setup lang="ts">
130
130
import { useElementBounding } from ' @vueuse/core'
131
- import { computed , onBeforeUnmount , onMounted , ref } from ' vue'
131
+ import { computed , onBeforeUnmount , onMounted , ref , toRefs , watch } from ' vue'
132
132
133
133
import IconSendFill from ' @/assets/icons/send-fill.svg?component'
134
134
import IconStop from ' @/assets/icons/stop.svg?component'
@@ -140,6 +140,7 @@ import Button from '@/components/ui/Button.vue'
140
140
import { FileGetter } from ' @/utils/file'
141
141
import { useI18n } from ' @/utils/i18n'
142
142
import { isToggleableThinkingModel } from ' @/utils/llm/thinking-models'
143
+ import { useOllamaStatusStore } from ' @/utils/pinia-store/store'
143
144
import { setSidepanelStatus } from ' @/utils/sidepanel-status'
144
145
import { getUserConfig } from ' @/utils/user-config'
145
146
import { classNames } from ' @/utils/vue/utils'
@@ -161,6 +162,8 @@ import ThinkingModeSwitch from './ThinkingModeSwitch.vue'
161
162
const inputContainerRef = ref <HTMLDivElement >()
162
163
const sendButtonContainerRef = ref <HTMLDivElement >()
163
164
const { height : inputContainerHeight } = useElementBounding (inputContainerRef )
165
+ const { modelList : ollamaModelList } = toRefs (useOllamaStatusStore ())
166
+ const { updateModelList : updateOllamaModelList } = useOllamaStatusStore ()
164
167
165
168
const { t } = useI18n ()
166
169
const userInput = ref (' ' )
@@ -172,10 +175,17 @@ defineExpose({
172
175
attachmentSelectorRef ,
173
176
})
174
177
178
+ const updateModelList = async () => {
179
+ if (endpointType .value === ' ollama' ) {
180
+ await updateOllamaModelList ()
181
+ }
182
+ }
183
+
175
184
const chat = await Chat .getInstance ()
176
185
const userConfig = await getUserConfig ()
177
186
const contextAttachmentStorage = chat .contextAttachmentStorage
178
187
const currentModel = userConfig .llm .model .toRef ()
188
+ const endpointType = userConfig .llm .endpointType .toRef ()
179
189
180
190
initChatSideEffects ()
181
191
@@ -192,6 +202,23 @@ const actionEventHandler = Chat.createActionEventHandler((actionEvent) => {
192
202
}
193
203
})
194
204
205
+ const modelList = computed (() => {
206
+ if (endpointType .value === ' ollama' ) {
207
+ return ollamaModelList .value
208
+ }
209
+ return []
210
+ })
211
+
212
+ // Check if current model supports thinking
213
+ const isModelSupportsThinking = computed (() => {
214
+ if (endpointType .value !== ' ollama' ) return false
215
+ if (! currentModel .value ) return false
216
+ if (! modelList .value || ! Array .isArray (modelList .value )) return false
217
+
218
+ const model = modelList .value .find ((m ) => m .model === currentModel .value )
219
+ return model ?.supportsThinking ?? false
220
+ })
221
+
195
222
const allowAsk = computed (() => {
196
223
return ! chat .isAnswering () && userInput .value .trim ().length > 0
197
224
})
@@ -235,9 +262,15 @@ const ask = async () => {
235
262
userInput .value = ' '
236
263
}
237
264
238
- onMounted (() => {
265
+ // Watch for model list updates to refresh thinking capabilities (following ModelSelector pattern)
266
+ watch ([endpointType , currentModel ], async () => {
267
+ await updateModelList ()
268
+ })
269
+
270
+ onMounted (async () => {
239
271
scrollContainerRef .value ?.snapToBottom ()
240
272
setSidepanelStatus ({ loaded: true })
273
+ updateModelList ()
241
274
})
242
275
243
276
onBeforeUnmount (() => {
0 commit comments