[GH-ISSUE #19] 需要处理deepseek回答截断的情况 #11

Closed
opened 2026-02-27 01:55:50 +03:00 by kerem · 7 comments
Owner

Originally created by @he426100 on GitHub (Feb 7, 2025).
Original GitHub issue: https://github.com/ErlichLiu/DeepClaude/issues/19

思考过长会被截断,这样就卡在思考这一步了

Originally created by @he426100 on GitHub (Feb 7, 2025). Original GitHub issue: https://github.com/ErlichLiu/DeepClaude/issues/19 思考过长会被截断,这样就卡在思考这一步了
kerem closed this issue 2026-02-27 01:55:50 +03:00
Author
Owner

@GowayLee commented on GitHub (Feb 7, 2025):

什么是截断, 能否提供详细案例

<!-- gh-comment-id:2641851156 --> @GowayLee commented on GitHub (Feb 7, 2025): 什么是截断, 能否提供详细案例
Author
Owner

@he426100 commented on GitHub (Feb 7, 2025):

Image

Image

就像这样,思考的内容没发完,但deepseek的返回已经结束了

<!-- gh-comment-id:2641857455 --> @he426100 commented on GitHub (Feb 7, 2025): ![Image](https://github.com/user-attachments/assets/2abba443-c21d-45f5-aa84-734a91b26d14) ![Image](https://github.com/user-attachments/assets/1952165f-4428-414d-a266-087015048ff2) 就像这样,思考的内容没发完,但deepseek的返回已经结束了
Author
Owner

@GowayLee commented on GitHub (Feb 7, 2025):

能否提供DeepClaude的日志信息, 目前这边还没有设置请求超时, 理论上不会被DeepClaude截断, 应该是被DeepSeek提供商那边的推理端截断了

<!-- gh-comment-id:2641869889 --> @GowayLee commented on GitHub (Feb 7, 2025): 能否提供DeepClaude的日志信息, 目前这边还没有设置请求超时, 理论上不会被DeepClaude截断, 应该是被DeepSeek提供商那边的推理端截断了
Author
Owner

@he426100 commented on GitHub (Feb 7, 2025):

2025-02-07 01:55:39 - DeepClaude - INFO - 当前工作目录: /app
2025-02-07 01:55:39 - DeepClaude - INFO - 尝试加载.env文件...
2025-02-07 01:55:39 - DeepClaude - INFO - ALLOW_API_KEY环境变量状态: 已设置
2025-02-07 01:55:39 - DeepClaude - INFO - Loaded API key starting with: NxSQ
2025-02-07 01:55:40 - DeepClaude - INFO - 开始请求
INFO:     Started server process [1]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2025-02-07 01:56:03 - DeepClaude - INFO - API密钥验证通过
INFO:     172.17.0.1:57402 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-02-07 01:56:03 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek
2025-02-07 01:56:03 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容...
2025-02-07 01:56:12 - DeepClaude - INFO - 提取内容信息,推理阶段结束: 
                                                                                                                                                                                                                     
                                                                                                                                                                                                                     
2025-02-07 01:56:12 - DeepClaude - INFO - DeepSeek 推理完成,收集到的推理内容长度:368
2025-02-07 01:56:12 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束
2025-02-07 01:56:12 - DeepClaude - INFO - 开始处理 Claude 流,使用模型: claude-3-5-sonnet-20241022, 提供商: oneapi
2025-02-07 01:56:14 - DeepClaude - INFO - Claude 任务处理完成,标记结束
2025-02-07 01:56:28 - DeepClaude - INFO - API密钥验证通过
INFO:     172.17.0.1:59522 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-02-07 01:56:28 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek
2025-02-07 01:56:28 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容...
2025-02-07 01:57:09 - DeepClaude - INFO - 提取内容信息,推理阶段结束: 
                                                                                                                                                                                                                     
                                                                                                                                                                                                                     
2025-02-07 01:57:09 - DeepClaude - INFO - DeepSeek 推理完成,收集到的推理内容长度:954
2025-02-07 01:57:09 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束
2025-02-07 01:57:09 - DeepClaude - INFO - 开始处理 Claude 流,使用模型: claude-3-5-sonnet-20241022, 提供商: oneapi
2025-02-07 01:57:20 - DeepClaude - INFO - API密钥验证通过
INFO:     172.17.0.1:55152 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-02-07 01:57:20 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek
2025-02-07 01:57:20 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容...
2025-02-07 01:57:39 - DeepClaude - INFO - Claude 任务处理完成,标记结束
2025-02-07 02:02:20 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束

是硅基那边截断了

<!-- gh-comment-id:2641874357 --> @he426100 commented on GitHub (Feb 7, 2025): ```log 2025-02-07 01:55:39 - DeepClaude - INFO - 当前工作目录: /app 2025-02-07 01:55:39 - DeepClaude - INFO - 尝试加载.env文件... 2025-02-07 01:55:39 - DeepClaude - INFO - ALLOW_API_KEY环境变量状态: 已设置 2025-02-07 01:55:39 - DeepClaude - INFO - Loaded API key starting with: NxSQ 2025-02-07 01:55:40 - DeepClaude - INFO - 开始请求 INFO: Started server process [1] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) 2025-02-07 01:56:03 - DeepClaude - INFO - API密钥验证通过 INFO: 172.17.0.1:57402 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-02-07 01:56:03 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek 2025-02-07 01:56:03 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容... 2025-02-07 01:56:12 - DeepClaude - INFO - 提取内容信息,推理阶段结束: 2025-02-07 01:56:12 - DeepClaude - INFO - DeepSeek 推理完成,收集到的推理内容长度:368 2025-02-07 01:56:12 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束 2025-02-07 01:56:12 - DeepClaude - INFO - 开始处理 Claude 流,使用模型: claude-3-5-sonnet-20241022, 提供商: oneapi 2025-02-07 01:56:14 - DeepClaude - INFO - Claude 任务处理完成,标记结束 2025-02-07 01:56:28 - DeepClaude - INFO - API密钥验证通过 INFO: 172.17.0.1:59522 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-02-07 01:56:28 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek 2025-02-07 01:56:28 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容... 2025-02-07 01:57:09 - DeepClaude - INFO - 提取内容信息,推理阶段结束: 2025-02-07 01:57:09 - DeepClaude - INFO - DeepSeek 推理完成,收集到的推理内容长度:954 2025-02-07 01:57:09 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束 2025-02-07 01:57:09 - DeepClaude - INFO - 开始处理 Claude 流,使用模型: claude-3-5-sonnet-20241022, 提供商: oneapi 2025-02-07 01:57:20 - DeepClaude - INFO - API密钥验证通过 INFO: 172.17.0.1:55152 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-02-07 01:57:20 - DeepClaude - INFO - 开始处理 DeepSeek 流,使用模型:Pro/deepseek-ai/DeepSeek-R1, 提供商: deepseek 2025-02-07 01:57:20 - DeepClaude - INFO - 等待获取 DeepSeek 的推理内容... 2025-02-07 01:57:39 - DeepClaude - INFO - Claude 任务处理完成,标记结束 2025-02-07 02:02:20 - DeepClaude - INFO - DeepSeek 任务处理完成,标记结束 ``` 是硅基那边截断了
Author
Owner

@GowayLee commented on GitHub (Feb 7, 2025):

是硅基那边截断了

现在R1的Provider基本上都不太稳定, 提供的推理被截断也是没办法了🥲

我自己现在基本上用蒸馏模型做推理, 实在有点难等671B的推理速度.

<!-- gh-comment-id:2641890630 --> @GowayLee commented on GitHub (Feb 7, 2025): > 是硅基那边截断了 现在R1的Provider基本上都不太稳定, 提供的推理被截断也是没办法了🥲 我自己现在基本上用蒸馏模型做推理, 实在有点难等671B的推理速度.
Author
Owner

@he426100 commented on GitHub (Feb 7, 2025):

硅基昨天新推出的 Pro/deepseek-ai/DeepSeek-R1 速度还可以

<!-- gh-comment-id:2641893002 --> @he426100 commented on GitHub (Feb 7, 2025): 硅基昨天新推出的 Pro/deepseek-ai/DeepSeek-R1 速度还可以
Author
Owner

@he426100 commented on GitHub (Feb 11, 2025):

效果很好,放个php的贪吃蛇作为结尾

php源码

<?php
// 设置终端为非阻塞模式并支持特殊键位
system('stty -icanon -echo');
stream_set_blocking(STDIN, 0);

// 初始化游戏参数
$width = 20;
$height = 10;
$score = 0;

// 初始化蛇的位置
$snake = array(
    array($width/2, $height/2)
);
$direction = 'R';

// 定义相反方向映射
$opposite = [
    'U' => 'D',
    'D' => 'U',
    'L' => 'R',
    'R' => 'L'
];

// 生成第一个食物
$food = array(
    rand(0, $width-1),
    rand(0, $height-1)
); 

// 游戏主循环
while(true) {
    // 处理箭头键输入
    $input = fread(STDIN, 3);
    if($input) {
        $new_direction = $direction; // 默认保持当前方向
        switch($input) {
            case "\033[A": $new_direction = 'U'; break; // 上箭头
            case "\033[B": $new_direction = 'D'; break; // 下箭头
            case "\033[D": $new_direction = 'L'; break; // 左箭头
            case "\033[C": $new_direction = 'R'; break; // 右箭头
            case "q": die("Game Over!\n"); break;
        }
        // 检查是否是相反方向,如果不是才改变方向
        if ($new_direction !== $opposite[$direction]) {
            $direction = $new_direction;
        }
    }

    // 移动蛇头
    $head = $snake[0];
    switch($direction) {
        case 'U': $head = array($head[0], $head[1]-1); break;
        case 'D': $head = array($head[0], $head[1]+1); break;
        case 'L': $head = array($head[0]-1, $head[1]); break;
        case 'R': $head = array($head[0]+1, $head[1]); break;
    }
    array_unshift($snake, $head);

    // 检查是否吃到食物
    if($head[0] == $food[0] && $head[1] == $food[1]) {
        $score++;
        do {
            $food = array(rand(0, $width-1), rand(0, $height-1));
        } while(in_array($food, $snake));
    } else {
        array_pop($snake);
    }

    // 检查是否撞墙
    if($head[0] < 0 || $head[0] >= $width || 
       $head[1] < 0 || $head[1] >= $height) {
        die("Game Over! Hit the wall! Score: $score\n");
    }

    // 检查是否吃到自己
    $body = array_slice($snake, 1); // 获取蛇身(不包括头部)
    foreach($body as $part) {
        if($part[0] == $head[0] && $part[1] == $head[1]) {
            die("Game Over! Snake ate itself! Score: $score\n");
        }
    }

    // 清屏
    system('clear');
    
    // 绘制上边界
    echo str_repeat('#', $width + 2) . "\n";
    
    // 绘制游戏区域
    for($y = 0; $y < $height; $y++) {
        echo '#'; // 左边界
        for($x = 0; $x < $width; $x++) {
            $printed = false;
            // 绘制蛇
            foreach($snake as $part) {
                if($part[0] == $x && $part[1] == $y) {
                    echo "O";
                    $printed = true;
                    break;
                }
            }
            // 绘制食物
            if(!$printed && $food[0] == $x && $food[1] == $y) {
                echo "*";
                $printed = true;
            }
            // 绘制空白
            if(!$printed) {
                echo " ";
            }
        }
        echo "#\n"; // 右边界
    }
    
    // 绘制下边界
    echo str_repeat('#', $width + 2) . "\n";
    
    echo "Score: $score\n";
    echo "Use arrow keys to move, Q to quit\n";
    
    usleep(300000); // 300ms移动一次
}

// 恢复终端设置
system('stty sane');

思维导图 (使用 Mermaid)

mindmap
  root((贪吃蛇游戏))
    初始化
      终端设置
        禁用回显
        非阻塞模式
      游戏参数
        地图大小
        初始分数
        移动速度
      蛇的初始化
        起始位置
        移动方向
      食物生成
        随机位置
    游戏主循环
      输入处理
        箭头按键检测
        方向判断
        反向移动限制
      移动逻辑
        蛇头移动
        蛇身跟随
      碰撞检测
        墙壁碰撞
        自身碰撞
        食物碰撞
      渲染系统
        清屏
        绘制边界
        绘制蛇身
        绘制食物
        显示分数
    游戏结束
      显示得分
      恢复终端

流程图 (使用 Mermaid)

flowchart TD
    A[开始] --> B[初始化游戏参数]
    B --> C[设置终端模式]
    C --> D[初始化蛇和食物]
    D --> E{读取键盘输入}
    E --> |有输入| F{检查是否为有效方向}
    E --> |无输入| G[根据当前方向移动蛇]
    F --> |是| H[更新移动方向]
    F --> |否| G
    H --> G
    G --> I{检查是否吃到食物}
    I --> |是| J[增加分数/生成新食物]
    I --> |否| K[移除蛇尾]
    J --> L{检查碰撞}
    K --> L
    L --> |撞墙或自噬| M[游戏结束]
    L --> |未碰撞| N[更新显示]
    N --> O[等待时间间隔]
    O --> E
    M --> P[显示得分]
    P --> Q[恢复终端设置]
    Q --> R[结束]

游戏界面

Image

<!-- gh-comment-id:2649671140 --> @he426100 commented on GitHub (Feb 11, 2025): 效果很好,放个php的贪吃蛇作为结尾 ### php源码 ```php <?php // 设置终端为非阻塞模式并支持特殊键位 system('stty -icanon -echo'); stream_set_blocking(STDIN, 0); // 初始化游戏参数 $width = 20; $height = 10; $score = 0; // 初始化蛇的位置 $snake = array( array($width/2, $height/2) ); $direction = 'R'; // 定义相反方向映射 $opposite = [ 'U' => 'D', 'D' => 'U', 'L' => 'R', 'R' => 'L' ]; // 生成第一个食物 $food = array( rand(0, $width-1), rand(0, $height-1) ); // 游戏主循环 while(true) { // 处理箭头键输入 $input = fread(STDIN, 3); if($input) { $new_direction = $direction; // 默认保持当前方向 switch($input) { case "\033[A": $new_direction = 'U'; break; // 上箭头 case "\033[B": $new_direction = 'D'; break; // 下箭头 case "\033[D": $new_direction = 'L'; break; // 左箭头 case "\033[C": $new_direction = 'R'; break; // 右箭头 case "q": die("Game Over!\n"); break; } // 检查是否是相反方向,如果不是才改变方向 if ($new_direction !== $opposite[$direction]) { $direction = $new_direction; } } // 移动蛇头 $head = $snake[0]; switch($direction) { case 'U': $head = array($head[0], $head[1]-1); break; case 'D': $head = array($head[0], $head[1]+1); break; case 'L': $head = array($head[0]-1, $head[1]); break; case 'R': $head = array($head[0]+1, $head[1]); break; } array_unshift($snake, $head); // 检查是否吃到食物 if($head[0] == $food[0] && $head[1] == $food[1]) { $score++; do { $food = array(rand(0, $width-1), rand(0, $height-1)); } while(in_array($food, $snake)); } else { array_pop($snake); } // 检查是否撞墙 if($head[0] < 0 || $head[0] >= $width || $head[1] < 0 || $head[1] >= $height) { die("Game Over! Hit the wall! Score: $score\n"); } // 检查是否吃到自己 $body = array_slice($snake, 1); // 获取蛇身(不包括头部) foreach($body as $part) { if($part[0] == $head[0] && $part[1] == $head[1]) { die("Game Over! Snake ate itself! Score: $score\n"); } } // 清屏 system('clear'); // 绘制上边界 echo str_repeat('#', $width + 2) . "\n"; // 绘制游戏区域 for($y = 0; $y < $height; $y++) { echo '#'; // 左边界 for($x = 0; $x < $width; $x++) { $printed = false; // 绘制蛇 foreach($snake as $part) { if($part[0] == $x && $part[1] == $y) { echo "O"; $printed = true; break; } } // 绘制食物 if(!$printed && $food[0] == $x && $food[1] == $y) { echo "*"; $printed = true; } // 绘制空白 if(!$printed) { echo " "; } } echo "#\n"; // 右边界 } // 绘制下边界 echo str_repeat('#', $width + 2) . "\n"; echo "Score: $score\n"; echo "Use arrow keys to move, Q to quit\n"; usleep(300000); // 300ms移动一次 } // 恢复终端设置 system('stty sane'); ``` ### 思维导图 (使用 Mermaid) ```mermaid mindmap root((贪吃蛇游戏)) 初始化 终端设置 禁用回显 非阻塞模式 游戏参数 地图大小 初始分数 移动速度 蛇的初始化 起始位置 移动方向 食物生成 随机位置 游戏主循环 输入处理 箭头按键检测 方向判断 反向移动限制 移动逻辑 蛇头移动 蛇身跟随 碰撞检测 墙壁碰撞 自身碰撞 食物碰撞 渲染系统 清屏 绘制边界 绘制蛇身 绘制食物 显示分数 游戏结束 显示得分 恢复终端 ``` ### 流程图 (使用 Mermaid) ```mermaid flowchart TD A[开始] --> B[初始化游戏参数] B --> C[设置终端模式] C --> D[初始化蛇和食物] D --> E{读取键盘输入} E --> |有输入| F{检查是否为有效方向} E --> |无输入| G[根据当前方向移动蛇] F --> |是| H[更新移动方向] F --> |否| G H --> G G --> I{检查是否吃到食物} I --> |是| J[增加分数/生成新食物] I --> |否| K[移除蛇尾] J --> L{检查碰撞} K --> L L --> |撞墙或自噬| M[游戏结束] L --> |未碰撞| N[更新显示] N --> O[等待时间间隔] O --> E M --> P[显示得分] P --> Q[恢复终端设置] Q --> R[结束] ``` ### 游戏界面 ![Image](https://github.com/user-attachments/assets/da620c53-8434-4ee7-95cd-373fd286b893)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DeepClaude#11
No description provided.