diff --git a/LLama/ChatSession.cs b/LLama/ChatSession.cs
index 9018b20e..3d5b5b61 100644
--- a/LLama/ChatSession.cs
+++ b/LLama/ChatSession.cs
@@ -74,15 +74,21 @@ public class ChatSession
///
/// The executor for this session
/// History for this session
- ///
+ /// History Transform for this session
+ /// A new chat session.
public static async Task InitializeSessionFromHistoryAsync(
- ILLamaExecutor executor, ChatHistory history)
+ ILLamaExecutor executor, ChatHistory history, IHistoryTransform? transform = null)
{
if (executor is not StatefulExecutorBase statefulExecutor)
{
throw new ArgumentException("Executor must have a StatefulExecutorBase", nameof(executor));
}
var session = new ChatSession(executor, history);
+ if (transform != null)
+ {
+ session = session.WithHistoryTransform(transform);
+ }
+
await statefulExecutor.PrefillPromptAsync(session.HistoryTransform.HistoryToText(history));
return session;
}
@@ -780,4 +786,4 @@ public record SessionState
outputTransform,
historyTransform);
}
-}
\ No newline at end of file
+}