Browse Source

Update ToLLamaSharpChatHistory extension method to be public and support semantic-kernel author roles

tags/v0.8.0
Chirag Karia 2 years ago
parent
commit
1b4659dff9
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      LLama.SemanticKernel/ExtensionMethods.cs

+ 3
- 3
LLama.SemanticKernel/ExtensionMethods.cs View File

@@ -3,9 +3,9 @@ using Microsoft.SemanticKernel.AI.ChatCompletion;


namespace LLamaSharp.SemanticKernel; namespace LLamaSharp.SemanticKernel;


internal static class ExtensionMethods
public static class ExtensionMethods
{ {
internal static global::LLama.Common.ChatHistory ToLLamaSharpChatHistory(this ChatHistory chatHistory)
public static global::LLama.Common.ChatHistory ToLLamaSharpChatHistory(this ChatHistory chatHistory)
{ {
if (chatHistory is null) if (chatHistory is null)
{ {
@@ -16,7 +16,7 @@ internal static class ExtensionMethods


foreach (var chat in chatHistory) foreach (var chat in chatHistory)
{ {
var role = Enum.TryParse<global::LLama.Common.AuthorRole>(chat.Role.Label, out var _role) ? _role : global::LLama.Common.AuthorRole.Unknown;
var role = Enum.TryParse<global::LLama.Common.AuthorRole>(chat.Role.Label, true, out var _role) ? _role : global::LLama.Common.AuthorRole.Unknown;
history.AddMessage(role, chat.Content); history.AddMessage(role, chat.Content);
} }




Loading…
Cancel
Save