From 9204a3e177a7ec556198a73e3784cce86c5be3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Sun, 31 Aug 2025 04:22:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E6=B6=88=E6=81=AFkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SmartChatBox/MessageRenderer.tsx | 11 +++++++++-- components/SmartChatBox/SmartChatBox.tsx | 2 +- components/SmartChatBox/api.ts | 5 +++++ components/SmartChatBox/types.ts | 5 +++-- components/pages/work-flow/use-workflow-data.tsx | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/components/SmartChatBox/MessageRenderer.tsx b/components/SmartChatBox/MessageRenderer.tsx index 68bed03..de70028 100644 --- a/components/SmartChatBox/MessageRenderer.tsx +++ b/components/SmartChatBox/MessageRenderer.tsx @@ -1,6 +1,6 @@ import React, { useMemo } from "react"; import { motion } from "framer-motion"; -import { ChatMessage } from "./types"; +import { ChatMessage, MessageBlock } from "./types"; import { bubbleVariants, hhmm } from "./utils"; import { ProgressBar } from "./ProgressBar"; import { Loader2, AlertCircle, CheckCircle2 } from "lucide-react"; @@ -8,9 +8,10 @@ import { Image } from 'antd'; interface MessageRendererProps { msg: ChatMessage; + sendMessage: (blocks: MessageBlock[]) => Promise; } -export function MessageRenderer({ msg }: MessageRendererProps) { +export function MessageRenderer({ msg, sendMessage }: MessageRendererProps) { // Decide bubble style const isUser = msg.role === "user"; const isSystem = msg.role === "system"; @@ -75,6 +76,7 @@ export function MessageRenderer({ msg }: MessageRendererProps) { animate="visible" transition={{ duration: 0.25 }} data-alt="message-bubble" + key={msg.id} >
{/* Header */} @@ -126,6 +128,11 @@ export function MessageRenderer({ msg }: MessageRendererProps) { return ; case "link": return {b.text}; + case "applyButton": + return ; default: return null; } diff --git a/components/SmartChatBox/SmartChatBox.tsx b/components/SmartChatBox/SmartChatBox.tsx index 5d0ac65..ff7a812 100644 --- a/components/SmartChatBox/SmartChatBox.tsx +++ b/components/SmartChatBox/SmartChatBox.tsx @@ -161,7 +161,7 @@ export default function SmartChatBox({ {group.messages.map((message) => ( - + ))} ))} diff --git a/components/SmartChatBox/api.ts b/components/SmartChatBox/api.ts index 11b6363..6804d64 100644 --- a/components/SmartChatBox/api.ts +++ b/components/SmartChatBox/api.ts @@ -239,6 +239,11 @@ function transformMessage(apiMessage: RealApiMessage): ChatMessage { message.blocks.push({ type: "link", text: c.content, url: c.url || '' }); } }); + + // todo: 需要确认是否需要添加applyButton + // if (role === 'assistant' && function_name === 'modify_video_with_runway') { + // message.blocks.push({ type: "applyButton", text: "Apply" }); + // } } catch (error) { // 如果 JSON 解析失败,将整个 content 作为文本内容 message.blocks.push({ type: "text", text: content }); diff --git a/components/SmartChatBox/types.ts b/components/SmartChatBox/types.ts index c9a1040..c37dbea 100644 --- a/components/SmartChatBox/types.ts +++ b/components/SmartChatBox/types.ts @@ -8,7 +8,8 @@ export type MessageBlock = | { type: "video"; url: string; poster?: string } | { type: "audio"; url: string } | { type: "progress"; value: number; total?: number; label?: string } - | { type: "link"; text: string; url: string }; + | { type: "link"; text: string; url: string } + | { type: "applyButton"; text: string; } export interface ChatMessage { id: string; @@ -80,7 +81,7 @@ export interface MessagesResponse { } type ContentType = "text" | "image" | "video" | "audio"; -export type FunctionName = "create_project" | "generate_script_summary" | "generate_character" | "generate_sketch" | "generate_shot_sketch" | "generate_video"; +export type FunctionName = "create_project" | "generate_script_summary" | "generate_character" | "generate_sketch" | "generate_shot_sketch" | "generate_video" | "modify_video_with_runway"; // 项目创建 export interface ProjectInit { diff --git a/components/pages/work-flow/use-workflow-data.tsx b/components/pages/work-flow/use-workflow-data.tsx index e8e2eda..b5d4e3e 100644 --- a/components/pages/work-flow/use-workflow-data.tsx +++ b/components/pages/work-flow/use-workflow-data.tsx @@ -115,7 +115,7 @@ export function useWorkflowData() { const generateEditPlan = useCallback(async (isInit?: boolean) => { isInit && await getGenerateEditPlan({ project_id: episodeId }); - window.open(`https://smartcut.huiying.video/ai-editor/${episodeId}?token=${token}&user_id=${useid}`, '_target'); + window.open(`https://smartcut.movieflow.ai/editor/${episodeId}?token=${token}&user_id=${useid}`, '_target'); }, [episodeId]); useEffect(() => {