From 53951aa870caa0c0fcfbcaf3d0a9e0d3ff878a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Fri, 6 Feb 2026 17:15:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E7=9A=84AI=E8=AF=B7=E6=B1=82temperature=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VideoAnalysis/Program.cs | 2 +- VideoAnalysisCore/AICore/GPT/BserGPT.cs | 6 ---- .../AICore/GPT/ChatGPT/ChatGPTClient.cs | 1 - .../AICore/GPT/DeepSeek/DeepSeekGPTClient.cs | 1 - .../AICore/GPT/GTP_Analysis_1.cs | 12 +++++-- .../AICore/GPT/Gemini/GeminiGPTClient.cs | 1 - VideoAnalysisCore/Common/RedisExpand.cs | 36 +++++++++++++------ VideoAnalysisCore/Controllers/Dto/ApiDto.cs | 4 +++ .../Controllers/LJZK_Controller.cs | 8 +++++ .../Controllers/VideoTaskController.cs | 2 +- .../Model/Enum/GradeSemesterEnum.cs | 17 +++++++++ VideoAnalysisCore/Model/NodePackageInfo.cs | 19 ++++++++++ VideoAnalysisCore/Model/VideoTask.cs | 21 +++++++++++ VideoAnalysisCore/Model/VideoTaskStage.cs | 22 ++++++++++++ 14 files changed, 129 insertions(+), 23 deletions(-) create mode 100644 VideoAnalysisCore/Model/Enum/GradeSemesterEnum.cs diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index a90ca2d..40f0044 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -101,7 +101,7 @@ namespace Learn.VideoAnalysis app.UseMiddleware("Swagger"); // Configure the HTTP request pipeline. //开启redis队列服务 - //_ = app.Services.GetRequiredService(); + _ = app.Services.GetRequiredService(); app.UseSwagger(); app.UseSwaggerUI(); app.UseExceptionHandler("/Error"); diff --git a/VideoAnalysisCore/AICore/GPT/BserGPT.cs b/VideoAnalysisCore/AICore/GPT/BserGPT.cs index eccc918..d6901f0 100644 --- a/VideoAnalysisCore/AICore/GPT/BserGPT.cs +++ b/VideoAnalysisCore/AICore/GPT/BserGPT.cs @@ -62,12 +62,6 @@ namespace VideoAnalysisCore.AICore.GPT public float? max_tokens { get; set; } = 8000; public float? max_completion_tokens { get; set; } = 8000; /// - /// 瑕佷娇鐢ㄧ殑閲囨牱娓╁害锛屼粙浜 0 鍜 2 涔嬮棿銆傝緝楂樼殑鍊硷紙濡 0.8锛夊皢浣胯緭鍑烘洿鍔犻殢鏈猴紝鑰岃緝浣庣殑鍊硷紙濡 0.2锛夊皢浣垮叾鏇村姞闆嗕腑鍜岀‘瀹氥 鎴戜滑閫氬父寤鸿鏇存敼姝ら」鎴栧悓鏃舵洿鏀逛袱鑰呫倀op_p - /// 榛樿涓 1 - /// 鑱斿姩 - /// - public float? temperature { get; set; } = 0.2f; - /// /// 涓绉嶆浛浠f俯搴﹂噰鏍风殑鏂规硶锛岀О涓哄師瀛愭牳閲囨牱锛 鍏朵腑锛屾ā鍨嬭冭檻鍏锋湁top_p姒傜巼鐨勬爣璁扮殑缁撴灉 璐ㄩ噺銆傛墍浠 0.1 琛ㄧず浠呭寘鍚墠 10% 姒傜巼璐ㄩ噺鐨勪唬甯 琚 /// 寤鸿涓鑱斿姩 /// diff --git a/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs b/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs index 23062df..c03d0e6 100644 --- a/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs @@ -58,7 +58,6 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT title = title, max_tokens = max_tokens, stream = true, - temperature = 0.2f, messages = messageArr }; diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs index b524df3..20308bc 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekGPTClient.cs @@ -57,7 +57,6 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT model = model ?? ChatGPTType.Deepseek_Chat, max_tokens = model == ChatGPTType.Deepseek_Reasoner ? 32000 : max_tokens, stream = true, - temperature = 0.2f, messages = messageArr }; return await base.ChatAsync(chatReq); diff --git a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs index a4c8e87..b6c2999 100644 --- a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs +++ b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs @@ -187,7 +187,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek $"瀛楀箷鍒楄〃 {rCaptionArr}銆" + $"杈撳嚭鏍煎紡 json瀛楃涓 瀵硅薄鏍煎紡{fileNameResFormat}"; var task = taskInfo.Id.ToString(); - var fileNameInfoRes = await chatGPTClient.ChatAsync + var fileNameInfoRes = await geminiClient.ChatAsync (task, fileNamePostMessages, "鎺堣绔犺妭"); taskInfo.Sections = fileNameInfoRes.鎺堣绔犺妭; await videoTaskDB.AsUpdateable() @@ -309,7 +309,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek await Parallel.ForAsync(0, totalCount, new ParallelOptions() #if DEBUG - { MaxDegreeOfParallelism = 1 }, + { MaxDegreeOfParallelism = 4 }, #else { MaxDegreeOfParallelism = 9 }, #endif @@ -725,6 +725,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek throw new Exception("鏈兘鎵惧埌瀵瑰簲鐭ヨ瘑鐐=>" + sections); List? knowledgeInfos = new List(); var kInfo = await knowledgeInfoDB.GetByIdAsync(know.Parent_Id); + if (know.Parent_Id == 0) + kInfo = know; try { knowledgeInfos = await knowledgeInfoDB.AsQueryable() @@ -800,6 +802,10 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek Stage = s.First().Stage, Theme = s.First().Theme, VideoTaskId = taskInfo.Id, + CourseLevel = taskInfo.CourseLevel, + TextBookVersionId = taskInfo.TextBookVersionId, + GradeSemester= taskInfo.GradeSemester, + GradeId = taskInfo.GradeId, }).ToList(); //灏濊瘯杩藉姞 浣滀笟甯冪疆鍒嗘 if (homework != null && (!questionRes.Any(s => s.Stage == StageEnum.浣滀笟甯冪疆.ToString()))) @@ -850,6 +856,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek if (know is null) throw new Exception("鏈兘鎵惧埌瀵瑰簲鐭ヨ瘑鐐=>" + sections); var kInfo = await knowledgeInfoDB.GetByIdAsync(know.Parent_Id); + if (know.Parent_Id == 0) + kInfo = know; var knowledgeInfos = await knowledgeInfoDB.AsQueryable() .ToChildListAsync(s => s.Parent_Id, kInfo.Parent_Id == 0 ? kInfo.Id : kInfo.Parent_Id); //寮濮嬪垎鏋愬涔犺 璇曢 diff --git a/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs b/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs index 36fdac4..772e335 100644 --- a/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/Gemini/GeminiGPTClient.cs @@ -56,7 +56,6 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT model = model, max_tokens = max_tokens, stream = true, - temperature = 0.2f, messages = messageArr, max_completion_tokens= 12288, }; diff --git a/VideoAnalysisCore/Common/RedisExpand.cs b/VideoAnalysisCore/Common/RedisExpand.cs index ea93c88..64892c3 100644 --- a/VideoAnalysisCore/Common/RedisExpand.cs +++ b/VideoAnalysisCore/Common/RedisExpand.cs @@ -139,8 +139,8 @@ namespace VideoAnalysisCore.Common await scope.ServiceProvider.GetService()?.RunTask(task); }); SubscribeList.Add(RedisChannelEnum.鍒嗙闊抽, FFMPGE.RunAsync); - //SubscribeList.Add(RedisChannelEnum.瑙f瀽瀛楀箷, senseVoice.RunTask); - SubscribeList.Add(RedisChannelEnum.瑙f瀽瀛楀箷, funASRNano.RunTask); + SubscribeList.Add(RedisChannelEnum.瑙f瀽瀛楀箷, senseVoice.RunTask); + //SubscribeList.Add(RedisChannelEnum.瑙f瀽瀛楀箷, funASRNano.RunTask); //SubscribeList.Add(RedisChannelEnum.瑙f瀽璇磋瘽浜,Speaker.Run); SubscribeList.Add(RedisChannelEnum.AI璇剧▼绫诲瀷, async (task) => { @@ -433,15 +433,20 @@ namespace VideoAnalysisCore.Common var oldTaskCount = Redis.LLen(RedisExpandKey.IDTask); //閲嶈瘯浠诲姟骞跺彂杩囧鍙兘浼氬鑷寸▼搴忓穿婧 // 鏈兘閲嶆柊鍒嗘瀽鐨勪腑鏂换鍔 鍒欏崟鐙紑涓涓綉椤垫潵澶勭悊 - if (oldTaskCount > 0 ) + if (oldTaskCount > 0) { - var oldTaskArr = Redis.LRange(RedisExpandKey.IDTask, 0, oldTaskCount); - //涓嶈嚜鍔ㄦ竻鐞嗘湭瀹屾垚浠诲姟 绛夊緟鎵ц瀹屾瘯/澶辫触鍚庤嚜鍔ㄦ竻鐞 - //Redis.LTrim(RedisExpandKey.IDTask, 1, 0);//鍒犻櫎 redis 鍒楄〃 - //鏈澶氭墽琛5涓笂娆′腑鏂/鎴栬呮湭瀹屾垚鐨勪换鍔 - foreach (var oldTask in oldTaskArr.Take(5)) + //鑾峰彇鎵鏈夋湭瀹屾垚鐨勪换鍔 + var oldTaskArr = Redis.LRange(RedisExpandKey.IDTask, 0, -1); + Console.WriteLine($"{DateTime.Now:HH:mm:ss}-------------> 鍙戠幇 {oldTaskArr.Length} 涓湭瀹屾垚浠诲姟锛屽噯澶囨仮澶..."); + + //浣跨敤淇″彿閲忛檺鍒跺苟鍙戞暟(5)锛岄槻姝㈠穿婧 + using var semaphore = new System.Threading.SemaphoreSlim(5); + var retryTaskArr = new List(); + + foreach (var oldTask in oldTaskArr) { - _ = Task.Run(async () => + await semaphore.WaitAsync(); + var res = Task.Run(async () => { try { @@ -453,10 +458,21 @@ namespace VideoAnalysisCore.Common catch (Exception ex) { await SetTaskErrorMessage(long.Parse(oldTask), ex); - throw; + Console.WriteLine($"鎭㈠浠诲姟 {oldTask} 澶辫触: {ex.Message}"); + } + finally + { + semaphore.Release(); } }); + retryTaskArr.Add(res); } + //绛夊緟鎵鏈 閲嶈瘯浠诲姟瀹屾垚鍚庢帴鏀舵柊浠诲姟 + await Task.WhenAll(retryTaskArr); + + Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 鎵鏈夋湭瀹屾垚浠诲姟澶勭悊瀹屾瘯!"); + ReceivingTaskAsync(); + } else { diff --git a/VideoAnalysisCore/Controllers/Dto/ApiDto.cs b/VideoAnalysisCore/Controllers/Dto/ApiDto.cs index e874697..786e24a 100644 --- a/VideoAnalysisCore/Controllers/Dto/ApiDto.cs +++ b/VideoAnalysisCore/Controllers/Dto/ApiDto.cs @@ -141,6 +141,10 @@ namespace VideoAnalysisCore.Controllers.Dto /// 鏁欒偛闃舵 /// public EducationStageEnum StageId { get; set; } + /// + /// 骞寸骇鍐岋紙涓婂唽/涓嬪唽锛 + /// + public GradeSemesterEnum? GradeSemester { get; set; } } /// /// 瑙嗛澶勭悊 璇锋眰 diff --git a/VideoAnalysisCore/Controllers/LJZK_Controller.cs b/VideoAnalysisCore/Controllers/LJZK_Controller.cs index 54401e9..812458b 100644 --- a/VideoAnalysisCore/Controllers/LJZK_Controller.cs +++ b/VideoAnalysisCore/Controllers/LJZK_Controller.cs @@ -115,6 +115,10 @@ namespace VideoAnalysisCore.Controllers CloudSchoolId =s.UserCenterCloudSchoolId, Area = s.Area, HostIP = s.HostIP, + StageId = s.StageId, + GradeId = s.GradeId, + GradeSemester = s.GradeSemester, + TextBookVersionId = s.TextBookVersionId, }; nodePackages.Add(np); if (videoIdArr.Contains(s.VideoCode)) continue; @@ -134,6 +138,10 @@ namespace VideoAnalysisCore.Controllers PPTVideoUrl = pptUrl, VideoType = s.CourseType, CloudSchoolId = s.UserCenterCloudSchoolId, + TextBookVersionId = s.TextBookVersionId, + GradeSemester =s .GradeSemester, + CourseLevel =s.CourseLevel, + GradeId = s.GradeId, }); } await nodePackageInfoDB.InsertRangeAsync(nodePackages); diff --git a/VideoAnalysisCore/Controllers/VideoTaskController.cs b/VideoAnalysisCore/Controllers/VideoTaskController.cs index 6d8ccef..8c04b7f 100644 --- a/VideoAnalysisCore/Controllers/VideoTaskController.cs +++ b/VideoAnalysisCore/Controllers/VideoTaskController.cs @@ -266,7 +266,7 @@ namespace VideoAnalysisCore.Controllers TagId = req.TagId, PPTVideoCode = req.PPTVideoCode, PPTVideoUrl = req.PPTVideoUrl, - VideoType = req.VideoType + VideoType = req.VideoType, }; //鍏ュ簱 await baseService.InsertAsync(task); diff --git a/VideoAnalysisCore/Model/Enum/GradeSemesterEnum.cs b/VideoAnalysisCore/Model/Enum/GradeSemesterEnum.cs new file mode 100644 index 0000000..48f90c7 --- /dev/null +++ b/VideoAnalysisCore/Model/Enum/GradeSemesterEnum.cs @@ -0,0 +1,17 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VideoAnalysisCore.Model.Enum +{ + /// + /// 骞寸骇灞傛 + /// + public enum GradeSemesterEnum + { + 涓婂唽 = 1, + 涓嬪唽 = 2 + } +} diff --git a/VideoAnalysisCore/Model/NodePackageInfo.cs b/VideoAnalysisCore/Model/NodePackageInfo.cs index 568a566..c5621c6 100644 --- a/VideoAnalysisCore/Model/NodePackageInfo.cs +++ b/VideoAnalysisCore/Model/NodePackageInfo.cs @@ -83,6 +83,25 @@ namespace VideoAnalysisCore.Model /// public string Area { get; set; } /// + /// 骞寸骇 + /// + [SugarColumn(IsNullable = true)] + public GradeEnum? GradeId { get; set; } + /// + /// 鏁欒偛闃舵 + /// + [SugarColumn(IsNullable = true)] + public EducationStageEnum StageId { get; set; } + /// + /// 骞寸骇鍐岋紙涓婂唽/涓嬪唽锛 + /// + [SugarColumn(IsNullable = true)] + public GradeSemesterEnum? GradeSemester { get; set; } + /// + /// 瀛︾缃戠殑鏁欐潗鐗堟湰Id + /// + public long TextBookVersionId { get; set; } + /// /// 璇锋眰鍖哄煙 /// 鍥炶皟娣诲姞鍒癏eaders /// diff --git a/VideoAnalysisCore/Model/VideoTask.cs b/VideoAnalysisCore/Model/VideoTask.cs index 127e7ba..ea26755 100644 --- a/VideoAnalysisCore/Model/VideoTask.cs +++ b/VideoAnalysisCore/Model/VideoTask.cs @@ -145,5 +145,26 @@ namespace VideoAnalysisCore.Model [SugarColumn(IsNullable = true)] public long? CloudSchoolId { get; set; } + + /// + /// 鏁欐潗灞傛 + /// + [SugarColumn(IsNullable = true)] + public CourselevelTypeEnum? CourseLevel { get; set; } + /// + /// 骞寸骇 + /// + [SugarColumn(IsNullable = true)] + public GradeEnum? GradeId { get; set; } + /// + /// 骞寸骇鍐岋紙涓婂唽/涓嬪唽锛 + /// + [SugarColumn(IsNullable = true)] + public GradeSemesterEnum? GradeSemester { get; set; } + /// + /// 瀛︾缃戠殑鏁欐潗鐗堟湰Id + /// + public long TextBookVersionId { get; set; } + } } diff --git a/VideoAnalysisCore/Model/VideoTaskStage.cs b/VideoAnalysisCore/Model/VideoTaskStage.cs index fd75ca5..2c57c41 100644 --- a/VideoAnalysisCore/Model/VideoTaskStage.cs +++ b/VideoAnalysisCore/Model/VideoTaskStage.cs @@ -57,6 +57,7 @@ namespace VideoAnalysisCore.Model /// /// 鐭ヨ瘑鐐规潵婧 瑙嗛绉,鏉ユ簮鍘熷洜 /// + [SugarColumn(Length = 500, IsNullable = true)] public string Content { get; set; } /// /// 璇剧▼闃舵 @@ -75,5 +76,26 @@ namespace VideoAnalysisCore.Model /// [SugarColumn(IsNullable = true)] public virtual string? TextbookSource { get; set; } + + + /// + /// 鏁欐潗灞傛 + /// + [SugarColumn(IsNullable = true)] + public CourselevelTypeEnum? CourseLevel { get; set; } + /// + /// 骞寸骇 + /// + [SugarColumn(IsNullable = true)] + public GradeEnum? GradeId { get; set; } + /// + /// 骞寸骇鍐岋紙涓婂唽/涓嬪唽锛 + /// + [SugarColumn(IsNullable = true)] + public GradeSemesterEnum? GradeSemester { get; set; } + /// + /// 瀛︾缃戠殑鏁欐潗鐗堟湰Id + /// + public long TextBookVersionId { get; set; } } }