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.

IHistoryTransform.cs 1.1 kB

123456789101112131415161718192021222324252627282930313233
  1. using LLama.Common;
  2. using System.Text.Json.Serialization;
  3. namespace LLama.Abstractions
  4. {
  5. /// <summary>
  6. /// Transform history to plain text and vice versa.
  7. /// </summary>
  8. [JsonConverter(typeof(PolymorphicJSONConverter<IHistoryTransform>))]
  9. public interface IHistoryTransform
  10. {
  11. /// <summary>
  12. /// Convert a ChatHistory instance to plain text.
  13. /// </summary>
  14. /// <param name="history">The ChatHistory instance</param>
  15. /// <returns></returns>
  16. string HistoryToText(ChatHistory history);
  17. /// <summary>
  18. /// Converts plain text to a ChatHistory instance.
  19. /// </summary>
  20. /// <param name="role">The role for the author.</param>
  21. /// <param name="text">The chat history as plain text.</param>
  22. /// <returns>The updated history.</returns>
  23. ChatHistory TextToHistory(AuthorRole role, string text);
  24. /// <summary>
  25. /// Copy the transform.
  26. /// </summary>
  27. /// <returns></returns>
  28. IHistoryTransform Clone();
  29. }
  30. }