-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathChatHistory.cs
66 lines (57 loc) · 1.65 KB
/
ChatHistory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
namespace Microsoft.SemanticKernel.AI.ChatCompletion;
public class ChatHistory
{
public enum AuthorRoles
{
Unknown = -1,
System = 0,
User = 1,
Assistant = 2,
}
/// <summary>
/// Chat message representation
/// </summary>
public class Message
{
/// <summary>
/// Role of the message author, e.g. user/assistant/system
/// </summary>
public AuthorRoles AuthorRole { get; set; }
/// <summary>
/// Message content
/// </summary>
public string Content { get; set; }
/// <summary>
/// Create a new instance
/// </summary>
/// <param name="authorRole">Role of message author</param>
/// <param name="content">Message content</param>
public Message(AuthorRoles authorRole, string content)
{
this.AuthorRole = authorRole;
this.Content = content;
}
}
/// <summary>
/// List of messages in the chat
/// </summary>
public List<Message> Messages { get; }
/// <summary>
/// Create a new instance of the chat content class
/// </summary>
public ChatHistory()
{
this.Messages = new List<Message>();
}
/// <summary>
/// Add a message to the chat history
/// </summary>
/// <param name="authorRole">Role of the message author</param>
/// <param name="content">Message content</param>
public void AddMessage(AuthorRoles authorRole, string content)
{
this.Messages.Add(new Message(authorRole, content));
}
}