You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ChatHistory.cs 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace LLama.Common
  5. {
  6. public enum AuthorRole
  7. {
  8. Unknown = -1,
  9. System = 0,
  10. User = 1,
  11. Assistant = 2,
  12. }
  13. // copy from semantic-kernel
  14. /// <summary>
  15. /// The chat history class
  16. /// </summary>
  17. public class ChatHistory
  18. {
  19. /// <summary>
  20. /// Chat message representation
  21. /// </summary>
  22. public class Message
  23. {
  24. /// <summary>
  25. /// Role of the message author, e.g. user/assistant/system
  26. /// </summary>
  27. public AuthorRole AuthorRole { get; set; }
  28. /// <summary>
  29. /// Message content
  30. /// </summary>
  31. public string Content { get; set; }
  32. /// <summary>
  33. /// Create a new instance
  34. /// </summary>
  35. /// <param name="authorRole">Role of message author</param>
  36. /// <param name="content">Message content</param>
  37. public Message(AuthorRole authorRole, string content)
  38. {
  39. this.AuthorRole = authorRole;
  40. this.Content = content;
  41. }
  42. }
  43. /// <summary>
  44. /// List of messages in the chat
  45. /// </summary>
  46. public List<Message> Messages { get; }
  47. /// <summary>
  48. /// Create a new instance of the chat content class
  49. /// </summary>
  50. public ChatHistory()
  51. {
  52. this.Messages = new List<Message>();
  53. }
  54. /// <summary>
  55. /// Add a message to the chat history
  56. /// </summary>
  57. /// <param name="authorRole">Role of the message author</param>
  58. /// <param name="content">Message content</param>
  59. public void AddMessage(AuthorRole authorRole, string content)
  60. {
  61. this.Messages.Add(new Message(authorRole, content));
  62. }
  63. }
  64. }

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。