-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<template> | ||
<n-scrollbar x-scrollable> | ||
<n-table :single-line="false" striped class="w-max min-w-full"> | ||
<thead> | ||
<tr class="text-center"> | ||
<th width="240">模型名称</th> | ||
<th width="130">Token 输入倍率</th> | ||
<th width="130">Token 输出倍率</th> | ||
<th width="130">最大 Token</th> | ||
<th width="70">付费标志</th> | ||
<th>选中提示</th> | ||
<th width="70">启用</th> | ||
<th width="70">删除</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(item, index) in modelConfigsData" :key="index"> | ||
<td> | ||
<n-input v-model:value="item.model" /> | ||
</td> | ||
<td> | ||
<n-input-number v-model:value="item.inputTokenMultiple" :min="0" /> | ||
</td> | ||
<td> | ||
<n-input-number v-model:value="item.outputTokenMultiple" :min="0" /> | ||
</td> | ||
<td><n-input-number v-model:value="item.maxTokens" :min="0" /></td> | ||
<td class="text-center"><n-switch v-model:value="item.paying" /></td> | ||
<td><n-input v-model:value="item.tips" type="textarea" :rows="2" /></td> | ||
<td class="text-center"><n-switch v-model:value="item.enable" /></td> | ||
<td> | ||
<n-popconfirm :on-positive-click="() => handleDeleteModel(index)"> | ||
<template #default>确认删除?</template> | ||
<template #trigger> | ||
<n-button text block type="primary">删除</n-button> | ||
</template> | ||
</n-popconfirm> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</n-table> | ||
<n-space justify="center" class="mt-2"> | ||
<n-button type="primary" @click="handleAddModelConfig"> | ||
<icon-ic-round-plus class="mr-4px text-20px" /> | ||
增加一项 | ||
</n-button> | ||
</n-space> | ||
</n-scrollbar> | ||
</template> | ||
|
||
<script setup lang="tsx"> | ||
import { watch, reactive } from 'vue'; | ||
export interface Props { | ||
modelConfigs: any[]; | ||
} | ||
export interface Emit { | ||
(e: 'update:modelConfigs', modelConfigs: any[]): void; | ||
} | ||
const props = defineProps<Props>(); | ||
const emit = defineEmits<Emit>(); | ||
const modelConfigsData = reactive( | ||
(() => { | ||
return props.modelConfigs.map(item => { | ||
return { | ||
...item, | ||
enable: item.enable === undefined ? true : item.enable, | ||
inputTokenMultiple: parseFloat(item.inputTokenMultiple), | ||
outputTokenMultiple: parseFloat(item.outputTokenMultiple) | ||
}; | ||
}); | ||
})() | ||
); | ||
watch(modelConfigsData, value => { | ||
emit('update:modelConfigs', value); | ||
}); | ||
function handleDeleteModel(index: number) { | ||
modelConfigsData.splice(index, 1); | ||
} | ||
function handleAddModelConfig() { | ||
modelConfigsData.push({ | ||
model: '', | ||
inputTokenMultiple: 1, | ||
outputTokenMultiple: 1, | ||
maxTokens: 4096, | ||
tips: '', | ||
enable: true | ||
}); | ||
} | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters