feat: ai完成接入deepseek

This commit is contained in:
ccnetcore
2025-06-25 00:05:00 +08:00
parent 04c2b246f6
commit 8eea510583
4 changed files with 145 additions and 9 deletions

View File

@@ -0,0 +1,21 @@
using System.Reflection;
using OpenAI.Chat;
namespace Yi.Framework.AiHub.Domain.Extensions;
public static class ChatMessageExtensions
{
public static string GetRoleAsString(this ChatMessage message)
{
var type = message.GetType();
var propertyInfo = type.GetProperty("Role", BindingFlags.NonPublic | BindingFlags.Instance);
if (propertyInfo != null)
{
var value = propertyInfo.GetValue(message) as ChatMessageRole?;
return value.ToString().ToLower();
}
return string.Empty;
}
}