Commit e02481b6 authored by nick zheng's avatar nick zheng

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

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