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.

llama.common.chathistory.md 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # ChatHistory
  2. Namespace: LLama.Common
  3. The chat history class
  4. ```csharp
  5. public class ChatHistory
  6. ```
  7. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ChatHistory](./llama.common.chathistory.md)
  8. ## Properties
  9. ### **Messages**
  10. List of messages in the chat
  11. ```csharp
  12. public List<Message> Messages { get; set; }
  13. ```
  14. #### Property Value
  15. [List&lt;Message&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
  16. ## Constructors
  17. ### **ChatHistory()**
  18. Create a new instance of the chat content class
  19. ```csharp
  20. public ChatHistory()
  21. ```
  22. ### **ChatHistory(Message[])**
  23. Create a new instance of the chat history from array of messages
  24. ```csharp
  25. public ChatHistory(Message[] messageHistory)
  26. ```
  27. #### Parameters
  28. `messageHistory` [Message[]](./llama.common.chathistory.message.md)<br>
  29. ## Methods
  30. ### **AddMessage(AuthorRole, String)**
  31. Add a message to the chat history
  32. ```csharp
  33. public void AddMessage(AuthorRole authorRole, string content)
  34. ```
  35. #### Parameters
  36. `authorRole` [AuthorRole](./llama.common.authorrole.md)<br>
  37. Role of the message author
  38. `content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  39. Message content
  40. ### **ToJson()**
  41. Serialize the chat history to JSON
  42. ```csharp
  43. public string ToJson()
  44. ```
  45. #### Returns
  46. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  47. ### **FromJson(String)**
  48. Deserialize a chat history from JSON
  49. ```csharp
  50. public static ChatHistory FromJson(string json)
  51. ```
  52. #### Parameters
  53. `json` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  54. #### Returns
  55. [ChatHistory](./llama.common.chathistory.md)<br>