53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using VideoAnalysisCore.Common;
|
|
using System.Net.Http.Headers;
|
|
using System.Text;
|
|
using Microsoft.Extensions.Logging;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Net.Http;
|
|
using Newtonsoft.Json;
|
|
using System.Net.Http.Json;
|
|
using System.Net;
|
|
using VideoAnalysisCore.AICore.GPT.DeepSeek;
|
|
using VideoAnalysisCore.AICore.GPT;
|
|
using System.Text.Json;
|
|
|
|
|
|
namespace VideoAnalysisCore.AICore.GPT.ChatGPT
|
|
{
|
|
|
|
public class DeepSeekGPTClient : GPTClient
|
|
{
|
|
|
|
public override GptConfig Config { get; set; } = AppCommon.Config.ChatGpt.DeepSeek;
|
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly RedisManager redisManager;
|
|
|
|
public DeepSeekGPTClient(IHttpClientFactory httpClientFactory, RedisManager redisManager)
|
|
:base(httpClientFactory, redisManager)
|
|
{
|
|
_httpClientFactory = httpClientFactory;
|
|
this.redisManager = redisManager;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 请求AI
|
|
/// </summary>
|
|
/// <typeparam name="T">返回JSON类型</typeparam>
|
|
/// <param name="task">任务id</param>
|
|
/// <param name="postMessages">提示词</param>
|
|
/// <param name="title">任务类型</param>
|
|
/// <param name="model">GPT版本</param>
|
|
/// <param name="max_tokens">最大token <para>不设置默认最大值 16000/8000</para></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public async Task<T> ChatAsync<T>(string task, string postMessages, string title, string model =null, int max_tokens = 8000)
|
|
{
|
|
model = model ?? ChatGPTType.Deepseek_Reasoner;
|
|
max_tokens = model == ChatGPTType.Deepseek_Reasoner ? 16000 : max_tokens;
|
|
return await base.ChatAsync<T>(task, postMessages, title, model, max_tokens);
|
|
}
|
|
|
|
}
|
|
} |