修改 数据结构后调整管理端UI

优化 任务接收辞池[进行中]
This commit is contained in:
小肥羊 2025-06-13 18:23:30 +08:00
parent f943c4fec4
commit f7c787cdf7
9 changed files with 67 additions and 70 deletions

View File

@ -20,7 +20,6 @@
<ColumnDefinitions Context="row">
<Selection />
<PropertyColumn Property="c=>c.Id" Width="110px" Filterable="true" Sortable="true" />
<PropertyColumn Property="c=>c.MediaName" Width="200px" />
<PropertyColumn Property="c=>c.TagId" Width="160px" />
<PropertyColumn Property="c=>c.LastEnum" Width="150px" />
<PropertyColumn Property="c=>c.Subject" Width="100px" />

View File

@ -6,8 +6,7 @@
<div id="segmentsContainer" class="sc">
<h2>
<button class="gudingBtn" onclick="gd(this)">🔒</button>
@nowTask.MediaName</h2>
<button class="gudingBtn" onclick="gd(this)">🔒</button></h2>
@for (int i = 0; i < videoKnows.Length; i++)
{
var item = videoKnows[i];
@ -20,6 +19,8 @@
</div>
<div>概览: @item.Content</div>
<br />
@if (item.QuestionArr != null)
{
@foreach (var q in item.QuestionArr)
{
@ -31,6 +32,7 @@
</div>
<br />
}
}
<br />
<br />

View File

@ -82,9 +82,8 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT
.Where(s => s.Course_Id == 27
&& s.Depth == 2)
.Select(s => s.Name).ToArrayAsync();
string title = taskInfo.MediaName;
var fileNameResFormat = "{授课章节: string|null, 授课内容:string}";
var fileNamePostMessages = title +
var fileNamePostMessages =
" 这是一堂课的标题,请你帮我分析一些关于课堂方面的内容." +
$"1.分析出高中{subject}课堂授课的主要章节(例如 章节: 数列),章节范围限定在[{string.Join(',', xkwKnows)}]范围." +
$"2.分析出这堂课的主要授课内容." +

View File

@ -386,7 +386,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
foreach (var item in farmeArr)
{
var knowInfoArr = videoKnowArr
.Where(s => item+30 >= s.StartTime && item <= s.EndTime)
.Where(s => item+20 >= s.StartTime && item < s.EndTime)
.ToArray();
if (knowInfoArr is null || knowInfoArr.Count() ==0)
continue;
@ -414,7 +414,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
$"排除不是试题内容的文字,优化试题排版并且去除题号,尽量保留latex数学公式。" +
$"如果存在多道题,则需要拆分成为多个试题对象!" +
$"试题的类型约束在 填空题/判断题/选择题/解答题/填空题 范围内。" +
$"如果存在题干中存在下划线则试题的题型应该是填空题。" +
$"如果是有效试题且题干中存在下划线则试题的题型应该是填空题。" +
$"请检查我提供的字符串内容,如果不能识别知识点则不处理知识点,如不包含问题试题则返回`[]`" +
$"输出内容只返回json格式为({resFormat})" +
$"以下是试题内容" +

View File

@ -179,9 +179,11 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
.Where(it => it.Id == long.Parse(task))
.ExecuteCommandAsync();
await RedisExpand.Redis.HMSetAsync(RedisExpandKey.Task(task), "Captions", res);
//RedisExpand.InsertChannel(Enum.RedisChannelEnum.ParsingSpeaker, task);
//分析完成视频字幕后继续接收任务
RedisExpand.NewTask();
await RedisExpand.NewTaskAsync();
RedisExpand.InsertChannel(RedisChannelEnum.ChatModelAnalysis, task);
}

View File

@ -176,7 +176,8 @@ namespace VideoAnalysisCore.Common
// .HMGetAsync<TaskRes>(RedisExpandKey.Task(task), "ChatAnalysis")).FirstOrDefault();
//if (gptRes is null)
// throw new Exception("未能读取到GPT处理结果");
//删除任务执行状态
await Redis.HDelAsync(RedisExpandKey.IDTask,task);
var taskData = await DbScoped.Sugar.Queryable<VideoTask>()
.FirstAsync(s => s.Id == tId);
if (taskData.Captions == "[]")
@ -215,29 +216,23 @@ namespace VideoAnalysisCore.Common
if (Redis is null) throw new Exception("redis未初始化");
SubscribeList.Add(RedisChannelEnum.DownloadFile,
(Action<string>)((msg) => {
TouchChannel(RedisChannelEnum.DownloadFile, msg,
(Func<string, Task>)((task) =>
(msg) => TouchChannel(RedisChannelEnum.DownloadFile, msg,
(task) =>
{
using var scope = AppCommon.Services?.CreateScope();
if (scope is null || ServiceProviderServiceExtensions.GetService<DownloadFile>(scope.ServiceProvider) is null)
if (scope is null || scope.ServiceProvider.GetService<DownloadFile>() is null)
throw new Exception("DownloadFile 未注入");
else
return (Task)(scope.ServiceProvider.GetService<DownloadFile>()?.RunTask(task) ?? Task.CompletedTask);
return scope.ServiceProvider.GetService<DownloadFile>()?.RunTask(task) ?? Task.CompletedTask;
}));
}));
SubscribeList.Add(RedisChannelEnum.SeparateAudio,
(msg) => { TouchChannel(RedisChannelEnum.SeparateAudio, msg, FFMPGEHandle.RunAsync); });
(msg) => TouchChannel(RedisChannelEnum.SeparateAudio, msg, FFMPGEHandle.RunAsync));
SubscribeList.Add(RedisChannelEnum.ParsingCaptions,
(msg) => { TouchChannel(RedisChannelEnum.ParsingCaptions, msg, SenseVoice.RunTask); });
(msg) => TouchChannel(RedisChannelEnum.ParsingCaptions, msg, SenseVoice.RunTask));
SubscribeList.Add(RedisChannelEnum.ParsingSpeaker,
(msg) => { TouchChannel(RedisChannelEnum.ParsingSpeaker, msg, Speaker.Run); });
(msg) => TouchChannel(RedisChannelEnum.ParsingSpeaker, msg, Speaker.Run));
SubscribeList.Add(RedisChannelEnum.ChatModelAnalysis,
(msg) =>
{
TouchChannel(RedisChannelEnum.ChatModelAnalysis, msg,
(msg) => TouchChannel(RedisChannelEnum.ChatModelAnalysis, msg,
(task) =>
{
using var scope = AppCommon.Services?.CreateScope();
@ -245,40 +240,45 @@ namespace VideoAnalysisCore.Common
throw new Exception("IBserGPT 未注入");
else
return scope.ServiceProvider.GetService<IBserGPT>()?.GetKnow(task) ?? Task.CompletedTask;
});
});
}));
SubscribeList.Add(RedisChannelEnum.EndTask,
(msg) => { TouchChannel(RedisChannelEnum.EndTask, msg, TaskEnd); });
(msg) => TouchChannel(RedisChannelEnum.EndTask, msg, TaskEnd));
await ReceivingTaskAsync();
ReceivingTaskAsync();
}
/// <summary>
/// 重新执行新任务
/// </summary>
/// <returns></returns>
public static void NewTask()
public static async Task NewTaskAsync()
{
Task.Run(async () =>
{
await Redis.DelAsync(RedisExpandKey.IDTask);
await ReceivingTaskAsync();
});
ReceivingTaskAsync();
}
/// <summary>
/// 重新接收新任务
/// </summary>
public static async Task ReceivingTaskAsync()
public static void ReceivingTaskAsync()
{
if (AppCommon.Config.TaskSetting.IS_Server)
{
Console.WriteLine($"{DateTime.Now} =>服务端不接收任务");
return;
}
Task.Run(async () =>
{
//todo 项目接收任务进程池
//接收任务加入池
//重试任务加入池
//失败任务删除池
//停止任务删除池
//重启项目运行池内所有可用任务
var oldTask = await Redis.GetAsync(RedisExpandKey.IDTask);
if (!string.IsNullOrEmpty(oldTask))
{
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收重试任务 " + oldTask);
var lastEnum = (await Redis.HMGetAsync<RedisChannelEnum>(RedisExpandKey.Task(oldTask), "LastEnum")).FirstOrDefault();
await SetTaskErrorMessage(long.Parse(oldTask), null);
InsertChannel(lastEnum, oldTask);
@ -289,19 +289,21 @@ namespace VideoAnalysisCore.Common
Subscribe = Redis.SubscribeList(RedisExpandKey.ChannelKey, (taskId) =>
{
if (taskId is null) return;
Subscribe?.Dispose();
Subscribe?.Dispose();//取消接收任务监听
//存储当前机器的任务
Redis.Set(RedisExpandKey.IDTask, taskId);
Redis.HSet(RedisExpandKey.IDTask, taskId,true);
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收到任务 " + taskId);
InsertChannel(RedisChannelEnum.DownloadFile, taskId);
});
});
}
/// <summary>
/// 写入任务异常
/// </summary>
/// <param name="taskID"></param>
/// <param name="errorMessage"></param>
/// <param name="ex"></param>
/// <returns></returns>
public static async Task<bool> SetTaskErrorMessage(long taskID, Exception? ex)
{
@ -315,8 +317,7 @@ namespace VideoAnalysisCore.Common
Console.WriteLine(ex.StackTrace);
Console.WriteLine("==============================================");
//清除失败任务 重新接收任务
await Redis.DelAsync(RedisExpandKey.IDTask);
await ReceivingTaskAsync();
await NewTaskAsync();
}
Redis.HMSet(RedisExpandKey.Task(taskID), "ErrorMessage", error);

View File

@ -190,7 +190,6 @@ namespace VideoAnalysisCore.Controllers
Subject = req.Subject,
Tag = req.Tag,
TagId = req.TagId,
MediaName = req.Name,
PPTVideoCode = req.PPTVideoCode,
VideoType=req.VideoType
};

View File

@ -132,11 +132,6 @@ namespace VideoAnalysisCore.Controllers.Dto
[Required(ErrorMessage = "资源URL是必填项")]
public string MediaUrl { get; set; } = string.Empty;
/// <summary>
/// 资源名称
/// </summary>
[Required(ErrorMessage = "资源名称是必要的")]
public string Name { get; set; } = string.Empty;
/// <summary>
/// ApiKey
/// </summary>
[Required(ErrorMessage = "接口Token是必填项")]