InitializeSessionFromHistoryAsync changed

ChatSession.InitializeSessionFromHistoryAsync now accepts IHistoryTransform as an optional parameter.
This commit is contained in:
Norne9 2024-04-30 02:32:14 +03:00 committed by GitHub
parent f44c8846f5
commit ad9bf1cbba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 3 deletions

View File

@ -74,15 +74,21 @@ public class ChatSession
/// </summary>
/// <param name="executor">The executor for this session</param>
/// <param name="history">History for this session</param>
/// <returns></returns>
/// <param name="transform">History Transform for this session</param>
/// <returns>A new chat session.</returns>
public static async Task<ChatSession> 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);
}
}
}