feat: AI 场景路由、ASR 服务及前后端全链路同步
- 新增 AI 场景路由控制器和管理接口 - 新增 ASR 语音识别服务及前后端集成 - 同步 AI Runtime 客户端到 Web/小程序/Life-Script - 完善 AI 配置测试修复和管理后台路由配置 - 新增数据库迁移脚本 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
import { computed, ref, onMounted, watch } from 'vue'
|
||||
import { useAppStore } from '../../stores/app.js'
|
||||
import * as lifePathService from '../../services/lifePath.js'
|
||||
import { streamAiScene } from '../../services/aiRuntime.js'
|
||||
|
||||
const store = useAppStore()
|
||||
|
||||
@@ -74,11 +75,55 @@ const loadPath = async (scriptId) => {
|
||||
const createPlaceholderPath = async (scriptId) => {
|
||||
const script = selectedScript.value || {}
|
||||
const title = script.title ? `${script.title} · 实现路径` : '我的实现路径'
|
||||
let generatedText = ''
|
||||
try {
|
||||
const streamRes = await streamAiScene({
|
||||
sceneCode: 'life_healing',
|
||||
inputs: {
|
||||
mode: 'path_generate',
|
||||
prompt: `请把下面的人生剧本拆解成现实中可执行的路径,按阶段输出。\n\n${script.content || script.summary || ''}`,
|
||||
script: script.content || script.summary || ''
|
||||
},
|
||||
onDelta: (_delta, output) => {
|
||||
generatedText = output
|
||||
pathData.value = {
|
||||
id: `stream-${scriptId}`,
|
||||
scriptId,
|
||||
title,
|
||||
description: output,
|
||||
steps: output.split('\n').filter(Boolean).slice(0, 6).map((line, index) => ({
|
||||
phase: `阶段${index + 1}`,
|
||||
task: line.replace(/^\d+[.、]\s*/, '').slice(0, 28),
|
||||
desc: line,
|
||||
content: line,
|
||||
done: index === 0
|
||||
})),
|
||||
progress: 8,
|
||||
status: 'active'
|
||||
}
|
||||
}
|
||||
})
|
||||
generatedText = streamRes.output || generatedText
|
||||
} catch (error) {
|
||||
generatedText = ''
|
||||
}
|
||||
const steps = [
|
||||
{ phase: '阶段1', task: '整理目标', desc: '把剧本中的关键目标拆成可以执行的小目标。', content: '把剧本中的关键目标拆成可以执行的小目标。', done: true },
|
||||
{ phase: '阶段2', task: '建立习惯', desc: '选择一个最小行动,每天稳定推进。', content: '选择一个最小行动,每天稳定推进。', done: false },
|
||||
{ phase: '阶段3', task: '复盘迭代', desc: '每周回看进展,根据现实反馈调整路径。', content: '每周回看进展,根据现实反馈调整路径。', done: false }
|
||||
]
|
||||
if (generatedText) {
|
||||
const generatedSteps = generatedText.split('\n').filter(Boolean).slice(0, 6).map((line, index) => ({
|
||||
phase: `阶段${index + 1}`,
|
||||
task: line.replace(/^\d+[.、]\s*/, '').slice(0, 28),
|
||||
desc: line,
|
||||
content: line,
|
||||
done: index === 0
|
||||
}))
|
||||
if (generatedSteps.length) {
|
||||
steps.splice(0, steps.length, ...generatedSteps)
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await lifePathService.createPath({
|
||||
scriptId,
|
||||
|
||||
Reference in New Issue
Block a user