mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-08 16:32:43 +08:00
【代码重构】AI:“聊天模型”重构为“模型”,支持 type 模型类型
This commit is contained in:
parent
ae632ac23b
commit
2ef484e700
@ -95,7 +95,13 @@
|
|||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<el-button type="primary" size="large" round @click="handleGenerateImage">
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
round
|
||||||
|
:disabled="prompt.length === 0"
|
||||||
|
@click="handleGenerateImage"
|
||||||
|
>
|
||||||
{{ drawIn ? '生成中' : '生成内容' }}
|
{{ drawIn ? '生成中' : '生成内容' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -112,9 +118,19 @@ import {
|
|||||||
MidjourneyVersions,
|
MidjourneyVersions,
|
||||||
NijiVersionList
|
NijiVersionList
|
||||||
} from '@/views/ai/utils/constants'
|
} from '@/views/ai/utils/constants'
|
||||||
|
import { ModelVO } from '@/api/ai/model/model'
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
// 接收父组件传入的模型列表
|
||||||
|
const props = defineProps({
|
||||||
|
models: {
|
||||||
|
type: Array<ModelVO>,
|
||||||
|
default: () => [] as ModelVO[]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
|
||||||
|
|
||||||
// 定义属性
|
// 定义属性
|
||||||
const drawIn = ref<boolean>(false) // 生成中
|
const drawIn = ref<boolean>(false) // 生成中
|
||||||
const selectHotWord = ref<string>('') // 选中的热词
|
const selectHotWord = ref<string>('') // 选中的热词
|
||||||
@ -125,7 +141,6 @@ const selectModel = ref<string>('midjourney') // 选中的模型
|
|||||||
const selectSize = ref<string>('1:1') // 选中 size
|
const selectSize = ref<string>('1:1') // 选中 size
|
||||||
const selectVersion = ref<any>('6.0') // 选中的 version
|
const selectVersion = ref<any>('6.0') // 选中的 version
|
||||||
const versionList = ref<any>(MidjourneyVersions) // version 列表
|
const versionList = ref<any>(MidjourneyVersions) // version 列表
|
||||||
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
|
|
||||||
|
|
||||||
/** 选择热词 */
|
/** 选择热词 */
|
||||||
const handleHotWordClick = async (hotWord: string) => {
|
const handleHotWordClick = async (hotWord: string) => {
|
||||||
@ -158,6 +173,15 @@ const handleModelClick = async (model: ImageModelVO) => {
|
|||||||
|
|
||||||
/** 图片生成 */
|
/** 图片生成 */
|
||||||
const handleGenerateImage = async () => {
|
const handleGenerateImage = async () => {
|
||||||
|
// 从 models 中查找匹配的模型
|
||||||
|
const matchedModel = props.models.find(
|
||||||
|
(item) => item.model === selectModel.value && item.platform === AiPlatformEnum.MIDJOURNEY
|
||||||
|
)
|
||||||
|
if (!matchedModel) {
|
||||||
|
message.error('该模型不可用,请选择其它模型')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 二次确认
|
// 二次确认
|
||||||
await message.confirm(`确认生成内容?`)
|
await message.confirm(`确认生成内容?`)
|
||||||
try {
|
try {
|
||||||
@ -171,7 +195,7 @@ const handleGenerateImage = async () => {
|
|||||||
) as ImageSizeVO
|
) as ImageSizeVO
|
||||||
const req = {
|
const req = {
|
||||||
prompt: prompt.value,
|
prompt: prompt.value,
|
||||||
model: selectModel.value,
|
modelId: matchedModel.id,
|
||||||
width: imageSize.width,
|
width: imageSize.width,
|
||||||
height: imageSize.height,
|
height: imageSize.height,
|
||||||
version: selectVersion.value,
|
version: selectVersion.value,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="prompt"
|
v-model="prompt"
|
||||||
maxlength="1024"
|
maxlength="1024"
|
||||||
rows="5"
|
:rows="5"
|
||||||
class="w-100% mt-15px"
|
class="w-100% mt-15px"
|
||||||
input-style="border-radius: 7px;"
|
input-style="border-radius: 7px;"
|
||||||
placeholder="例如:童话里的小屋应该是什么样子?"
|
placeholder="例如:童话里的小屋应该是什么样子?"
|
||||||
@ -128,7 +128,14 @@
|
|||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<el-button type="primary" size="large" round :loading="drawIn" @click="handleGenerateImage">
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
round
|
||||||
|
:loading="drawIn"
|
||||||
|
:disabled="prompt.length === 0"
|
||||||
|
@click="handleGenerateImage"
|
||||||
|
>
|
||||||
{{ drawIn ? '生成中' : '生成内容' }}
|
{{ drawIn ? '生成中' : '生成内容' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -143,9 +150,19 @@ import {
|
|||||||
StableDiffusionSamplers,
|
StableDiffusionSamplers,
|
||||||
StableDiffusionStylePresets
|
StableDiffusionStylePresets
|
||||||
} from '@/views/ai/utils/constants'
|
} from '@/views/ai/utils/constants'
|
||||||
|
import { ModelVO } from '@/api/ai/model/model'
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
// 接收父组件传入的模型列表
|
||||||
|
const props = defineProps({
|
||||||
|
models: {
|
||||||
|
type: Array<ModelVO>,
|
||||||
|
default: () => [] as ModelVO[]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
|
||||||
|
|
||||||
// 定义属性
|
// 定义属性
|
||||||
const drawIn = ref<boolean>(false) // 生成中
|
const drawIn = ref<boolean>(false) // 生成中
|
||||||
const selectHotWord = ref<string>('') // 选中的热词
|
const selectHotWord = ref<string>('') // 选中的热词
|
||||||
@ -160,8 +177,6 @@ const scale = ref<number>(7.5) // 引导系数
|
|||||||
const clipGuidancePreset = ref<string>('NONE') // 文本提示相匹配的图像(clip_guidance_preset) 简称 CLIP
|
const clipGuidancePreset = ref<string>('NONE') // 文本提示相匹配的图像(clip_guidance_preset) 简称 CLIP
|
||||||
const stylePreset = ref<string>('3d-model') // 风格
|
const stylePreset = ref<string>('3d-model') // 风格
|
||||||
|
|
||||||
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
|
|
||||||
|
|
||||||
/** 选择热词 */
|
/** 选择热词 */
|
||||||
const handleHotWordClick = async (hotWord: string) => {
|
const handleHotWordClick = async (hotWord: string) => {
|
||||||
// 情况一:取消选中
|
// 情况一:取消选中
|
||||||
@ -177,6 +192,16 @@ const handleHotWordClick = async (hotWord: string) => {
|
|||||||
|
|
||||||
/** 图片生成 */
|
/** 图片生成 */
|
||||||
const handleGenerateImage = async () => {
|
const handleGenerateImage = async () => {
|
||||||
|
// 从 models 中查找匹配的模型
|
||||||
|
const selectModel = 'stable-diffusion-v1-6'
|
||||||
|
const matchedModel = props.models.find(
|
||||||
|
(item) => item.model === selectModel && item.platform === AiPlatformEnum.STABLE_DIFFUSION
|
||||||
|
)
|
||||||
|
if (!matchedModel) {
|
||||||
|
message.error('该模型不可用,请选择其它模型')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 二次确认
|
// 二次确认
|
||||||
if (hasChinese(prompt.value)) {
|
if (hasChinese(prompt.value)) {
|
||||||
message.alert('暂不支持中文!')
|
message.alert('暂不支持中文!')
|
||||||
@ -191,8 +216,7 @@ const handleGenerateImage = async () => {
|
|||||||
emits('onDrawStart', AiPlatformEnum.STABLE_DIFFUSION)
|
emits('onDrawStart', AiPlatformEnum.STABLE_DIFFUSION)
|
||||||
// 发送请求
|
// 发送请求
|
||||||
const form = {
|
const form = {
|
||||||
platform: AiPlatformEnum.STABLE_DIFFUSION,
|
modelId: matchedModel.id,
|
||||||
model: 'stable-diffusion-v1-6',
|
|
||||||
prompt: prompt.value, // 提示词
|
prompt: prompt.value, // 提示词
|
||||||
width: width.value, // 图片宽度
|
width: width.value, // 图片宽度
|
||||||
height: height.value, // 图片高度
|
height: height.value, // 图片高度
|
||||||
|
Loading…
x
Reference in New Issue
Block a user