Compare commits
No commits in common. "ad0f415ef643a66dc0190e0caa4c50c00b8fd203" and "22330627a85b9b7a0640462cbdcd18dd74a2cf89" have entirely different histories.
ad0f415ef6
...
22330627a8
|
|
@ -66,7 +66,6 @@ namespace Learn.VideoAnalysis
|
|||
builder.Services.AddSimpleTexOcrClient();
|
||||
builder.Services.AddDownloadFileExpand();
|
||||
builder.Services.AddAlibabaCloudVod();
|
||||
builder.Services.AddAliyunOSS();
|
||||
builder.Services.AddRedisExpand();
|
||||
builder.Services.AddSpeakerAI();
|
||||
builder.Services.AddCoravel();
|
||||
|
|
|
|||
|
|
@ -58,21 +58,13 @@
|
|||
"DB": {
|
||||
"ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None",
|
||||
"SqlType": "MySql",
|
||||
"UpdateTable": true
|
||||
"UpdateTable": false
|
||||
},
|
||||
"AlibabaCloudVod": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"EndPoint": "vod.cn-shanghai.aliyuncs.com" //上传节点
|
||||
},
|
||||
"AliyunOSS": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"BucketDomain": "https://learn-videoanalysis.oss-cn-chengdu.aliyuncs.com",
|
||||
"Region": "cn-chengdu",
|
||||
"BucketName": "learn-videoanalysis",
|
||||
"EndPoint": "oss-cn-chengdu.aliyuncs.com" //上传节点
|
||||
},
|
||||
"OtherDBArr": [
|
||||
{
|
||||
"ConfigId": 1001, //ResourceBank
|
||||
|
|
|
|||
|
|
@ -204,14 +204,13 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT
|
|||
messages = messageArr
|
||||
};
|
||||
|
||||
var time = DateTime.Now.ToString("MMddHHmmss");
|
||||
RedisExpand.SetTaskGPTCached(task, time,chatRep);
|
||||
RedisExpand.SetTaskGPTReqCached(task, chatRep);
|
||||
var chatResp = await chatClient.Chat(chatRep);
|
||||
var chatResContent = chatResp?.res;
|
||||
if (string.IsNullOrEmpty(chatResContent))
|
||||
throw new Exception("GPT返回message无效结果");
|
||||
if (chatResp != null)
|
||||
RedisExpand.SetTaskGPTCached(task, time, new object[] { chatResp.Value.res, chatResp.Value.u });
|
||||
RedisExpand.SetTaskGPTCached(task, new object[] { chatResp.Value.res, chatResp.Value.u });
|
||||
|
||||
chatResContent = chatResContent?.Replace("字幕内容", "课堂情况");
|
||||
chatResContent = chatResContent?.Replace("\n", "");
|
||||
|
|
@ -308,14 +307,13 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT
|
|||
]
|
||||
};
|
||||
|
||||
var time = DateTime.Now.ToString("MMddHHmmss");
|
||||
RedisExpand.SetTaskGPTCached(task, time, chatRep);
|
||||
RedisExpand.SetTaskGPTReqCached(task, chatRep);
|
||||
var chatResp = await chatClient.Chat(chatRep);
|
||||
var chatResContent = chatResp?.res;
|
||||
if (string.IsNullOrEmpty(chatResContent))
|
||||
throw new Exception("GPT返回message无效结果");
|
||||
if (chatResp != null)
|
||||
RedisExpand.SetTaskGPTCached(task, time, new object[] { chatResp.Value.res, chatResp.Value.u });
|
||||
RedisExpand.SetTaskGPTCached(task, new object[] { chatResp.Value.res, chatResp.Value.u });
|
||||
|
||||
chatResContent = chatResContent?.Replace("字幕内容", "课堂情况");
|
||||
chatResContent = chatResContent?.Replace("\n", "");
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ using System.Linq;
|
|||
using System.Security.Cryptography;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using FFmpeg.NET.Services;
|
||||
using Aliyun.OSS;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||
{
|
||||
|
|
@ -31,16 +29,14 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
private readonly Repository<VideoTask> videoTaskDB;
|
||||
private readonly Repository<VideoKonwPoint> videoKonwPointDB;
|
||||
private readonly Repository<VideoQuestion> videoQuestionDB;
|
||||
private readonly Repository<VideoQuestionKonw> videoQuestionKonwDB;
|
||||
private readonly Repository<KnowledgeInfo> knowledgeInfoDB;
|
||||
private readonly SimpLetexClient simpLetexClient;
|
||||
private readonly OssClient ossClient;
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
/// <param name="moonshotClient"></param>
|
||||
/// <param name="logger"></param>
|
||||
public DeepSeek_GPT(DeepSeekGPTClient moonshotClient, Repository<CourseGradingCriteria> criteria, Repository<VideoTask> videoTaskDB, Repository<KnowledgeInfo> knowledgeInfoDB, Repository<VideoKonwPoint> videoKonwPointDB, SimpLetexClient simpLetexClient, Repository<VideoQuestion> videoQuestionDB, OssClient ossClient, Repository<VideoQuestionKonw> videoQuestionKonwDB)
|
||||
public DeepSeek_GPT(DeepSeekGPTClient moonshotClient, Repository<CourseGradingCriteria> criteria, Repository<VideoTask> videoTaskDB, Repository<KnowledgeInfo> knowledgeInfoDB, Repository<VideoKonwPoint> videoKonwPointDB, SimpLetexClient simpLetexClient, Repository<VideoQuestion> videoQuestionDB)
|
||||
{
|
||||
chatClient = moonshotClient;
|
||||
criteriaDB = criteria;
|
||||
|
|
@ -49,8 +45,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
this.videoKonwPointDB = videoKonwPointDB;
|
||||
this.simpLetexClient = simpLetexClient;
|
||||
this.videoQuestionDB = videoQuestionDB;
|
||||
this.ossClient = ossClient;
|
||||
this.videoQuestionKonwDB = videoQuestionKonwDB;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取内容对应的章节
|
||||
|
|
@ -87,7 +81,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
$" 格式 (方法点Id|方法点名称) " +
|
||||
$"提供的知识点名称({knows})。";
|
||||
Console.WriteLine(DateTime.Now + "=>2.开始分析视频内容知识点");
|
||||
var konwRes = await ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), knowMessages, "知识点");
|
||||
var konwRes = await ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), knowMessages, null);
|
||||
|
||||
for (int i = 0; i < konwRes.Count(); i++)
|
||||
questionRes[i].KnowPoint = konwRes[i].KnowPoint;
|
||||
|
|
@ -101,7 +95,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
s =>
|
||||
{
|
||||
var ks = s.KnowPoint.Split(",").Distinct();
|
||||
var StageId=Yitter.IdGenerator.YitIdHelper.NextId();
|
||||
return ks.Where(x => knowDic.ContainsKey(x))
|
||||
.Select(x => new VideoKonwPoint()
|
||||
{
|
||||
|
|
@ -109,7 +102,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
Theme = s.Theme,
|
||||
StartTime = s.StartTime,
|
||||
EndTime = s.EndTime,
|
||||
StageId = StageId,
|
||||
KnowPoint = x,
|
||||
KnowPointId = knowDic[x].ToString(),
|
||||
TagId = taskInfo.TagId,
|
||||
|
|
@ -152,7 +144,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
$"输出格式 json字符串 对象格式{fileNameResFormat}";
|
||||
var task = taskInfo.Id.ToString();
|
||||
var fileNameInfoRes = await ChatAsync<FileNameInfo>
|
||||
(task, fileNamePostMessages, "授课章节");
|
||||
(task, fileNamePostMessages, null);
|
||||
taskInfo.Sections = fileNameInfoRes.授课章节;
|
||||
await videoTaskDB.AsUpdateable()
|
||||
.SetColumns(it => it.Sections == fileNameInfoRes.授课章节)
|
||||
|
|
@ -182,7 +174,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
$"字幕格式(说话人:开始秒:结束秒:内容|下一段字幕).以下是包含时间的视频字幕文本。字幕列表 {captions.Captions}。" +
|
||||
$"最后输出格式为json({checkResFormat})";
|
||||
Console.WriteLine(DateTime.Now + "=>3.开始检查视频分段结果");
|
||||
return await ChatAsync<CheckMessageDto>(taskInfo.Id.ToString(), checkMessage, "结果检查");
|
||||
return await ChatAsync<CheckMessageDto>(taskInfo.Id.ToString(), checkMessage, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -210,20 +202,20 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
.Take(spanCount);
|
||||
if (cArr.Count() == 0)
|
||||
return;
|
||||
var nowCaptionStr =JsonSerializer.Serialize(cArr.Select(s =>s.Text));
|
||||
var nowCaptionStr = string.Join('|', cArr.Select(s => /*s.Start + ":" +*/ s.Text));
|
||||
var resFormat = """[string(修改结果)]""";
|
||||
var postMessages =
|
||||
$"这是一堂中国课的字幕由结果是语音识别提供。" +
|
||||
$"字幕内容与{subject}学科{sections}章节相关。" +
|
||||
$"需要你帮我修复其中的错别字,修复公式。" +
|
||||
$"请注意 只允许对字幕进行修改不允许删除字幕的字或者添加字。" +
|
||||
$"请确保输出字幕条数与输入字幕条数一致!!!" +
|
||||
$"输出内容只返回json格式({resFormat})" +
|
||||
$"字幕内容(JSON字符串)" +
|
||||
$"字幕内容(使用|符号分割)" +
|
||||
$"`{nowCaptionStr}`" +
|
||||
$"字幕结束。" +
|
||||
$"最后请确保输出字幕条数与输入字幕条数一致!!! 如果不一致则重新优化并且确保字幕条数一致!!!!";
|
||||
$"字幕结束。 ";
|
||||
Console.WriteLine(DateTime.Now + $"=>字幕优化 分段{s}/{totalCount}开始...");
|
||||
var resData = await ChatAsync<string[]>(taskInfo.Id.ToString(), postMessages, "优化字幕", "deepseek-chat");
|
||||
var resData = await ChatAsync<string[]>(taskInfo.Id.ToString(), postMessages, null, "deepseek-chat");
|
||||
if (resData.Count() != cArr.Count())
|
||||
{
|
||||
Console.WriteLine(DateTime.Now + $"=>字幕优化 分段{s}/{totalCount} AI结果数量不匹配,重试");
|
||||
|
|
@ -288,7 +280,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
$"字幕列表 {nowCaptionStr} 字幕结束!";
|
||||
|
||||
Console.WriteLine(DateTime.Now + $"=>{taskInfo.Id.ToString()}.开始分析视频内容 {lastTime}~{endTime}");
|
||||
questionRes.AddRange(await ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), postMessages, "分析字幕"));
|
||||
questionRes.AddRange(await ChatAsync<VideoKnowRes[]>(taskInfo.Id.ToString(), postMessages, null));
|
||||
lastTime = (int)questionRes.Last().EndTime.Value - (lastTime == 0 ? 0 : 30);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -325,8 +317,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
Course_Id = 27;
|
||||
break;
|
||||
}
|
||||
if(taskInfo.VideoType == AttachmentsInfoType.Review)
|
||||
await AnalysisVideoQuestions(taskInfo);
|
||||
|
||||
//AnalysisVideoQuestions(taskInfo,)
|
||||
|
||||
|
||||
var captionsArr = JsonSerializer.Deserialize<SenseVoiceRes[]>(taskInfo.Captions);
|
||||
|
|
@ -379,10 +371,11 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
return null;
|
||||
}
|
||||
|
||||
public async Task<T> ChatAsync<T>(string task, string postMessages, string title, string model = "deepseek-reasoner")
|
||||
public async Task<T> ChatAsync<T>(string task, string postMessages, string postMessages1, string model = "deepseek-reasoner")
|
||||
{
|
||||
Message[] messageArr = [
|
||||
new Message(postMessages,"user"),
|
||||
string.IsNullOrEmpty(postMessages1)?null:new Message(postMessages1,"user"),
|
||||
];
|
||||
messageArr = messageArr.Where(s => s != null).ToArray();
|
||||
var chatRep = new ChatRequest
|
||||
|
|
@ -398,17 +391,14 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
{
|
||||
try
|
||||
{
|
||||
var time = title+DateTime.Now.ToString("MMddHHmmss");
|
||||
var redisCached = new object[2] { chatRep, null };
|
||||
RedisExpand.SetTaskGPTCached(task, time,chatRep);
|
||||
RedisExpand.SetTaskGPTReqCached(task, chatRep);
|
||||
var chatResp = await chatClient.Chat(chatRep);
|
||||
var chatResContent = chatResp?.res;
|
||||
if (string.IsNullOrEmpty(chatResContent))
|
||||
throw new Exception("GPT返回message无效结果");
|
||||
if (chatResp != null) {
|
||||
redisCached[1] = new object[] { chatResp.Value.res, chatResp.Value.u, chatResp.Value.reasoning };
|
||||
RedisExpand.SetTaskGPTCached(task, time, redisCached);
|
||||
}
|
||||
if (chatResp != null)
|
||||
RedisExpand.SetTaskGPTCached(task, new object[] { chatResp.Value.res, chatResp.Value.u, chatResp.Value.reasoning });
|
||||
|
||||
chatResContent = chatResContent?.Replace("字幕内容", "课堂情况");
|
||||
chatResContent = chatResContent?.Replace("\n", "");
|
||||
chatResContent = chatResContent?.Replace("```json", "");
|
||||
|
|
@ -447,18 +437,17 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 提取试题
|
||||
/// 优化字幕
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<SenseVoiceRes[]> AnalysisVideoQuestions(VideoTask taskInfo)
|
||||
{
|
||||
|
||||
if (taskInfo is null || string.IsNullOrEmpty(taskInfo.PPTKeyFrame))
|
||||
if (taskInfo is null || !string.IsNullOrEmpty(taskInfo.PPTKeyFrame))
|
||||
return null;
|
||||
var farmeArr = JsonSerializer.Deserialize<int[]>(taskInfo.PPTKeyFrame);
|
||||
var videoKnowArr = await videoKonwPointDB.GetListAsync(s => s.VideoTaskId == taskInfo.Id);
|
||||
var insertData =new List<VideoQuestionOSSDto>();
|
||||
var insertQuestionKonw = new List<VideoQuestionKonw>();
|
||||
var insertData =new List<VideoQuestion>();
|
||||
foreach (var item in farmeArr)
|
||||
{
|
||||
var knowInfoArr = videoKnowArr
|
||||
|
|
@ -466,47 +455,33 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
.ToArray();
|
||||
if (knowInfoArr is null || knowInfoArr.Count() ==0)
|
||||
return null;
|
||||
var tryCount = 50;
|
||||
while (tryCount>1)
|
||||
while (true)
|
||||
{
|
||||
tryCount--;
|
||||
try
|
||||
{
|
||||
var filePath = taskInfo.FramePath(item);
|
||||
var sRes = await simpLetexClient
|
||||
.ProcessImageAsync(new SimpleTexOcrRequest(filePath));
|
||||
.ProcessImageAsync(new SimpleTexOcrRequest(taskInfo.FramePath(item)));
|
||||
if (!sRes.Success)
|
||||
continue;
|
||||
var knowArr=string.Join(',', knowInfoArr.Select(s => s.KnowPoint + "|"+s.KnowPointId));
|
||||
var resFormat = """[{"TopicStem":string(试题题干),"Question:string(问题)","KnowPointId":(string)知识点ID}]""";
|
||||
var resFormat = """[{"TopicStem":string(试题题干),"Question:string(问题)","KnowPointId":(string)知识点ID(多个使用逗号拼接)}]""";
|
||||
var postMessages =
|
||||
$"提供一段内容是md格式的试题内容字符串。" +
|
||||
$"请提取出其中的试题内容。并且为每个试题关联上在我限定范围内的知识点(多个则用逗号分割)。" +
|
||||
$"请提取出其中的试题内容。并且为他们关联上在我限定范围内的知识点。" +
|
||||
$"知识点范围[{knowArr}]。" +
|
||||
$"排除不是试题内容的文字,优化公式排版并且去除题号。" +
|
||||
$"如果存在多道大题,请帮忙拆分开!" +
|
||||
$"输出内容只返回json格式为({resFormat})" +
|
||||
$"以下是试题内容" +
|
||||
$"`{sRes.Result.res.info.markdown}`";
|
||||
var resData = await ChatAsync<VideoQuestionOSSDto[]>(taskInfo.Id.ToString(), postMessages, "提取试题", "deepseek-chat");
|
||||
var resData = await ChatAsync<VideoQuestion[]>(taskInfo.Id.ToString(), postMessages, null, "deepseek-chat");
|
||||
foreach (var q in resData)
|
||||
{
|
||||
q.FilePath = filePath;
|
||||
q.VideoTaskId = taskInfo.Id;
|
||||
q.StageId = knowInfoArr.First().StageId;
|
||||
foreach (var kid in q.KnowPointId.Split(","))
|
||||
{
|
||||
insertQuestionKonw.Add(new VideoQuestionKonw()
|
||||
{
|
||||
KnowPoint = knowInfoArr.First(s => s.KnowPointId == kid).KnowPoint,
|
||||
KnowPointId= kid,
|
||||
StageId =q.StageId,
|
||||
VideoTaskId = q.VideoTaskId,
|
||||
});
|
||||
}
|
||||
q.VideoKonwPoint = knowInfoArr.First().Id;
|
||||
}
|
||||
//处理知识点
|
||||
insertData.AddRange(resData);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -514,17 +489,9 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
|||
}
|
||||
}
|
||||
}
|
||||
//分组共同题干试题ID
|
||||
foreach (var item in insertData.GroupBy(x => x.TopicStem))
|
||||
{
|
||||
var keyId=YitIdHelper.NextId();
|
||||
foreach (var s in item)
|
||||
s.TopicId = keyId;
|
||||
}
|
||||
//上传oss
|
||||
ossClient.AddVideoQuestionUrl(insertData);
|
||||
await videoQuestionDB.InsertRangeAsync(insertData.Adapt<VideoQuestion[]>());
|
||||
await videoQuestionKonwDB.InsertRangeAsync(insertQuestionKonw);
|
||||
|
||||
|
||||
await videoQuestionDB.InsertRangeAsync(insertData);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"Env": [],
|
||||
"IIsConfig": {
|
||||
"SdkType": null,
|
||||
"WebSiteName": "",
|
||||
"LastEnvName": null,
|
||||
"EnvPairList": []
|
||||
},
|
||||
"WindowsServiveConfig": {
|
||||
"ServiceName": "",
|
||||
"SdkType": null,
|
||||
"LastEnvName": null,
|
||||
"EnvPairList": []
|
||||
},
|
||||
"LinuxServiveConfig": {
|
||||
"ServiceName": "",
|
||||
"EnvParam": "",
|
||||
"LastEnvName": null,
|
||||
"EnvPairList": []
|
||||
},
|
||||
"DockerConfig": {
|
||||
"Prot": "",
|
||||
"AspNetCoreEnv": "",
|
||||
"LastEnvName": null,
|
||||
"RemoveDaysFromPublished": "10",
|
||||
"WorkDir": "",
|
||||
"Volume": "",
|
||||
"Other": "",
|
||||
"EnvPairList": []
|
||||
},
|
||||
"DockerImageConfig": {
|
||||
"BaseHttpProxy": "",
|
||||
"BaseImage": "",
|
||||
"BaseImageCredential": {
|
||||
"UserName": "",
|
||||
"Password": ""
|
||||
},
|
||||
"TargetImage": "",
|
||||
"TargetHttpProxy": "",
|
||||
"TargetTags": [
|
||||
""
|
||||
],
|
||||
"TargetImageCredential": {
|
||||
"UserName": "",
|
||||
"Password": ""
|
||||
},
|
||||
"ImageFormat": "Docker",
|
||||
"Entrypoint": [
|
||||
""
|
||||
],
|
||||
"Cmd": [
|
||||
""
|
||||
],
|
||||
"IgnoreList": [],
|
||||
"SkipExistingImages": false
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ namespace VideoAnalysisCore.Common
|
|||
/// <returns></returns>
|
||||
public static string FramePath(this VideoTask task, int fTime)
|
||||
{
|
||||
return Path.Combine(task.Id.ToString().LocalPath(), $"{FrameName}{(fTime / 5).ToString().PadLeft(3,'0')}.jpg");
|
||||
return Path.Combine(task.Id.ToString().LocalPath(), $"{FrameName}{fTime / 5}.jpg");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ namespace VideoAnalysisCore.Common
|
|||
/// 阿里云视频点播配置
|
||||
/// </summary>
|
||||
public AlibabaCloudVodConfig AlibabaCloudVod { get; set; } = new AlibabaCloudVodConfig();
|
||||
public AliyunOSSConfig AliyunOSS { get; set; } = new AliyunOSSConfig();
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,113 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AlibabaCloud.OpenApiClient.Models;
|
||||
using AlibabaCloud.SDK.Vod20170321;
|
||||
using AlibabaCloud.SDK.Vod20170321.Models;
|
||||
using AlibabaCloud.TeaUtil.Models;
|
||||
using Aliyun.OSS.Common;
|
||||
using Aliyun.OSS;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using VideoAnalysisCore.Job;
|
||||
using VideoAnalysisCore.Model;
|
||||
using System.Security.AccessControl;
|
||||
using Aliyun.Credentials.Models;
|
||||
using VideoAnalysisCore.Model.Dto;
|
||||
using System.IO;
|
||||
|
||||
namespace VideoAnalysisCore.Common
|
||||
{
|
||||
public class AliyunOSSConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
public string AccessKeyId { get; set; }
|
||||
/// <summary>
|
||||
///密钥
|
||||
/// </summary>
|
||||
public string AccessKeySecret { get; set; }
|
||||
/// <summary>
|
||||
/// 区域Url
|
||||
/// </summary>
|
||||
public string Region { get; set; }
|
||||
/// <summary>
|
||||
/// 筒域名
|
||||
/// </summary>
|
||||
public string BucketDomain { get; set; }
|
||||
/// <summary>
|
||||
/// 桶名称
|
||||
/// </summary>
|
||||
public string BucketName { get; set; }
|
||||
public string Endpoint { get; set; } = "oss-cn-chengdu.aliyuncs.com";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 阿里云 视频点播拓展
|
||||
/// </summary>
|
||||
public static class AliyunOSSExpand
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用阿里云 vod拓展
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
/// <returns></returns>
|
||||
public static void AddAliyunOSS(this IServiceCollection service)
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now}=>初始化 阿里云OSS");
|
||||
AliyunOSSConfig config = new()
|
||||
{
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
AccessKeyId = AppCommon.Config.AliyunOSS.AccessKeyId,
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
AccessKeySecret = AppCommon.Config.AliyunOSS.AccessKeySecret,
|
||||
Endpoint = AppCommon.Config.AliyunOSS.Endpoint
|
||||
};// 创建ClientConfiguration实例,按照您的需要修改默认参数。
|
||||
var conf = new ClientConfiguration();
|
||||
// 设置v4签名。
|
||||
conf.SignatureVersion = SignatureVersion.V4;
|
||||
// 创建OssClient实例。
|
||||
var oss = new OssClient(config.Endpoint, config.AccessKeyId, config.AccessKeySecret, conf);
|
||||
oss.SetRegion(config.Region);
|
||||
|
||||
service.AddSingleton(oss);
|
||||
}
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="oss"></param>
|
||||
/// <param name="fileArr">视频尸体片段</param>
|
||||
public static void AddVideoQuestionUrl(this OssClient oss, List<VideoQuestionOSSDto> fileArr )
|
||||
{
|
||||
var cached = new HashSet<string>();
|
||||
foreach (var item in fileArr)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = item.VideoTaskId.ToString() + "/" + Path.GetFileName(item.FilePath);
|
||||
if (cached.Contains(item.FilePath))
|
||||
{
|
||||
item.ImageUrl = AppCommon.Config.AliyunOSS.BucketDomain + "/" + path;
|
||||
continue;
|
||||
}
|
||||
using var file = File.OpenRead(item.FilePath);
|
||||
var result = oss
|
||||
.PutObject(
|
||||
AppCommon.Config.AliyunOSS.BucketName,
|
||||
path,
|
||||
file);
|
||||
item.ImageUrl = AppCommon.Config.AliyunOSS.BucketDomain + "/" + path;
|
||||
cached.Add(item.FilePath);
|
||||
continue;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ namespace VideoAnalysisCore.Common
|
|||
/// 用以指定识别图片的类型,如果使用auto则会自动检测,使用document会返回markdown文档结果,使用formula会返回LaTeX结果
|
||||
/// <para>"auto", "document", "formula"</para>
|
||||
/// </summary>
|
||||
public string rec_mode { get; set; } = "document";
|
||||
public string rec_mode { get; set; } = "auto";
|
||||
/// <summary>
|
||||
/// 开启后,模型将基于0°,90°, 180°, 270°自动矫正上传图片的方向,默认不开启
|
||||
/// </summary>
|
||||
|
|
@ -159,9 +159,8 @@ namespace VideoAnalysisCore.Common
|
|||
try
|
||||
{
|
||||
var response = await client.SendAsync(requestMessage);
|
||||
var resStr = await response.Content.ReadAsStringAsync();
|
||||
var responseContent = await response.Content.ReadFromJsonAsync<SimpleTexOcrResponseData>();
|
||||
request.file.Dispose();
|
||||
|
||||
return new SimpleTexOcrResponse
|
||||
{
|
||||
Success = response.IsSuccessStatusCode,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VideoAnalysisCore.Common.Expand
|
||||
{
|
||||
public static class StartUpExpand
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -106,9 +106,13 @@ namespace VideoAnalysisCore.Common
|
|||
/// 缓存GPT任务缓存
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
public static void SetTaskGPTCached(object taskId,string time, object? data)
|
||||
public static void SetTaskGPTCached(object taskId, object? data)
|
||||
{
|
||||
Redis.Set(RedisExpandKey.TaskGPT(taskId) + ":" + time, data, 3600 * 24);
|
||||
Redis.Set(RedisExpandKey.TaskGPT(taskId) + ":" + DateTime.Now.ToString("MMddHHmmss") + "01", data, 3600 * 24);
|
||||
}
|
||||
public static void SetTaskGPTReqCached(object taskId, object? data)
|
||||
{
|
||||
Redis.Set(RedisExpandKey.TaskGPT(taskId) + ":" + DateTime.Now.ToString("MMddHHmmss")+ "00", data, 3600 * 24);
|
||||
}
|
||||
/// <summary>
|
||||
/// 加入到消费队列
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@ namespace VideoAnalysisCore.Controllers
|
|||
TagId = req.TagId,
|
||||
MediaName = req.Name,
|
||||
PPTVideoCode = req.PPTVideoCode,
|
||||
VideoType=req.VideoType
|
||||
};
|
||||
//Èë¿â
|
||||
var hashEntries = task.GetType()
|
||||
|
|
|
|||
|
|
@ -121,10 +121,6 @@ namespace VideoAnalysisCore.Controllers.Dto
|
|||
/// </summary>
|
||||
public TaskTypeEnum? Type { get; set; }
|
||||
/// <summary>
|
||||
/// 视频类型
|
||||
/// </summary>
|
||||
public AttachmentsInfoType? VideoType { get; set; }
|
||||
/// <summary>
|
||||
/// 自定义值 任务完成后附带通知
|
||||
/// </summary>
|
||||
public string Tag { get; set; } = string.Empty;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace VideoAnalysisCore.Controllers
|
|||
TaskType = req.TaskType,
|
||||
SubjectType = req.SubjectType,
|
||||
VideoUrl =s.VideoUrl,
|
||||
CallBackUrl=s.CallBackUrl,
|
||||
CallBackUrl=s.CallBackUrl
|
||||
};
|
||||
nodePackages.Add(np);
|
||||
if (s.AttachmentsInfoType == AttachmentsInfoType.PPT)
|
||||
|
|
@ -117,7 +117,6 @@ namespace VideoAnalysisCore.Controllers
|
|||
MediaUrl =s.VideoUrl,
|
||||
MediaName = s.VideoName,
|
||||
PPTVideoCode = pptCode,
|
||||
VideoType =s.AttachmentsInfoType
|
||||
});
|
||||
}
|
||||
await nodePackageInfoDB.InsertRangeAsync(nodePackages);
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VideoAnalysisCore.Model.Dto
|
||||
{
|
||||
public class VideoQuestionOSSDto: VideoQuestion
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public string KnowPointId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -20,17 +20,13 @@ namespace VideoAnalysisCore.Model
|
|||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 视频任务id
|
||||
/// </summary>
|
||||
public long VideoTaskId { get; set; }
|
||||
/// <summary>
|
||||
/// 视频阶段id
|
||||
/// </summary>
|
||||
public long StageId { get; set; }
|
||||
/// <summary>
|
||||
/// 自定义Id [任务视频自定义id]
|
||||
/// <see cref="VideoTask.TagId"/>
|
||||
/// </summary>
|
||||
|
|
@ -71,7 +67,6 @@ namespace VideoAnalysisCore.Model
|
|||
/// <summary>
|
||||
/// 课程阶段
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public virtual StageEnum? Stage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,26 +27,22 @@ namespace VideoAnalysisCore.Model
|
|||
/// </summary>
|
||||
public long VideoTaskId { get; set; }
|
||||
/// <summary>
|
||||
/// 视频阶段id
|
||||
/// <para>隶属于<see cref="VideoKonwPoint.StageId"/></para>
|
||||
/// 视频片段ID
|
||||
/// <para>隶属于<see cref="VideoKonwPoint.Id"/></para>
|
||||
/// </summary>
|
||||
public long StageId { get; set; }
|
||||
public long VideoKonwPoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 题干id
|
||||
/// <para>[用于多个一个题干多个问题]</para>
|
||||
/// 知识点
|
||||
/// </summary>
|
||||
public long TopicId { get; set; }
|
||||
|
||||
public string? KnowPoint { get; set; }
|
||||
/// <summary>
|
||||
/// 图片地址
|
||||
/// 知识点ID
|
||||
/// </summary>
|
||||
[SugarColumn(Length =100)]
|
||||
public string? ImageUrl { get; set; }
|
||||
public string? KnowPointId { get; set; }
|
||||
/// <summary>
|
||||
/// 题干
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType ="text")]
|
||||
public string? TopicStem { get; set; }
|
||||
/// <summary>
|
||||
/// 问题(设问)
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
using SqlSugar;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using UserCenter.Model.Enum;
|
||||
using VideoAnalysisCore.AICore.GPT.Dto;
|
||||
using VideoAnalysisCore.AICore.SherpaOnnx;
|
||||
using VideoAnalysisCore.Model.Enum;
|
||||
using VideoAnalysisCore.Model.Interface;
|
||||
using Whisper.net;
|
||||
|
||||
namespace VideoAnalysisCore.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 视频片段试题知识点关系表
|
||||
/// </summary>
|
||||
[SugarTable("videoquestionkonw")]
|
||||
public class VideoQuestionKonw : IDB
|
||||
{
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 视频任务id
|
||||
/// </summary>
|
||||
public long VideoTaskId { get; set; }
|
||||
/// <summary>
|
||||
/// 知识点名称
|
||||
/// </summary>
|
||||
public string KnowPoint { get; set; }
|
||||
/// <summary>
|
||||
/// 知识点ID
|
||||
/// </summary>
|
||||
public string KnowPointId { get; set; }
|
||||
/// <summary>
|
||||
/// 视频阶段id
|
||||
/// <para>隶属于<see cref="VideoKonwPoint.StageId"/></para>
|
||||
/// </summary>
|
||||
public long StageId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -59,12 +59,6 @@ namespace VideoAnalysisCore.Model
|
|||
[SugarColumn(IsNullable = true)]
|
||||
public TaskTypeEnum? Type { get; set; }
|
||||
/// <summary>
|
||||
/// 视频类型
|
||||
/// <para>常规,教研,PPT...</para>
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public AttachmentsInfoType? VideoType { get; set; }
|
||||
/// <summary>
|
||||
/// 自定义值 任务完成后附带通知
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 500, IsNullable = true)]
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlibabaCloud.SDK.Vod20170321" Version="3.6.1" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||
<PackageReference Include="Coravel" Version="6.0.2" />
|
||||
<PackageReference Include="FreeRedis" Version="1.3.2" />
|
||||
<PackageReference Include="Downloader" Version="3.2.1" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue