lh 1 tydzień temu
rodzic
commit
af5ba6082c

+ 7 - 6
app/Http/Controllers/Anime/AnimeController.php

@@ -869,11 +869,12 @@ class AnimeController extends BaseController
         ]);
     }
 
-    // public function scriptList(Request $request) {
-    //     $data = $request->all();
-    //     $result = $this->AnimeService->scriptList($data);
-    //     return $this->success($result, [new AnimeTransformer(), 'newBuildScriptList']);
-    // }
+    // 应用有声制作参数
+    public function applyAudioData(Request $request) {
+        $data = $request->all();
+
+        $result = $this->AnimeService->applyAudioData($data);
+        return $this->success($result);
+    }
 
-    
 }

+ 29 - 0
app/Services/Anime/AnimeService.php

@@ -1523,6 +1523,35 @@ class AnimeService
         return compact('pics', 'videos');
     }
 
+    public function applyAudioData($data) {
+        $segment_id = getProp($data, 'segment_id');
+        $global_data = getProp($data, 'global_data');
+        $segment_data = getProp($data, 'segment_data');
+
+        // 解析数据
+        
+
+        try {
+            DB::beginTransaction();
+
+            // 更新全局数据
+            $boolen = DB::table('mp_episode_segments')->where('segment_id', $segment_id)->update([
+                'global_data' => json_encode($global_data),
+                'segment_data' => json_encode($segment_data),
+            ]);
+            if (!$boolen) {
+                Utils::throwError('20003:更新分镜失败');
+            }
+
+            DB::commit();
+            return true;
+
+        } catch (\Exception $e) {
+            DB::rollBack();
+            Utils::throwError('20003:'.$e->getMessage());
+        }
+    }
+
     // 轮训获取图片任务结果
     private function loopGetPicTaskResult($task_id) {
         $start_count = 0;

Plik diff jest za duży
+ 6 - 6
app/Services/DeepSeek/DeepSeekService.php


+ 26 - 7
public/deepseek-stream-demo.html

@@ -507,10 +507,14 @@
 
             // 准备表单数据
             const formData = new FormData();
-            formData.append('anime_id', document.getElementById('scriptId').value);
-            formData.append('model', document.getElementById('model').value);
-            formData.append('start_episode_sequence', document.getElementById('startEpisode').value);
-            formData.append('total_episode_num', document.getElementById('totalEpisode').value);
+            formData.append('is_multi', 0);
+            formData.append('model', 'deepseek-chat');
+            formData.append('art_style', '日系动漫风格');
+            formData.append('prompt', '1+1=2');
+            // formData.append('anime_id', document.getElementById('scriptId').value);
+            // formData.append('model', document.getElementById('model').value);
+            // formData.append('start_episode_sequence', document.getElementById('startEpisode').value);
+            // formData.append('total_episode_num', document.getElementById('totalEpisode').value);
             
             const content = document.getElementById('content').value;
             if (content) {
@@ -537,7 +541,7 @@
 
             try {
                 // 发起流式请求,传入 signal 用于中断
-                const response = await fetch('/api/chat', {
+                const response = await fetch('/api/addChat', {
                     method: 'POST',
                     body: formData,
                     signal: abortController.signal // 关键:添加中断信号
@@ -625,13 +629,19 @@
             if (data.type === 'reasoning') {
                 // 思维链内容
                 // 注释掉下面两行则不展示思维链内容,仅计数
-                reasoningContent.textContent = data.full_reasoning || '';
+                const nextReasoning = typeof data.full_reasoning === 'string'
+                    ? data.full_reasoning
+                    : reasoningContent.textContent + (data.content || '');
+                reasoningContent.textContent = nextReasoning;
                 reasoningContent.scrollTop = reasoningContent.scrollHeight;
                 charCount += (data.content || '').length;
                 updateCharCount();
             } else if (data.type === 'content') {
                 // 最终回答内容
-                contentOutput.textContent = data.full_content || '';
+                const nextContent = typeof data.full_content === 'string'
+                    ? data.full_content
+                    : contentOutput.textContent + (data.content || '');
+                contentOutput.textContent = nextContent;
                 contentOutput.scrollTop = contentOutput.scrollHeight;
                 charCount += (data.content || '').length;
                 updateCharCount();
@@ -648,6 +658,15 @@
         // 处理完成
         function handleComplete(data) {
             updateStatus('completed', '生成完成');
+            if (typeof data.full_reasoning === 'string') {
+                reasoningContent.textContent = data.full_reasoning;
+                reasoningContent.scrollTop = reasoningContent.scrollHeight;
+            }
+
+            if (typeof data.full_content === 'string') {
+                contentOutput.textContent = data.full_content;
+                contentOutput.scrollTop = contentOutput.scrollHeight;
+            }
             
             // 显示 Token 使用情况
             if (data.usage) {

+ 0 - 185
seedance_api_test_examples.md

@@ -1,185 +0,0 @@
-# Seedance 1.5 Pro API 测试示例
-
-## 1. 文生视频 (Text-to-Video)
-
-```bash
-POST /api/AIGeneration/video/seedance/createTask
-Content-Type: application/json
-
-{
-    "model": "doubao-seedance-1-5-pro-251215",
-    "content": [
-        {
-            "type": "text",
-            "text": "一只可爱的小猫在阳光下打哈欠,画面温馨自然"
-        }
-    ],
-    "resolution": "720p",
-    "ratio": "16:9",
-    "duration": 5,
-    "seed": 12345,
-    "generate_audio": true,
-    "watermark": false
-}
-```
-
-## 2. 图生视频 - 首帧 (Image-to-Video - First Frame)
-
-```bash
-POST /api/AIGeneration/video/seedance/createTask
-Content-Type: application/json
-
-{
-    "model": "doubao-seedance-1-5-pro-251215",
-    "content": [
-        {
-            "type": "text",
-            "text": "小猫慢慢睁开眼睛,伸了个懒腰"
-        },
-        {
-            "type": "image_url",
-            "image_url": {
-                "url": "https://example.com/cat_sleeping.jpg"
-            },
-            "role": "first_frame"
-        }
-    ],
-    "resolution": "1080p",
-    "ratio": "adaptive",
-    "duration": 8,
-    "generate_audio": true,
-    "return_last_frame": true
-}
-```
-
-## 3. 图生视频 - 首尾帧 (Image-to-Video - First & Last Frame)
-
-```bash
-POST /api/AIGeneration/video/seedance/createTask
-Content-Type: application/json
-
-{
-    "model": "doubao-seedance-1-5-pro-251215",
-    "content": [
-        {
-            "type": "text",
-            "text": "小猫从睡觉状态慢慢醒来并站起身"
-        },
-        {
-            "type": "image_url",
-            "image_url": {
-                "url": "https://example.com/cat_sleeping.jpg"
-            },
-            "role": "first_frame"
-        },
-        {
-            "type": "image_url",
-            "image_url": {
-                "url": "https://example.com/cat_standing.jpg"
-            },
-            "role": "last_frame"
-        }
-    ],
-    "resolution": "720p",
-    "ratio": "16:9",
-    "duration": 6,
-    "camera_fixed": false,
-    "watermark": false
-}
-```
-
-## 4. 样片模式 (Draft Mode)
-
-```bash
-POST /api/AIGeneration/video/seedance/createTask
-Content-Type: application/json
-
-{
-    "model": "doubao-seedance-1-5-pro-251215",
-    "content": [
-        {
-            "type": "text",
-            "text": "一个人在海边看日落,画面唯美浪漫"
-        }
-    ],
-    "resolution": "480p",
-    "draft": true,
-    "duration": 4,
-    "service_tier": "flex"
-}
-```
-
-## 5. 基于样片生成正式视频
-
-```bash
-POST /api/AIGeneration/video/seedance/createTask
-Content-Type: application/json
-
-{
-    "model": "doubao-seedance-1-5-pro-251215",
-    "content": [
-        {
-            "type": "draft_task",
-            "draft_task": {
-                "id": "draft_task_id_from_step_4"
-            }
-        }
-    ],
-    "resolution": "1080p",
-    "watermark": false
-}
-```
-
-## 6. 查询任务状态
-
-```bash
-GET /api/AIGeneration/video/seedance/taskStatus/{task_id}
-```
-
-响应示例:
-```json
-{
-    "success": true,
-    "data": {
-        "id": "seedance_1710071234_abc123",
-        "status": "succeeded",
-        "result_url": "https://tos.example.com/videos/seedance_video.mp4",
-        "last_frame_url": "https://tos.example.com/images/last_frame.png",
-        "error_message": null,
-        "created_at": "2026-03-10T13:41:23.000000Z",
-        "started_at": "2026-03-10T13:41:25.000000Z",
-        "completed_at": "2026-03-10T13:43:15.000000Z"
-    }
-}
-```
-
-## 状态说明
-
-- `queued`: 排队中
-- `running`: 任务运行中  
-- `succeeded`: 任务成功
-- `failed`: 任务失败
-- `expired`: 任务超时
-
-## 注意事项
-
-1. 图片要求:
-   - 格式:jpeg、png、webp、bmp、tiff、gif、heic、heif
-   - 宽高比:0.4 ~ 2.5
-   - 尺寸:300px ~ 6000px
-   - 大小:< 30MB
-
-2. 文本提示词:
-   - 中文不超过500字
-   - 英文不超过1000词
-   - 建议对话部分用双引号包围
-
-3. 视频参数:
-   - 时长:2-12秒
-   - 分辨率:480p、720p、1080p
-   - 宽高比:16:9、4:3、1:1、3:4、9:16、21:9、adaptive
-
-4. 样片模式限制:
-   - 只能使用480p分辨率
-   - 不支持return_last_frame
-   - 不支持离线推理(flex)

+ 0 - 69
test_batch_segment_videos.php

@@ -1,69 +0,0 @@
-<?php
-/**
- * 测试批量生成分镜视频接口
- * 
- * 使用方法:
- * php test_batch_segment_videos.php
- */
-
-// 测试参数
-$testData = [
-    'anime_id' => 'test_anime_001',
-    'episode_number' => 1
-];
-
-// API 端点
-$apiUrl = 'http://localhost/api/anime/batchSetSegmentVideos';
-
-// 构建 POST 数据
-$postData = http_build_query($testData);
-
-// 设置 cURL 选项
-$ch = curl_init();
-curl_setopt($ch, CURLOPT_URL, $apiUrl);
-curl_setopt($ch, CURLOPT_POST, true);
-curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
-curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $data) {
-    // 处理 SSE 数据
-    if (strpos($data, 'data: ') === 0) {
-        $jsonData = substr($data, 6);
-        $jsonData = trim($jsonData);
-        
-        if (!empty($jsonData)) {
-            $decoded = json_decode($jsonData, true);
-            if ($decoded) {
-                echo "收到数据: " . json_encode($decoded, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n";
-            }
-        }
-    }
-    
-    return strlen($data);
-});
-
-// 设置请求头
-curl_setopt($ch, CURLOPT_HTTPHEADER, [
-    'Accept: text/event-stream',
-    'Cache-Control: no-cache',
-    'Content-Type: application/x-www-form-urlencoded'
-]);
-
-echo "开始测试批量生成分镜视频接口...\n";
-echo "测试参数: " . json_encode($testData, JSON_UNESCAPED_UNICODE) . "\n";
-echo "API 地址: $apiUrl\n";
-echo "等待响应...\n\n";
-
-// 执行请求
-$result = curl_exec($ch);
-
-if (curl_error($ch)) {
-    echo "cURL 错误: " . curl_error($ch) . "\n";
-}
-
-$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-echo "\nHTTP 状态码: $httpCode\n";
-
-curl_close($ch);
-
-echo "\n测试完成。\n";
-?>