fix: 暂时切换AI服务到doubao-1.5-pro

This commit is contained in:
pipipi-pikachu 2025-02-08 20:47:15 +08:00
parent 95c86924b0
commit 9f40217183
3 changed files with 26 additions and 5 deletions

View File

@ -217,6 +217,13 @@ export default () => {
if (match) return match[1].trim()
return content.replace('```markdown', '').replace('```', '')
}
const getJSONContent = (content: string) => {
const regex = /```json([^```]*)```/
const match = content.match(regex)
if (match) return match[1].trim()
return content.replace('```json', '').replace('```', '')
}
const AIPPT = (templateSlides: Slide[], _AISlides: AIPPTSlide[], imgs?: PexelsImage[]) => {
if (imgs) imgPool.value = imgs
@ -480,5 +487,6 @@ export default () => {
return {
AIPPT,
getMdContent,
getJSONContent,
}
}

View File

@ -12,7 +12,11 @@ export default {
return axios.get(`${ASSET_URL}/data/${filename}.json`)
},
AIPPT_Outline(content: string, language: string): Promise<any> {
AIPPT_Outline(
content: string,
language: string,
model = 'doubao-1.5-pro-32k'
): Promise<any> {
return fetch(`${SERVER_URL}/tools/aippt_outline`, {
method: 'POST',
headers: {
@ -21,12 +25,21 @@ export default {
body: JSON.stringify({
content,
language,
model,
stream: true,
}),
})
},
AIPPT(content: string, language: string) {
return axios.post(`${SERVER_URL}/tools/aippt`, { content, language })
AIPPT(
content: string,
language: string,
model = 'doubao-1.5-pro-32k'
) {
return axios.post(`${SERVER_URL}/tools/aippt`, {
content,
language,
model,
})
},
}

View File

@ -68,7 +68,7 @@ import FullscreenSpin from '@/components/FullscreenSpin.vue'
const mainStore = useMainStore()
const { templates } = storeToRefs(useSlidesStore())
const { AIPPT } = useAIPPT()
const { AIPPT, getJSONContent } = useAIPPT()
const language = ref<'zh' | 'en'>('zh')
const keyword = ref('')
@ -137,7 +137,7 @@ const createPPT = async () => {
// const AISlides: AIPPTSlide[] = await api.getMockData('AIPPT')
const AISlides: AIPPTSlide[] = await api.AIPPT(outline.value, language.value).then(ret => {
const obj = JSON.parse(ret.data[0].content)
const obj = JSON.parse(getJSONContent(ret.data[0].content))
return obj.data
})
const templateSlides: Slide[] = await api.getFileData(selectedTemplate.value).then(ret => ret.slides)