MCPcopy Create free account
hub / github.com/TimeCyber/MCP-X-web / parseScriptToData

Function parseScriptToData

src/services/videogenService.ts:746–853  ·  view source on GitHub ↗
(
  rawText: string,
  language: string = '中文',
  textModel?: string,
  onProgress?: (text: string) => void,
  videoType?: 'script' | 'promotional' | 'shortvideo' | 'storyboard'
)

Source from the content-addressed store, hash-verified

744 * 使用 AI 解析剧本数据
745 */
746export const parseScriptToData = async (
747 rawText: string,
748 language: string = '中文',
749 textModel?: string,
750 onProgress?: (text: string) => void,
751 videoType?: 'script' | 'promotional' | 'shortvideo' | 'storyboard'
752): Promise<ScriptData> => {
753 const userId = localStorage.getItem('userId');
754 if (!userId) throw new Error('用户未登录');
755
756 const prompt = videoType === 'storyboard'
757 ? buildStoryboardScriptParsePrompt(rawText, language)
758 : `你是一个专业的剧本分析师。请分析以下剧本文本,并以JSON格式输出结构化数据。
759
760要求:
7611. 提取标题、类型、故事梗概(使用${language})
7622. 提取角色信息(id, name, gender, age, personality)。
763 【重要】personality字段要求:
764 - 请在此字段填写角色的【视觉形象定妆照描述】(形象Prompt)。
765 - 只描述角色的外貌、五官特征、发型、身材、服装款式与材质、配饰等视觉细节。
766 - 严禁描述人物性格(如“开朗”、“阴险”)。
767 - 严禁描述故事细节、背景或任何情节。
768 - 严禁涉及到其他人物。
7693. 提取场景信息(id, location, time, atmosphere)。
770 【重要】atmosphere字段要求:
771 - 请在此字段填写场景的【视觉布局与陈设描述】。
772 - 只描述场景的物理样子、建筑风格、房间布局、家具摆放、具体的物品及其材质等视觉细节。
773 - 严禁描述情感词、氛围词(如“压抑”、“温馨”、“神秘”)。
774 - 严禁描述故事情节或人物活动。
7754. 将故事分解为段落,并关联到对应场景
776
777剧本内容:
778"${rawText.slice(0, 15000)}"
779
780请严格按照以下JSON格式输出:
781{
782 "title": "剧本标题",
783 "genre": "类型",
784 "logline": "故事梗概",
785 "characters": [
786 {"id": "char1", "name": "角色名", "gender": "性别", "age": "年龄", "personality": "视觉形象定妆照描述"}
787 ],
788 "scenes": [
789 {"id": "scene1", "location": "地点", "time": "时间", "atmosphere": "视觉布局与陈设描述"}
790 ],
791 "storyParagraphs": [
792 {"id": 1, "text": "段落内容", "sceneRefId": "scene1"}
793 ]
794}`;
795
796 return new Promise((resolve, reject) => {
797 let fullResponse = '';
798
799 const sendData: SendDTO = {
800 messages: [{ role: 'user', content: prompt }],
801 model: textModel || 'deepseek-chat',
802 stream: true,
803 userId,

Callers 1

handleAnalyzeFunction · 0.90

Calls 5

streamChatSendFunction · 0.90
extractScriptDataJsonFunction · 0.85

Tested by

no test coverage detected