优化 AI分析超时情况
This commit is contained in:
parent
94aa7572bf
commit
42becf154a
|
|
@ -10,6 +10,7 @@ using Whisper.net;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using VideoAnalysisCore.AICore.GPT.ChatGPT;
|
||||
using VideoAnalysisCore.AICore.GPT.DeepSeek;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace VideoAnalysisCore.AICore.GPT
|
||||
{
|
||||
|
|
@ -51,7 +52,7 @@ namespace VideoAnalysisCore.AICore.GPT
|
|||
/// <para>此功能处于 Beta 阶段。 如果指定,我们的系统将尽最大努力确定性地采样,这样具有相同 and 参数的重复请求应该返回相同的结果。 无法保证确定性,您应该参考 response 参数来监控后端的变化</para>
|
||||
/// </summary>
|
||||
public int? seed { get; set; } = null;
|
||||
[json]
|
||||
[JsonIgnore]
|
||||
public string? title { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 推理模型 (deepseek-reasoner)
|
||||
|
|
|
|||
|
|
@ -46,12 +46,13 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT
|
|||
Message[] messageArr = [
|
||||
new Message(postMessages,"user"),
|
||||
];
|
||||
model = model ?? ChatGPTType.GPT5_mini;
|
||||
messageArr = messageArr.Where(s => s != null).ToArray();
|
||||
var chatReq = new ChatRequest
|
||||
{
|
||||
taskId = task,
|
||||
model = model,
|
||||
max_tokens = model == "deepseek-reasoner" ? 16000 : 8000,
|
||||
max_tokens =8000,
|
||||
stream = true,
|
||||
temperature = 0.2f,
|
||||
messages = messageArr
|
||||
|
|
|
|||
|
|
@ -86,14 +86,17 @@ namespace VideoAnalysisCore.AICore.GPT
|
|||
var messageBuilder1 = new StringBuilder();
|
||||
var lastChat = new ChatResSSE();
|
||||
var splitCount = "data:".Length;
|
||||
var maxLoop = 60 * 100000;
|
||||
var maxLoop = 50 * 200;
|
||||
int threshold = 0;
|
||||
while (maxLoop > 0)
|
||||
var startTime= DateTime.Now;
|
||||
var endTime = startTime.AddHours(1.5);
|
||||
//最长分析分析时间1.5小时 或者重试读取 1w次
|
||||
while (maxLoop > 0 && DateTime.Now < endTime)
|
||||
{
|
||||
line = reader.ReadLine();
|
||||
if (line is null || string.IsNullOrEmpty(line) || line.StartsWith(": keep-alive"))
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
Thread.Sleep(50);
|
||||
maxLoop--;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ namespace VideoAnalysisCore.Model.Enum
|
|||
[Description("班会")]
|
||||
班会 = 5,
|
||||
[Description("其他资料")]
|
||||
其他资料 = 7
|
||||
其他资料 = 7,
|
||||
[Description("教研")]
|
||||
教研 = 8
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue