@@ -19,23 +19,34 @@ const showModal = ref(false)
1919const editingName = ref <string | null >(null )
2020const showApiKey = ref (false )
2121const form = ref <ModelConfig >({
22- name: ' ' , provider: ModelProvider .OpenAI , baseURL: ' ' , apiKey: ' ' , model: ' ' , apiVersion: undefined , temperature: undefined , maxTokens: undefined , contextWindow: undefined , thinking : undefined ,
22+ name: ' ' , provider: ModelProvider .OpenAI , baseURL: ' ' , apiKey: ' ' , model: ' ' , temperature: undefined , maxTokens: undefined , contextWindow: undefined ,
2323})
2424
2525const isOllama = computed (() => form .value .provider === ModelProvider .Ollama )
2626const isAnthropic = computed (() => form .value .provider === ModelProvider .Anthropic )
2727const isGemini = computed (() => form .value .provider === ModelProvider .Gemini || form .value .provider === ModelProvider .GeminiImage )
2828
2929const thinkingType = computed ({
30- get : () => form .value .thinking ?.type ?? ' ' ,
30+ get : () => form .value .anthropic ?. thinking ?.type ?? ' ' ,
3131 set : (v : string ) => {
32- if (! v ) { form .value .thinking = undefined ; return }
33- form .value .thinking = { type: v as any , ... (v === ' enabled' ? { budgetTokens: form .value .thinking ?.budgetTokens ?? 8192 } : {}) }
32+ if (! v ) { form .value .anthropic = { ... form .value .anthropic , thinking: undefined }; return }
33+ form .value .anthropic = {
34+ ... form .value .anthropic ,
35+ thinking: { type: v as any , ... (v === ' enabled' ? { budgetTokens: form .value .anthropic ?.thinking ?.budgetTokens ?? 8192 } : {}) },
36+ }
3437 },
3538})
3639const thinkingBudget = computed ({
37- get : () => form .value .thinking ?.budgetTokens ,
38- set : (v : number | undefined ) => { if (form .value .thinking ) form .value .thinking .budgetTokens = v },
40+ get : () => form .value .anthropic ?.thinking ?.budgetTokens ,
41+ set : (v : number | undefined ) => { if (form .value .anthropic ?.thinking ) form .value .anthropic .thinking .budgetTokens = v },
42+ })
43+ const promptCaching = computed ({
44+ get : () => form .value .anthropic ?.promptCaching ?? false ,
45+ set : (v : boolean ) => { form .value .anthropic = { ... form .value .anthropic , promptCaching: v || undefined } },
46+ })
47+ const geminiApiVersion = computed ({
48+ get : () => form .value .gemini ?.apiVersion ?? ' ' ,
49+ set : (v : string ) => { form .value .gemini = { ... form .value .gemini , apiVersion: v || undefined } },
3950})
4051
4152
@@ -76,7 +87,7 @@ function pickModel(m: string) {
7687function openAdd() {
7788 editingName .value = null
7889 showApiKey .value = false
79- form .value = { name: ' ' , provider: ModelProvider .OpenAI , baseURL: ' ' , apiKey: ' ' , model: ' ' , apiVersion: undefined , temperature: undefined , maxTokens: undefined , contextWindow: undefined }
90+ form .value = { name: ' ' , provider: ModelProvider .OpenAI , baseURL: ' ' , apiKey: ' ' , model: ' ' , temperature: undefined , maxTokens: undefined , contextWindow: undefined }
8091 showModal .value = true
8192}
8293
@@ -90,10 +101,11 @@ function openEdit(id: string) {
90101 baseURL: m .baseURL ,
91102 apiKey: m .apiKey ,
92103 model: m .model ,
93- apiVersion: m .apiVersion ,
94104 temperature: m .temperature ,
95105 maxTokens: m .maxTokens ,
96106 contextWindow: m .contextWindow ,
107+ anthropic: m .anthropic ? { ... m .anthropic } : undefined ,
108+ gemini: m .gemini ? { ... m .gemini } : undefined ,
97109 }
98110 showModal .value = true
99111}
@@ -108,9 +120,16 @@ async function save() {
108120 if (body .temperature === undefined || body .temperature === null ) delete body .temperature
109121 if (body .maxTokens === undefined || body .maxTokens === null ) delete body .maxTokens
110122 if (body .contextWindow === undefined || body .contextWindow === null ) delete body .contextWindow
111- if (! body .apiVersion ) delete body .apiVersion
112- if (! body .thinking ) delete body .thinking
113- else if (body .thinking .type !== ' enabled' ) delete body .thinking .budgetTokens
123+ if (body .anthropic ) {
124+ if (! body .anthropic .thinking ) delete body .anthropic .thinking
125+ else if (body .anthropic .thinking .type !== ' enabled' ) delete body .anthropic .thinking .budgetTokens
126+ if (! body .anthropic .promptCaching ) delete body .anthropic .promptCaching
127+ if (! Object .keys (body .anthropic ).length ) delete body .anthropic
128+ }
129+ if (body .gemini ) {
130+ if (! body .gemini .apiVersion ) delete body .gemini .apiVersion
131+ if (! Object .keys (body .gemini ).length ) delete body .gemini
132+ }
114133 const id = editingName .value
115134 const res = id
116135 ? await apiFetch (` /api/settings/models/${encodeURIComponent (id )} ` , ' PUT' , body )
@@ -257,7 +276,7 @@ async function refresh() {
257276 </div >
258277 <div v-if =" isGemini" class =" form-group" >
259278 <label >{{ t('models.api_version') }}</label >
260- <input v-model =" form.apiVersion " placeholder =" v1beta" />
279+ <input v-model =" geminiApiVersion " placeholder =" v1beta" />
261280 </div >
262281 <div class =" form-group" >
263282 <label >{{ t('models.temperature') }}</label >
@@ -284,6 +303,10 @@ async function refresh() {
284303 <label >{{ t('models.thinking_budget') }}</label >
285304 <input v-model.number =" thinkingBudget" type =" number" step =" 1024" placeholder =" 8192" />
286305 </div >
306+ <div v-if =" isAnthropic" class =" form-group" >
307+ <label >{{ t('models.prompt_caching') }}</label >
308+ <label class =" checkbox-label" ><input type =" checkbox" v-model =" promptCaching" /> {{ t('models.prompt_caching_desc') }}</label >
309+ </div >
287310 </div >
288311 <div class =" modal-footer" >
289312 <button class =" btn-outline" @click =" showModal = false" >{{ t('common.cancel') }}</button >
0 commit comments