diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 3d1e9ff..7262a1b 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -8,24 +8,24 @@
12
Custouch
LICENSE
-
+
https://github.com/custouch/semantic-kernel-ERNIE-Bot
https://github.com/custouch/semantic-kernel-ERNIE-Bot
git
- 0.13.0
+ 0.13.1
..\..\nupkgs
readme.md
SKEXP0001;SKEXP0002;SKEXP0052;SKEXP0003
-
+
-
+
True
\
-
+
True
@@ -36,5 +36,5 @@
true
-
+
diff --git a/src/ERNIE-Bot.SemanticKernel/ERNIEBotChatCompletion.cs b/src/ERNIE-Bot.SemanticKernel/ERNIEBotChatCompletion.cs
index 6c707d7..9d2ad12 100644
--- a/src/ERNIE-Bot.SemanticKernel/ERNIEBotChatCompletion.cs
+++ b/src/ERNIE-Bot.SemanticKernel/ERNIEBotChatCompletion.cs
@@ -12,11 +12,9 @@ public class ERNIEBotChatCompletion : IChatCompletionService, ITextGenerationSer
{
protected readonly ERNIEBotClient _client;
private readonly ModelEndpoint _modelEndpoint;
- private readonly Dictionary _attributes = new();
+ private readonly Dictionary _attributes = new();
- public IReadOnlyDictionary Attributes => this._attributes;
-
- IReadOnlyDictionary IAIService.Attributes => throw new NotImplementedException();
+ public IReadOnlyDictionary Attributes => this._attributes;
public ERNIEBotChatCompletion(ERNIEBotClient client, ModelEndpoint? modelEndpoint = null)
{
@@ -116,26 +114,30 @@ public ChatHistory CreateNewChat(string? instructions = null)
}
private List StringToMessages(string text)
{
- return new List()
- {
+ return
+ [
new Message()
{
- Role = MessageRole.User,
- Content = text
+ Role = MessageRole.User,
+ Content = text
}
- };
+ ];
}
private List ChatHistoryToMessages(ChatHistory chatHistory, out string? system)
{
- if (chatHistory.First().Role == AuthorRole.System)
+ system = null;
+
+ if (chatHistory.Count == 1)
{
- system = chatHistory.First().Content;
+ return StringToMessages(chatHistory.First().Content!);
}
- else
+
+ if (chatHistory.First().Role == AuthorRole.System)
{
- system = null;
+ system = chatHistory.First().Content;
}
+
return chatHistory
.Where(_ => _.Role != AuthorRole.System)
.Select(m => new Message()