From ad9bf1cbba2b86a89c58e6f0c2cc41abdff2c912 Mon Sep 17 00:00:00 2001
From: Norne9 <4660466+Norne9@users.noreply.github.com>
Date: Tue, 30 Apr 2024 02:32:14 +0300
Subject: [PATCH] InitializeSessionFromHistoryAsync changed
ChatSession.InitializeSessionFromHistoryAsync now accepts IHistoryTransform as an optional parameter.
---
LLama/ChatSession.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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
+}