-
Notifications
You must be signed in to change notification settings - Fork 663
Expand file tree
/
Copy pathModelConfigItem.vue
More file actions
124 lines (118 loc) · 3.35 KB
/
ModelConfigItem.vue
File metadata and controls
124 lines (118 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<div
:class="[
'flex flex-row bg-muted/50 hover:bg-accent items-center gap-2 px-3 py-2 border-b last:border-none transition-colors'
]"
>
<div class="flex gap-1 items-center">
<span class="text-xs" :class="!enabled ? 'text-foreground/70' : ''">
{{ modelName }}
</span>
<Icon v-if="vision" icon="lucide:eye" class="w-4 h-4 text-blue-500" title="视觉能力" />
<Icon
v-if="functionCall"
icon="lucide:function-square"
class="w-4 h-4 text-orange-500"
title="函数调用能力"
/>
<Icon v-if="reasoning" icon="lucide:brain" class="w-4 h-4 text-purple-500" title="推理能力" />
<Icon
v-if="enableSearch"
icon="lucide:globe"
class="w-4 h-4 text-green-500"
title="联网搜索能力"
/>
</div>
<div class="grow"></div>
<div class="flex flex-row items-center gap-2">
<span v-if="group && group !== 'default'" class="text-xs text-muted-foreground">{{
group
}}</span>
<span
class="px-2 py-0.5 rounded-full bg-muted text-xs text-muted-foreground border border-muted-foreground/20 select-none"
>
{{ type }}
</span>
<Switch
v-if="!hideEnableToggle"
:key="`${providerId}:${modelId}`"
:model-value="enabled"
@update:model-value="onEnabledChange"
/>
<Button
v-if="changeable"
variant="link"
size="icon"
class="w-7 h-7 text-xs text-normal rounded-lg"
@click="onConfigModel"
:title="$t('settings.model.configureModel')"
>
<Icon icon="lucide:settings" class="w-4 h-4 text-muted-foreground" />
</Button>
<Button
v-if="isCustomModel"
variant="link"
size="icon"
class="w-7 h-7 text-xs text-normal rounded-lg"
@click="onDeleteModel"
>
<Icon icon="lucide:trash-2" class="w-4 h-4 text-destructive" />
</Button>
</div>
</div>
<!-- 模型配置对话框 -->
<ModelConfigDialog
v-model:open="showConfigDialog"
:model-id="modelId"
:model-name="modelName"
:provider-id="providerId"
mode="edit"
:is-custom-model="isCustomModel"
@saved="onConfigSaved"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@shadcn/components/ui/button'
import { Switch } from '@shadcn/components/ui/switch'
import { Icon } from '@iconify/vue'
import { ModelType } from '@shared/model'
import ModelConfigDialog from './ModelConfigDialog.vue'
withDefaults(
defineProps<{
modelName: string
modelId: string
providerId: string
group?: string
enabled: boolean
isCustomModel?: boolean
vision?: boolean
functionCall?: boolean
reasoning?: boolean
enableSearch?: boolean
type?: ModelType
changeable?: boolean
hideEnableToggle?: boolean
}>(),
{
type: ModelType.Chat,
changeable: true,
hideEnableToggle: false
}
)
const emit = defineEmits<{
enabledChange: [boolean]
deleteModel: []
configChanged: []
}>()
// 配置对话框状态
const showConfigDialog = ref(false)
const onEnabledChange = (enabled: boolean) => emit('enabledChange', enabled)
const onDeleteModel = () => emit('deleteModel')
const onConfigModel = () => {
showConfigDialog.value = true
}
const onConfigSaved = () => {
emit('configChanged')
}
</script>