mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-05-10 11:44:28 +08:00
optimize jimeng power config
This commit is contained in:
@@ -341,6 +341,7 @@
|
||||
// 提示词指南样式
|
||||
.prompt-guide {
|
||||
margin: 12px 0 16px;
|
||||
background-color: var(--el-fill-color-blank);
|
||||
|
||||
.guide-title {
|
||||
display: flex;
|
||||
|
||||
@@ -36,7 +36,7 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
const shareStore = useSharedStore()
|
||||
|
||||
// 积分消耗配置
|
||||
const powerConfig = reactive({})
|
||||
const powerConfig = reactive({ powers: {} })
|
||||
const currentPowerCost = ref('0积分')
|
||||
|
||||
// 功能配置
|
||||
@@ -83,12 +83,10 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
// 获取状态类型
|
||||
const getTaskType = (type) => {
|
||||
const typeMap = {
|
||||
text_to_image: 'primary',
|
||||
image_to_image: 'primary',
|
||||
image_edit: 'primary',
|
||||
image_effects: 'primary',
|
||||
text_to_video: 'success',
|
||||
image_to_video: 'success',
|
||||
image: 'info',
|
||||
video: 'primary',
|
||||
virtual_human: 'success',
|
||||
action_transfer: 'warning',
|
||||
}
|
||||
return typeMap[type] || 'primary'
|
||||
}
|
||||
@@ -124,7 +122,7 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
}
|
||||
|
||||
total.value = data.total || 0
|
||||
if (data.items.length < pageSize.value) {
|
||||
if (!data.items || data.items.length < pageSize.value) {
|
||||
isOver.value = true
|
||||
}
|
||||
if (pageNum === 1) {
|
||||
@@ -150,7 +148,7 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
page_size: 20,
|
||||
})
|
||||
const data = response.data
|
||||
if (data.items.length === 0) {
|
||||
if (!data.items || data.items.length === 0) {
|
||||
stopPolling()
|
||||
return
|
||||
}
|
||||
@@ -184,7 +182,6 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
shareStore.setShowLoginDialog(true)
|
||||
return
|
||||
}
|
||||
console.log(formData.value)
|
||||
for (const key in requiredKeys.value) {
|
||||
if (!formData.value[key]) {
|
||||
showMessageError('缺少参数:' + requiredKeys.value[key].label)
|
||||
@@ -284,20 +281,32 @@ export const useJimengStore = defineStore('jimeng', () => {
|
||||
}
|
||||
|
||||
const setFunctionPowers = () => {
|
||||
if (activeFunction.value === 'image') {
|
||||
currentPowerCost.value = `${powerConfig.image}积分/张`
|
||||
} else {
|
||||
currentPowerCost.value = `${powerConfig.video}积分/秒`
|
||||
}
|
||||
nextTick(() => {
|
||||
const key = formData.value.req_key
|
||||
const perUnit = key ? powerConfig.powers[key] : 0
|
||||
if (!perUnit) {
|
||||
currentPowerCost.value = '未配置积分'
|
||||
return
|
||||
}
|
||||
currentPowerCost.value =
|
||||
activeFunction.value === 'image' ? `${perUnit}积分/张` : `${perUnit}积分/秒`
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formData.value,
|
||||
() => {
|
||||
setFunctionPowers()
|
||||
}
|
||||
)
|
||||
|
||||
// 初始化方法
|
||||
const init = async () => {
|
||||
try {
|
||||
// 获取积分消耗配置
|
||||
const powerRes = await httpGet('/api/jimeng/power-config')
|
||||
if (powerRes.data) {
|
||||
Object.assign(powerConfig, powerRes.data)
|
||||
powerConfig.powers = powerRes.data.powers || {}
|
||||
setFunctionPowers()
|
||||
}
|
||||
const user = await checkSession()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 提示词编写指南(可折叠) -->
|
||||
<div class="prompt-guide">
|
||||
<div class="prompt-guide pl-2">
|
||||
<el-collapse v-model="guideActive">
|
||||
<el-collapse-item name="guide">
|
||||
<template #title>
|
||||
|
||||
@@ -82,59 +82,44 @@
|
||||
<el-divider />
|
||||
<!-- 算力配置分组 -->
|
||||
<div class="mb-3">
|
||||
<h3 class="heading-3 mb-3">算力配置</h3>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="text-gray-500 text-sm">
|
||||
生成图片消耗的积分,包括:文生图、图生图、图片编辑、图片特效,<el-tag type="primary"
|
||||
>单位:积分/张</el-tag
|
||||
>
|
||||
<h3 class="heading-3 mb-3">任务积分配置</h3>
|
||||
<Alert type="info" class="mb-3">
|
||||
<div class="text-gray-500">
|
||||
图片类模型统一都是 0.2 元一张,假如你100积分售价1元,建议设置:20积分/张。
|
||||
</div>
|
||||
<div class="text-gray-500">
|
||||
视频/数字人/动作迁移单位:积分/秒,但是不同的模型的价格不一样,建议去火山方舟控制台查看,根据价格设置积分。
|
||||
</div>
|
||||
</Alert>
|
||||
|
||||
<div v-for="func in functions" :key="func.key" class="mb-4">
|
||||
<h4 class="mb-2 text-base font-bold flex items-center gap-2">
|
||||
<i class="iconfont" :class="func.icon"></i>
|
||||
{{ func.name }}
|
||||
<el-tag size="small" type="info">{{ getUnit(func.key) }}</el-tag>
|
||||
</h4>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div
|
||||
v-for="model in params[func.key]"
|
||||
:key="model.key"
|
||||
class="p-3 rounded-md border border-gray-100"
|
||||
>
|
||||
<div class="text-sm mb-2">
|
||||
<div class="font-bold">{{ model.name }}</div>
|
||||
<div class="text-gray-500 line-clamp-2" :title="model.label">
|
||||
{{ model.label }}
|
||||
</div>
|
||||
</div>
|
||||
<el-input-number
|
||||
v-model="jimengConfig.powers[model.key]"
|
||||
:min="1"
|
||||
:placeholder="`对应模型:${model.key}(${getUnit(func.key)})`"
|
||||
class="w-full"
|
||||
/>
|
||||
<div class="text-xs text-gray-400 mt-1">对应模型:{{ model.key }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="jimengConfig.power.image"
|
||||
:min="1"
|
||||
placeholder="请输入图片生成算力消耗"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="text-gray-500 text-sm">
|
||||
生成视频消耗的积分,包括:文生视频、图生视频,<el-tag type="primary"
|
||||
>单位:积分/秒</el-tag
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="jimengConfig.power.video"
|
||||
:min="1"
|
||||
placeholder="请输入视频生成算力消耗"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="text-gray-500 text-sm">
|
||||
生成数字人视频消耗的积分,<el-tag type="primary">单位:积分/秒</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="jimengConfig.power.virtual_human"
|
||||
:min="1"
|
||||
placeholder="请输入数字人视频生成算力消耗"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="text-gray-500 text-sm">
|
||||
生成视频动作迁移消耗的积分,<el-tag type="primary">单位:积分/秒</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="jimengConfig.power.action_transfer"
|
||||
:min="1"
|
||||
placeholder="请输入视频动作迁移算力消耗"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 10px">
|
||||
<el-form-item>
|
||||
@@ -149,6 +134,7 @@
|
||||
|
||||
<script setup>
|
||||
import Alert from '@/components/ui/Alert.vue'
|
||||
import { JimengFunctions, JimengParams } from '@/store/data/jimeng_params'
|
||||
import { httpGet, httpPost } from '@/utils/http'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
@@ -156,20 +142,15 @@ import { onMounted, ref } from 'vue'
|
||||
const jimengConfig = ref({
|
||||
access_key: '',
|
||||
secret_key: '',
|
||||
power: {
|
||||
text_to_image: 10,
|
||||
image_to_image: 15,
|
||||
image_edit: 20,
|
||||
image_effects: 25,
|
||||
text_to_video: 30,
|
||||
image_to_video: 35,
|
||||
},
|
||||
api_key: '',
|
||||
powers: {},
|
||||
})
|
||||
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const testing = ref(false)
|
||||
const configFormRef = ref()
|
||||
const functions = JimengFunctions
|
||||
const params = JimengParams
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
@@ -177,6 +158,8 @@ const rules = {
|
||||
secret_key: [{ required: true, message: '请输入SecretKey', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
const getUnit = (funcKey) => (funcKey === 'image' ? '积分/张' : '积分/秒')
|
||||
|
||||
onMounted(() => {
|
||||
loadConfig()
|
||||
})
|
||||
@@ -185,7 +168,9 @@ onMounted(() => {
|
||||
const loadConfig = async () => {
|
||||
try {
|
||||
const res = await httpGet('/api/admin/config/get?key=jimeng')
|
||||
jimengConfig.value = res.data
|
||||
const cfg = res.data || {}
|
||||
cfg.powers = cfg.powers || {}
|
||||
jimengConfig.value = cfg
|
||||
} catch (e) {
|
||||
ElMessage.error('加载配置失败: ' + e.message)
|
||||
} finally {
|
||||
@@ -214,14 +199,8 @@ const resetConfig = () => {
|
||||
jimengConfig.value = {
|
||||
access_key: '',
|
||||
secret_key: '',
|
||||
power: {
|
||||
text_to_image: 10,
|
||||
image_to_image: 15,
|
||||
image_edit: 20,
|
||||
image_effects: 25,
|
||||
text_to_video: 30,
|
||||
image_to_video: 35,
|
||||
},
|
||||
api_key: '',
|
||||
powers: {},
|
||||
}
|
||||
ElMessage.info('配置已重置')
|
||||
}
|
||||
@@ -237,7 +216,7 @@ const resetConfig = () => {
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
.heading-3 {
|
||||
|
||||
Reference in New Issue
Block a user