Commit e02481b6 authored by nick zheng's avatar nick zheng

feat: ai生成应用开场白和推荐问

parent d2884c07
......@@ -68,3 +68,23 @@ export function fetchGetLargeModelList<T>() {
export function fetchCreateDialogues<T>(agentId: string) {
return request.post<T>(`/agentApplicationRest/createDialogues.json?agentId=${agentId}`)
}
/**
* * @param { agentTitle: 标题 agentDesc: 描述 }
* @returns AI生成开场白
*/
export function fetchCreatePreamble<T>(payload: { agentTitle: string; agentDesc: string }) {
return request.post<T>('/agentApplicationInfoRest/createPreamble.json', payload, {
timeout: 120000,
})
}
/**
* * @param { agentTitle: 标题 agentDesc: 描述 }
* @returns AI生成推荐问
*/
export function fetchCreateFeaturedQuestions<T>(payload: { agentTitle: string; agentDesc: string }) {
return request.post<T>('/agentApplicationInfoRest/createFeaturedQuestions.json', payload, {
timeout: 120000,
})
}
......@@ -9,6 +9,8 @@ import UploadPhoto from '@/components/upload-photo/upload-photo.vue'
import { usePersonalAppConfigStore } from '@/store/modules/personal-app-config'
import { PersonalAppConfigState } from '@/store/types/personal-app-config'
import {
fetchCreateFeaturedQuestions,
fetchCreatePreamble,
fetchGetDebugApplicationInfo,
fetchGetLargeModelList,
fetchSaveAgentApplication,
......@@ -56,7 +58,6 @@ const showAdditionalPromptModal = ref(false)
const isInitGetAgentAppDetail = ref(false)
// const generateAgentAvatarLoading = ref(false) // 是否正在生成头像
const generatePreambleLoading = ref(false) // 是否正在生成开场白
const generateFeaturedQuestionsLoading = ref(false) // 是否正在生成推荐词
......@@ -176,35 +177,36 @@ function handleUpdateCommConfigExpandedNames(expandedNames: any) {
commConfigExpandedNames.value = expandedNames
}
// function handleGenerateAgentAvatar() {
// personalAppConfig.value.baseInfo.agentDesc = '22'
// generateAgentAvatarLoading.value = true
async function handleAIGeneratePreamble() {
!commConfigExpandedNames.value.includes('preamble') && commConfigExpandedNames.value.push('preamble')
// setTimeout(() => {
// generateAgentAvatarLoading.value = false
// }, 2000)
// }
generatePreambleLoading.value = true
// function handleAIGeneratePreamble() {
// !commConfigExpandedNames.value.includes('preamble') && commConfigExpandedNames.value.push('preamble')
const res = await fetchCreatePreamble({
agentTitle: personalAppConfig.value.baseInfo.agentTitle,
agentDesc: personalAppConfig.value.baseInfo.agentDesc,
}).finally(() => (generatePreambleLoading.value = false))
// generatePreambleLoading.value = true
if (res.code === 0) {
personalAppConfig.value.commConfig.preamble = res.data as string
}
}
// setTimeout(() => {
// generatePreambleLoading.value = false
// }, 2000)
// }
async function handleAIGenerateFeaturedQuestions() {
!commConfigExpandedNames.value.includes('featuredQuestions') &&
commConfigExpandedNames.value.push('featuredQuestions')
// function handleAIGenerateFeaturedQuestions() {
// !commConfigExpandedNames.value.includes('featuredQuestions') &&
// commConfigExpandedNames.value.push('featuredQuestions')
generateFeaturedQuestionsLoading.value = true
// generateFeaturedQuestionsLoading.value = true
const res = await fetchCreateFeaturedQuestions<string[]>({
agentTitle: personalAppConfig.value.baseInfo.agentTitle,
agentDesc: personalAppConfig.value.baseInfo.agentDesc,
}).finally(() => (generateFeaturedQuestionsLoading.value = false))
// setTimeout(() => {
// generateFeaturedQuestionsLoading.value = false
// }, 2000)
// }
if (res.code === 0) {
personalAppConfig.value.commConfig.featuredQuestions = res.data
}
}
</script>
<template>
......@@ -457,7 +459,7 @@ function handleUpdateCommConfigExpandedNames(expandedNames: any) {
<CustomIcon icon="gravity-ui:caret-right" />
</template>
<NCollapseItem title="开场白" name="preamble" class="my-[13px]!">
<!-- <template #header-extra>
<template #header-extra>
<NTooltip trigger="hover">
<template #trigger>
<div
......@@ -472,7 +474,7 @@ function handleUpdateCommConfigExpandedNames(expandedNames: any) {
</template>
AI生成
</NTooltip>
</template> -->
</template>
<NInput
v-model:value="personalAppConfig.commConfig.preamble"
type="textarea"
......@@ -483,8 +485,8 @@ function handleUpdateCommConfigExpandedNames(expandedNames: any) {
/>
</NCollapseItem>
<NCollapseItem title="推荐" name="featuredQuestions" class="my-[13px]!">
<!-- <template #header-extra>
<NCollapseItem title="推荐" name="featuredQuestions" class="my-[13px]!">
<template #header-extra>
<NTooltip trigger="hover">
<template #trigger>
<div
......@@ -499,10 +501,10 @@ function handleUpdateCommConfigExpandedNames(expandedNames: any) {
</template>
AI生成
</NTooltip>
</template> -->
</template>
<NDynamicInput
v-model:value="personalAppConfig.commConfig.featuredQuestions"
placeholder="请输入推荐"
placeholder="请输入推荐"
class="rounded-md"
:min="1"
:max="3"
......
......@@ -44,12 +44,7 @@ function handleSelectFeaturedQuestion(featuredQuestion: string) {
class="w-full cursor-pointer rounded-xl border border-[#d4d6d9] bg-[#ffffff80] px-[14px] py-[11px] hover:opacity-80"
@click="handleSelectFeaturedQuestion(featuredQuestionItem)"
>
<NPopover trigger="hover">
<template #trigger>
<span class="break-all">{{ featuredQuestionItem }}</span>
</template>
<span>{{ featuredQuestionItem }}</span>
</NPopover>
<span class="break-all">{{ featuredQuestionItem }}</span>
</div>
</li>
</ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment