mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 22:47:21 +00:00
Added a way to read what the AI received from your sources (#1100)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
e0d8e18f34
commit
cbc4ce5413
229 files changed
+12739
-1269
No files matched your search
@@ -305,6 +305,10 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// Read each attached document once, before the request sends it, see ChatThread.StoreAttachedDocumentsAsync:
|
||||
await chatThread.StoreAttachedDocumentsAsync(settingsManager.ConfigurationData.Chat.ReadChangedAttachmentsAgain);
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var lastStreamingEvent = DateTimeOffset.MinValue;
|
||||
if (!TrySetWaitingForRemote(state, token))
|
||||
return;
|
||||
@@ -371,6 +375,13 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
|
||||
RemoveEmptyAIResponse(state);
|
||||
|
||||
//
|
||||
// Before the last checkpoint, so that the stored chat refers to what the AI received instead
|
||||
// of holding it. An answer which was removed for being empty keeps nothing:
|
||||
//
|
||||
if (request.ChatThread.Blocks.Any(block => ReferenceEquals(block.Content, aiText)))
|
||||
await aiText.StoreReceivedContentAsync(request.ChatThread.ChatId);
|
||||
|
||||
lock (state.SyncRoot)
|
||||
{
|
||||
state.Snapshot = state.Snapshot with
|
||||
@@ -461,12 +472,7 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
if (state.IsCompletionStarted || token.IsCancellationRequested || state.ChatGenerationRequest is null)
|
||||
return false;
|
||||
|
||||
var aiText = state.ChatGenerationRequest.AIText;
|
||||
aiText.InitialRemoteWait = false;
|
||||
aiText.IsStreaming = true;
|
||||
aiText.Text += contentStreamChunk;
|
||||
aiText.Sources.MergeSources(contentStreamChunk.Sources);
|
||||
aiText.RecordReportedUsage(contentStreamChunk.Usage, state.ChatGenerationRequest.ProviderSettings.Model.Id, blocksSent);
|
||||
state.ChatGenerationRequest.AIText.ApplyStreamChunk(contentStreamChunk, state.ChatGenerationRequest.ProviderSettings.Model.Id, blocksSent);
|
||||
|
||||
if (state.Snapshot.Status is not AIJobStatus.RUNNING)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user