Rename lastPrompt to lastUserPrompt across codebase

This commit is contained in:
Thorsten Sommer 2025-09-25 19:10:18 +02:00
parent 8746d31230
commit 606aa6fe64
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
15 changed files with 34 additions and 34 deletions

View File

@ -131,7 +131,7 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
#endregion #endregion
public async Task<List<SelectedDataSource>> PerformSelectionAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default) public async Task<List<SelectedDataSource>> PerformSelectionAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default)
{ {
logger.LogInformation("The AI should select the appropriate data sources."); logger.LogInformation("The AI should select the appropriate data sources.");
@ -154,7 +154,7 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
// //
// 2. Prepare the current system and user prompts as input for the agent: // 2. Prepare the current system and user prompts as input for the agent:
// //
var lastPromptContent = lastPrompt switch var lastPromptContent = lastUserPrompt switch
{ {
ContentText text => text.Text, ContentText text => text.Text,

View File

@ -147,12 +147,12 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
/// <summary> /// <summary>
/// Validate all retrieval contexts against the last user and the system prompt. /// Validate all retrieval contexts against the last user and the system prompt.
/// </summary> /// </summary>
/// <param name="lastPrompt">The last user prompt.</param> /// <param name="lastUserPrompt">The last user prompt.</param>
/// <param name="chatThread">The chat thread.</param> /// <param name="chatThread">The chat thread.</param>
/// <param name="retrievalContexts">All retrieval contexts to validate.</param> /// <param name="retrievalContexts">All retrieval contexts to validate.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <returns>The validation results.</returns> /// <returns>The validation results.</returns>
public async Task<IReadOnlyList<RetrievalContextValidationResult>> ValidateRetrievalContextsAsync(IContent lastPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default) public async Task<IReadOnlyList<RetrievalContextValidationResult>> ValidateRetrievalContextsAsync(IContent lastUserPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default)
{ {
// Check if the retrieval context validation is enabled: // Check if the retrieval context validation is enabled:
if (!this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation) if (!this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation)
@ -178,7 +178,7 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
await semaphore.WaitAsync(token); await semaphore.WaitAsync(token);
// Start the next validation task: // Start the next validation task:
validationTasks.Add(this.ValidateRetrievalContextAsync(lastPrompt, chatThread, retrievalContext, token, semaphore)); validationTasks.Add(this.ValidateRetrievalContextAsync(lastUserPrompt, chatThread, retrievalContext, token, semaphore));
} }
// Wait for all validation tasks to complete: // Wait for all validation tasks to complete:
@ -193,13 +193,13 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
/// can call this method in parallel for each retrieval context. You might use /// can call this method in parallel for each retrieval context. You might use
/// the ValidateRetrievalContextsAsync method to validate all retrieval contexts. /// the ValidateRetrievalContextsAsync method to validate all retrieval contexts.
/// </remarks> /// </remarks>
/// <param name="lastPrompt">The last user prompt.</param> /// <param name="lastUserPrompt">The last user prompt.</param>
/// <param name="chatThread">The chat thread.</param> /// <param name="chatThread">The chat thread.</param>
/// <param name="retrievalContext">The retrieval context to validate.</param> /// <param name="retrievalContext">The retrieval context to validate.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <param name="semaphore">The optional semaphore to limit the number of parallel validations.</param> /// <param name="semaphore">The optional semaphore to limit the number of parallel validations.</param>
/// <returns>The validation result.</returns> /// <returns>The validation result.</returns>
public async Task<RetrievalContextValidationResult> ValidateRetrievalContextAsync(IContent lastPrompt, ChatThread chatThread, IRetrievalContext retrievalContext, CancellationToken token = default, SemaphoreSlim? semaphore = null) public async Task<RetrievalContextValidationResult> ValidateRetrievalContextAsync(IContent lastUserPrompt, ChatThread chatThread, IRetrievalContext retrievalContext, CancellationToken token = default, SemaphoreSlim? semaphore = null)
{ {
try try
{ {
@ -214,7 +214,7 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
// //
// 1. Prepare the current system and user prompts as input for the agent: // 1. Prepare the current system and user prompts as input for the agent:
// //
var lastPromptContent = lastPrompt switch var lastPromptContent = lastUserPrompt switch
{ {
ContentText text => text.Text, ContentText text => text.Text,

View File

@ -31,7 +31,7 @@ public sealed class ContentImage : IContent, IImageSource
public List<ISource> Sources { get; set; } = []; public List<ISource> Sources { get; set; } = [];
/// <inheritdoc /> /// <inheritdoc />
public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatChatThread, CancellationToken token = default) public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastUserPrompt, ChatThread? chatChatThread, CancellationToken token = default)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -41,7 +41,7 @@ public sealed class ContentText : IContent
public List<ISource> Sources { get; set; } = []; public List<ISource> Sources { get; set; } = [];
/// <inheritdoc /> /// <inheritdoc />
public async Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatThread, CancellationToken token = default) public async Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastUserPrompt, ChatThread? chatThread, CancellationToken token = default)
{ {
if(chatThread is null) if(chatThread is null)
return new(); return new();
@ -53,12 +53,12 @@ public sealed class ContentText : IContent
} }
// Call the RAG process. Right now, we only have one RAG process: // Call the RAG process. Right now, we only have one RAG process:
if (lastPrompt is not null) if (lastUserPrompt is not null)
{ {
try try
{ {
var rag = new AISrcSelWithRetCtxVal(); var rag = new AISrcSelWithRetCtxVal();
chatThread = await rag.ProcessAsync(provider, lastPrompt, chatThread, token); chatThread = await rag.ProcessAsync(provider, lastUserPrompt, chatThread, token);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -47,7 +47,7 @@ public interface IContent
/// <summary> /// <summary>
/// Uses the provider to create the content. /// Uses the provider to create the content.
/// </summary> /// </summary>
public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatChatThread, CancellationToken token = default); public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastUserPrompt, ChatThread? chatChatThread, CancellationToken token = default);
/// <summary> /// <summary>
/// Creates a deep copy /// Creates a deep copy

View File

@ -58,7 +58,7 @@ public readonly record struct DataSourceERI_V1 : IERIDataSource
public ushort MaxMatches { get; init; } = 10; public ushort MaxMatches { get; init; } = 10;
/// <inheritdoc /> /// <inheritdoc />
public async Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastPrompt, ChatThread thread, CancellationToken token = default) public async Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastUserPrompt, ChatThread thread, CancellationToken token = default)
{ {
// Important: Do not dispose the RustService here, as it is a singleton. // Important: Do not dispose the RustService here, as it is a singleton.
var rustService = Program.SERVICE_PROVIDER.GetRequiredService<RustService>(); var rustService = Program.SERVICE_PROVIDER.GetRequiredService<RustService>();
@ -70,8 +70,8 @@ public readonly record struct DataSourceERI_V1 : IERIDataSource
{ {
var retrievalRequest = new RetrievalRequest var retrievalRequest = new RetrievalRequest
{ {
LatestUserPromptType = lastPrompt.ToERIContentType, LatestUserPromptType = lastUserPrompt.ToERIContentType,
LatestUserPrompt = lastPrompt switch LatestUserPrompt = lastUserPrompt switch
{ {
ContentText text => text.Text, ContentText text => text.Text,
ContentImage image => await image.AsBase64(token), ContentImage image => await image.AsBase64(token),

View File

@ -34,7 +34,7 @@ public readonly record struct DataSourceLocalDirectory : IInternalDataSource
public ushort MaxMatches { get; init; } = 10; public ushort MaxMatches { get; init; } = 10;
/// <inheritdoc /> /// <inheritdoc />
public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastPrompt, ChatThread thread, CancellationToken token = default) public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastUserPrompt, ChatThread thread, CancellationToken token = default)
{ {
IReadOnlyList<IRetrievalContext> retrievalContext = new List<IRetrievalContext>(); IReadOnlyList<IRetrievalContext> retrievalContext = new List<IRetrievalContext>();
return Task.FromResult(retrievalContext); return Task.FromResult(retrievalContext);

View File

@ -34,7 +34,7 @@ public readonly record struct DataSourceLocalFile : IInternalDataSource
public ushort MaxMatches { get; init; } = 10; public ushort MaxMatches { get; init; } = 10;
/// <inheritdoc /> /// <inheritdoc />
public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastPrompt, ChatThread thread, CancellationToken token = default) public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastUserPrompt, ChatThread thread, CancellationToken token = default)
{ {
IReadOnlyList<IRetrievalContext> retrievalContext = new List<IRetrievalContext>(); IReadOnlyList<IRetrievalContext> retrievalContext = new List<IRetrievalContext>();
return Task.FromResult(retrievalContext); return Task.FromResult(retrievalContext);

View File

@ -48,9 +48,9 @@ public interface IDataSource
/// <summary> /// <summary>
/// Perform the data retrieval process. /// Perform the data retrieval process.
/// </summary> /// </summary>
/// <param name="lastPrompt">The last prompt from the chat.</param> /// <param name="lastUserPrompt">The last user prompt from the chat.</param>
/// <param name="thread">The chat thread.</param> /// <param name="thread">The chat thread.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <returns>The retrieved data context.</returns> /// <returns>The retrieved data context.</returns>
public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastPrompt, ChatThread thread, CancellationToken token = default); public Task<IReadOnlyList<IRetrievalContext>> RetrieveDataAsync(IContent lastUserPrompt, ChatThread thread, CancellationToken token = default);
} }

View File

@ -26,7 +26,7 @@ public sealed class AugmentationOne : IAugmentationProcess
public string Description => TB("This is the standard augmentation process, which uses all retrieval contexts to augment the chat thread."); public string Description => TB("This is the standard augmentation process, which uses all retrieval contexts to augment the chat thread.");
/// <inheritdoc /> /// <inheritdoc />
public async Task<ChatThread> ProcessAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default) public async Task<ChatThread> ProcessAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default)
{ {
var settings = Program.SERVICE_PROVIDER.GetService<SettingsManager>()!; var settings = Program.SERVICE_PROVIDER.GetService<SettingsManager>()!;
@ -46,7 +46,7 @@ public sealed class AugmentationOne : IAugmentationProcess
validationAgent.SetLLMProvider(provider); validationAgent.SetLLMProvider(provider);
// Let's validate all retrieval contexts: // Let's validate all retrieval contexts:
var validationResults = await validationAgent.ValidateRetrievalContextsAsync(lastPrompt, chatThread, retrievalContexts, token); var validationResults = await validationAgent.ValidateRetrievalContextsAsync(lastUserPrompt, chatThread, retrievalContexts, token);
// //
// Now, filter the retrieval contexts to the most relevant ones: // Now, filter the retrieval contexts to the most relevant ones:

View File

@ -25,7 +25,7 @@ public class AgenticSrcSelWithDynHeur : IDataSourceSelectionProcess
public string Description => TB("Automatically selects the appropriate data sources based on the last prompt. Applies a heuristic reduction at the end to reduce the number of data sources."); public string Description => TB("Automatically selects the appropriate data sources based on the last prompt. Applies a heuristic reduction at the end to reduce the number of data sources.");
/// <inheritdoc /> /// <inheritdoc />
public async Task<DataSelectionResult> SelectDataSourcesAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default) public async Task<DataSelectionResult> SelectDataSourcesAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default)
{ {
var proceedWithRAG = true; var proceedWithRAG = true;
IReadOnlyList<IDataSource> selectedDataSources = []; IReadOnlyList<IDataSource> selectedDataSources = [];
@ -40,7 +40,7 @@ public class AgenticSrcSelWithDynHeur : IDataSourceSelectionProcess
try try
{ {
// Let the AI agent do its work: // Let the AI agent do its work:
var aiSelectedDataSources = await selectionAgent.PerformSelectionAsync(provider, lastPrompt, chatThread, dataSources, token); var aiSelectedDataSources = await selectionAgent.PerformSelectionAsync(provider, lastUserPrompt, chatThread, dataSources, token);
// Check if the AI selected any data sources: // Check if the AI selected any data sources:
if (aiSelectedDataSources.Count is 0) if (aiSelectedDataSources.Count is 0)

View File

@ -24,10 +24,10 @@ public interface IAugmentationProcess
/// Starts the augmentation process. /// Starts the augmentation process.
/// </summary> /// </summary>
/// <param name="provider">The LLM provider. Gets used, e.g., for automatic retrieval context validation.</param> /// <param name="provider">The LLM provider. Gets used, e.g., for automatic retrieval context validation.</param>
/// <param name="lastPrompt">The last prompt that was issued by the user.</param> /// <param name="lastUserPrompt">The last user prompt that was issued by the user.</param>
/// <param name="chatThread">The chat thread.</param> /// <param name="chatThread">The chat thread.</param>
/// <param name="retrievalContexts">The retrieval contexts that were issued by the retrieval process.</param> /// <param name="retrievalContexts">The retrieval contexts that were issued by the retrieval process.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <returns>The altered chat thread.</returns> /// <returns>The altered chat thread.</returns>
public Task<ChatThread> ProcessAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default); public Task<ChatThread> ProcessAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, IReadOnlyList<IRetrievalContext> retrievalContexts, CancellationToken token = default);
} }

View File

@ -24,10 +24,10 @@ public interface IDataSourceSelectionProcess
/// Starts the data source selection process. /// Starts the data source selection process.
/// </summary> /// </summary>
/// <param name="provider">The LLM provider. Used as default for data selection agents.</param> /// <param name="provider">The LLM provider. Used as default for data selection agents.</param>
/// <param name="lastPrompt">The last prompt that was issued by the user.</param> /// <param name="lastUserPrompt">The last prompt that was issued by the user.</param>
/// <param name="chatThread">The chat thread.</param> /// <param name="chatThread">The chat thread.</param>
/// <param name="dataSources">The allowed data sources yielded by the data source service.</param> /// <param name="dataSources">The allowed data sources yielded by the data source service.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <returns></returns> /// <returns></returns>
public Task<DataSelectionResult> SelectDataSourcesAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default); public Task<DataSelectionResult> SelectDataSourcesAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, AllowedSelectedDataSources dataSources, CancellationToken token = default);
} }

View File

@ -24,9 +24,9 @@ public interface IRagProcess
/// Starts the RAG process. /// Starts the RAG process.
/// </summary> /// </summary>
/// <param name="provider">The LLM provider. Used to check whether the data sources are allowed to be used by this LLM.</param> /// <param name="provider">The LLM provider. Used to check whether the data sources are allowed to be used by this LLM.</param>
/// <param name="lastPrompt">The last prompt that was issued by the user.</param> /// <param name="lastUserPrompt">The last user prompt that was issued by the user.</param>
/// <param name="chatThread">The chat thread.</param> /// <param name="chatThread">The chat thread.</param>
/// <param name="token">The cancellation token.</param> /// <param name="token">The cancellation token.</param>
/// <returns>The altered chat thread.</returns> /// <returns>The altered chat thread.</returns>
public Task<ChatThread> ProcessAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, CancellationToken token = default); public Task<ChatThread> ProcessAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, CancellationToken token = default);
} }

View File

@ -27,7 +27,7 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
public string Description => TB("This RAG process filters data sources, automatically selects appropriate sources, optionally allows manual source selection, retrieves data, and automatically validates the retrieval context."); public string Description => TB("This RAG process filters data sources, automatically selects appropriate sources, optionally allows manual source selection, retrieves data, and automatically validates the retrieval context.");
/// <inheritdoc /> /// <inheritdoc />
public async Task<ChatThread> ProcessAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, CancellationToken token = default) public async Task<ChatThread> ProcessAsync(IProvider provider, IContent lastUserPrompt, ChatThread chatThread, CancellationToken token = default)
{ {
var settings = Program.SERVICE_PROVIDER.GetService<SettingsManager>()!; var settings = Program.SERVICE_PROVIDER.GetService<SettingsManager>()!;
var dataSourceService = Program.SERVICE_PROVIDER.GetService<DataSourceService>()!; var dataSourceService = Program.SERVICE_PROVIDER.GetService<DataSourceService>()!;
@ -83,7 +83,7 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
if (chatThread.DataSourceOptions.AutomaticDataSourceSelection) if (chatThread.DataSourceOptions.AutomaticDataSourceSelection)
{ {
var dataSourceSelectionProcess = new AgenticSrcSelWithDynHeur(); var dataSourceSelectionProcess = new AgenticSrcSelWithDynHeur();
var result = await dataSourceSelectionProcess.SelectDataSourcesAsync(provider, lastPrompt, chatThread, dataSources, token); var result = await dataSourceSelectionProcess.SelectDataSourcesAsync(provider, lastUserPrompt, chatThread, dataSources, token);
proceedWithRAG = result.ProceedWithRAG; proceedWithRAG = result.ProceedWithRAG;
selectedDataSources = result.SelectedDataSources; selectedDataSources = result.SelectedDataSources;
} }
@ -163,7 +163,7 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
// //
var retrievalTasks = new List<Task<IReadOnlyList<IRetrievalContext>>>(selectedDataSources.Count); var retrievalTasks = new List<Task<IReadOnlyList<IRetrievalContext>>>(selectedDataSources.Count);
foreach (var dataSource in selectedDataSources) foreach (var dataSource in selectedDataSources)
retrievalTasks.Add(dataSource.RetrieveDataAsync(lastPrompt, chatThreadWithoutWaitingAIBlock, token)); retrievalTasks.Add(dataSource.RetrieveDataAsync(lastUserPrompt, chatThreadWithoutWaitingAIBlock, token));
// //
// Wait for all retrieval tasks to finish: // Wait for all retrieval tasks to finish:
@ -187,7 +187,7 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
if (proceedWithRAG) if (proceedWithRAG)
{ {
var augmentationProcess = new AugmentationOne(); var augmentationProcess = new AugmentationOne();
chatThread = await augmentationProcess.ProcessAsync(provider, lastPrompt, chatThread, dataContexts, token); chatThread = await augmentationProcess.ProcessAsync(provider, lastUserPrompt, chatThread, dataContexts, token);
} }
} }