diff --git a/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs b/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs index 13e32500..fe9cc694 100644 --- a/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs +++ b/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs @@ -79,12 +79,19 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess var dataContexts = new List(); if (proceedWithRAG) { + // + // At this point in time, the chat thread contains already the + // last block, which is the waiting AI block. We need to remove + // this block before we call the RAG process: + // + var chatThreadWithoutWaitingAIBlock = chatThread with { Blocks = chatThread.Blocks[..^1] }; + // // We kick off the retrieval process for each data source in parallel: // var retrievalTasks = new List>>(selectedDataSources.Count); foreach (var dataSource in selectedDataSources) - retrievalTasks.Add(dataSource.RetrieveDataAsync(lastPrompt, chatThread, token)); + retrievalTasks.Add(dataSource.RetrieveDataAsync(lastPrompt, chatThreadWithoutWaitingAIBlock, token)); // // Wait for all retrieval tasks to finish: diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.32.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.32.md index 5cdac4d8..3e78d53a 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.32.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.32.md @@ -3,4 +3,5 @@ - Improved the ERI client to expect JSON responses and send JSON requests using camel case. - Improved the ERI client to raise an error when the server responds with additional JSON data that is not expected. - Improved the error handling in the ERI data source info dialog in cases where servers respond with an invalid message. -- Improved the error handling for the entire RAG process. \ No newline at end of file +- Improved the error handling for the entire RAG process. +- Fixed the chat thread we use for the data retrieval by removing the last block, which is meant to be for the final AI answer. \ No newline at end of file