feat: ai完成接入deepseek
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user