修复 分析知识点bug

This commit is contained in:
小肥羊 2025-11-03 16:29:53 +08:00
parent 964f97c115
commit 99f7601184
2 changed files with 18 additions and 20 deletions

View File

@ -63,7 +63,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
this.chatGPTClient = chatGPTClient; this.chatGPTClient = chatGPTClient;
} }
/// <summary> /// <summary>
/// 获取内容对应的章节 /// 获取分段内容对应的章节知识点
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private async Task<List<VideoKonwPoint>> GetVideoKnow(VideoKnowRes[] questionRes, VideoTask taskInfo, private async Task<List<VideoKonwPoint>> GetVideoKnow(VideoKnowRes[] questionRes, VideoTask taskInfo,
@ -90,16 +90,22 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
$"提供的知识点名称({knows})。"; $"提供的知识点名称({knows})。";
await redisManager.AddTaskLog(taskInfo.Id, DateTime.Now + "=>2.开始分析视频内容知识点"); await redisManager.AddTaskLog(taskInfo.Id, DateTime.Now + "=>2.开始分析视频内容知识点");
VideoKnowRes[] konwRes; VideoKnowRes[] konwRes;
for (int i = 0; i < 5; i++) var knowOK = false;
for (int i = 0; i < 4; i++)
{ {
konwRes = await chatGPTClient.ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), knowMessages, "知识点"); konwRes = await chatGPTClient.ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), knowMessages, "知识点");
// 分析结果的片段数量与预期不匹配 // 分析结果的片段数量与预期不匹配
if (questionRes.Length != konwRes.Length) continue; if (questionRes.Length != konwRes.Length) continue;
for (int xi = 0; xi < konwRes.Count(); xi++) for (int xi = 0; xi < konwRes.Count(); xi++)
questionRes[i].KnowPoint = konwRes[i].KnowPoint; questionRes[xi].KnowPoint = konwRes[xi].KnowPoint;
knowOK = true;
break; break;
} }
if (!knowOK)
{
await redisManager.AddTaskLog(taskInfo.Id,"GPT未能分析出有效的分段的知识点");
throw new Exception("GPT未能分析出有效的分段的知识点");
}
//todo 未包含的知识点片段 如何处理 //todo 未包含的知识点片段 如何处理
@ -189,13 +195,13 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
30 40
()
0-10070 0-10070
@ -640,7 +646,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
$"输出内容只返回json格式为({resFormat})" + $"输出内容只返回json格式为({resFormat})" +
$"以下是字幕内容" + $"以下是字幕内容" +
$"`{captions.Captions}`"; $"`{captions.Captions}`";
var resData = await chatClient.ChatAsync<AIVideoTypeDto?>(taskInfo.Id.ToString(), postMessages, "视频类型", "deepseek-chat"); //var resData = await chatClient.ChatAsync<AIVideoTypeDto?>(taskInfo.Id.ToString(), postMessages, "视频类型", "deepseek-chat");
var resData = await chatGPTClient.ChatAsync<AIVideoTypeDto?>(taskInfo.Id.ToString(), postMessages, "视频类型");
var res = resData.VideoType.ToEnum<AttachmentsInfoType>(); var res = resData.VideoType.ToEnum<AttachmentsInfoType>();
if (res != null) if (res != null)
{ {

View File

@ -112,17 +112,6 @@ namespace VideoAnalysisCore.Common
FFMPGE = fFMPGE; FFMPGE = fFMPGE;
this.senseVoice = senseVoice; this.senseVoice = senseVoice;
this.redisManager = redisManager; this.redisManager = redisManager;
for (int i = 1; i < 999; i++)
{
redisManager.AddTaskLog(-1, $"测试日志 {i}");
}
Init(); Init();
redisManager.InitChannel(); redisManager.InitChannel();
} }
@ -372,7 +361,9 @@ namespace VideoAnalysisCore.Common
if (Redis is null) throw new Exception("redis未初始化"); if (Redis is null) throw new Exception("redis未初始化");
//处理之前程序结束前未能执行完的情况 //处理之前程序结束前未能执行完的情况
var oldTaskCount = Redis.LLen(RedisExpandKey.IDTask); var oldTaskCount = Redis.LLen(RedisExpandKey.IDTask);
if (oldTaskCount > 0) //重试任务并发过多可能会导致程序崩溃
// 未能重新分析的中断任务 则单独开一个网页来处理
if (oldTaskCount > 0 && oldTaskCount < 10)
{ {
var oldTaskArr = Redis.LRange(RedisExpandKey.IDTask, 0, oldTaskCount); var oldTaskArr = Redis.LRange(RedisExpandKey.IDTask, 0, oldTaskCount);
//不自动清理未完成任务 等待执行完毕/失败后自动清理 //不自动清理未完成任务 等待执行完毕/失败后自动清理