Skip to content

Commit

Permalink
fix: 暂时切换AI服务到doubao-1.5-pro
Browse files Browse the repository at this point in the history
  • Loading branch information
pipipi-pikachu committed Feb 8, 2025
1 parent 95c8692 commit 9f40217
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/hooks/useAIPPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -480,5 +487,6 @@ export default () => {
return {
AIPPT,
getMdContent,
getJSONContent,
}
}
19 changes: 16 additions & 3 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
})
},
}
4 changes: 2 additions & 2 deletions src/views/Editor/AIPPTDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9f40217

Please sign in to comment.