diff --git a/LLama/Abstractions/IHistoryTransform.cs b/LLama/Abstractions/IHistoryTransform.cs
index 0768369a..75a78bc5 100644
--- a/LLama/Abstractions/IHistoryTransform.cs
+++ b/LLama/Abstractions/IHistoryTransform.cs
@@ -5,15 +5,23 @@ using System.Text;
namespace LLama.Abstractions
{
+ ///
+ /// Transform history to plain text and vice versa.
+ ///
public interface IHistoryTransform
{
+ ///
+ /// Convert a ChatHistory instance to plain text.
+ ///
+ /// The ChatHistory instance
+ ///
string HistoryToText(ChatHistory history);
+
///
- ///
+ /// Converts plain text to a ChatHistory instance.
///
- /// The existing history.
- ///
- ///
+ /// The role for the author.
+ /// The chat history as plain text.
/// The updated history.
ChatHistory TextToHistory(AuthorRole role, string text);
}
diff --git a/LLama/Abstractions/ILLamaExecutor.cs b/LLama/Abstractions/ILLamaExecutor.cs
index 485e1e44..b1712ce5 100644
--- a/LLama/Abstractions/ILLamaExecutor.cs
+++ b/LLama/Abstractions/ILLamaExecutor.cs
@@ -6,9 +6,22 @@ using System.Threading;
namespace LLama.Abstractions
{
+ ///
+ /// A high level interface for LLama models.
+ ///
public interface ILLamaExecutor
{
+ ///
+ /// The loaded model for this executor.
+ ///
public LLamaModel Model { get; }
+ ///
+ /// Infers a response from the model.
+ ///
+ /// Your prompt
+ /// Any additional parameters
+ /// A cancellation token.
+ ///
IEnumerable Infer(string text, InferenceParams? inferenceParams = null, CancellationToken token = default);
IAsyncEnumerable InferAsync(string text, InferenceParams? inferenceParams = null, CancellationToken token = default);
diff --git a/LLama/Abstractions/ITextStreamTransform.cs b/LLama/Abstractions/ITextStreamTransform.cs
index 7e1bbdf8..af083564 100644
--- a/LLama/Abstractions/ITextStreamTransform.cs
+++ b/LLama/Abstractions/ITextStreamTransform.cs
@@ -4,9 +4,22 @@ using System.Text;
namespace LLama.Abstractions
{
+ ///
+ /// Takes a stream of tokens and transforms them.
+ ///
public interface ITextStreamTransform
{
+ ///
+ /// Takes a stream of tokens and transforms them, returning a new stream of tokens.
+ ///
+ ///
+ ///
IEnumerable Transform(IEnumerable tokens);
+ ///
+ /// Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously.
+ ///
+ ///
+ ///
IAsyncEnumerable TransformAsync(IAsyncEnumerable tokens);
}
}
diff --git a/LLama/Abstractions/ITextTransform.cs b/LLama/Abstractions/ITextTransform.cs
index 731a5129..c165e807 100644
--- a/LLama/Abstractions/ITextTransform.cs
+++ b/LLama/Abstractions/ITextTransform.cs
@@ -4,8 +4,22 @@ using System.Text;
namespace LLama.Abstractions
{
+ ///
+ /// An interface for text transformations.
+ /// These can be used to compose a pipeline of text transformations, such as:
+ /// - Tokenization
+ /// - Lowercasing
+ /// - Punctuation removal
+ /// - Trimming
+ /// - etc.
+ ///
public interface ITextTransform
{
+ ///
+ /// Takes a string and transforms it.
+ ///
+ ///
+ ///
string Transform(string text);
}
}
diff --git a/LLama/LLamaTransforms.cs b/LLama/LLamaTransforms.cs
index f9957b46..1a2dccd3 100644
--- a/LLama/LLamaTransforms.cs
+++ b/LLama/LLamaTransforms.cs
@@ -13,6 +13,11 @@ namespace LLama
{
public class LLamaTransforms
{
+ ///
+ /// The default history transform.
+ /// Uses plain text with the following format:
+ /// [Author]: [Message]
+ ///
public class DefaultHistoryTransform : IHistoryTransform
{
private readonly string defaultUserName = "User";
@@ -94,13 +99,15 @@ namespace LLama
{
}
-
+ ///
public string Transform(string text)
{
return text.Trim();
}
}
-
+ ///
+ /// A no-op text input transform.
+ ///
public class EmptyTextOutputStreamTransform : ITextStreamTransform
{
public IEnumerable Transform(IEnumerable tokens)
@@ -113,7 +120,9 @@ namespace LLama
return tokens;
}
}
-
+ ///
+ /// A text output transform that removes the keywords from the response.
+ ///
public class KeywordTextOutputStreamTransform : ITextStreamTransform
{
HashSet _keywords;
@@ -135,7 +144,7 @@ namespace LLama
_maxKeywordLength = keywords.Select(x => x.Length).Max() + redundancyLength;
_removeAllMatchedTokens = removeAllMatchedTokens;
}
-
+ ///
public IEnumerable Transform(IEnumerable tokens)
{
var window = new Queue();
@@ -167,7 +176,7 @@ namespace LLama
yield return window.Dequeue();
}
}
-
+ ///
public async IAsyncEnumerable TransformAsync(IAsyncEnumerable tokens)
{
var window = new Queue();