mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-11 08:33:48 +00:00
Localize the messages of failed indexing attempts
This commit is contained in:
7 files changed
+66
-10
No files matched your search
@@ -78,6 +78,14 @@ internal static class FileExtractionErrorCodeExtensions
|
||||
FileExtractionErrorCode.PDFIUM_UNAVAILABLE => TB("PDF system unavailable"),
|
||||
FileExtractionErrorCode.PANDOC_UNAVAILABLE => TB("Pandoc unavailable"),
|
||||
|
||||
// Nothing about these lies in the file: AI Studio asked its runtime for the content and
|
||||
// got back something it cannot work with. One name for all of them, because that is the
|
||||
// one thing the user can tell from them:
|
||||
FileExtractionErrorCode.INVALID_RESPONSE => TB("Internal error"),
|
||||
FileExtractionErrorCode.INVALID_REQUEST => TB("Internal error"),
|
||||
FileExtractionErrorCode.REQUEST_FAILED => TB("Internal error"),
|
||||
FileExtractionErrorCode.INTERNAL => TB("Internal error"),
|
||||
|
||||
// Codes which say nothing beyond the message of the single file. The caller names those
|
||||
// files itself and shows their messages instead:
|
||||
_ => string.Empty,
|
||||
|
||||
@@ -329,7 +329,7 @@ public sealed partial class DataSourceEmbeddingService(SettingsManager settingsM
|
||||
else
|
||||
{
|
||||
logger.LogError(exception, "Background embedding failed for data source '{DataSourceName}' ({DataSourceId}).", dataSource.Name, dataSource.Id);
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, exception.Message));
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, string.Format(TB("The data source '{0}' could not be processed. The log file holds the details."), dataSource.Name)));
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -425,7 +425,7 @@ public sealed partial class DataSourceEmbeddingService(SettingsManager settingsM
|
||||
dataSource.Id,
|
||||
vectorStore.Name);
|
||||
token.ThrowIfCancellationRequested();
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, "The vector database is not available."));
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, TB("The vector database is not available.")));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ public sealed partial class DataSourceEmbeddingService(SettingsManager settingsM
|
||||
dataSource.Id,
|
||||
indexStore.Name);
|
||||
token.ThrowIfCancellationRequested();
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, "The local RAG index database is not available."));
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, TB("The local RAG index database is not available.")));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -765,14 +765,21 @@ public sealed partial class DataSourceEmbeddingService(SettingsManager settingsM
|
||||
// would interrupt whatever the user is doing right now.
|
||||
//
|
||||
failedFiles++;
|
||||
lastError = exception.Message;
|
||||
failureDetails.Add(new DataSourceEmbeddingFailure(file.FullName, exception.Message, DateTimeOffset.UtcNow, EmbeddingProviderName: embeddingProvider.Name, ExtractionCode: exception is FileExtractionException extractionFailure ? extractionFailure.Code : FileExtractionErrorCode.NONE));
|
||||
var extractionCode = exception is FileExtractionException extractionFailure ? extractionFailure.Code : FileExtractionErrorCode.NONE;
|
||||
|
||||
//
|
||||
// Deliberately not the message of the exception: that one is written for the log
|
||||
// file, in English, and repeats the path which the list shows anyway.
|
||||
//
|
||||
var failureMessage = extractionCode.ToIndexingUserMessage(file.Name);
|
||||
lastError = failureMessage;
|
||||
failureDetails.Add(new DataSourceEmbeddingFailure(file.FullName, failureMessage, DateTimeOffset.UtcNow, EmbeddingProviderName: embeddingProvider.Name, ExtractionCode: extractionCode));
|
||||
manifest.Files.Remove(file.FullName);
|
||||
await this.ForgetPermanentFailureAsync(indexStore, dataSource, manifest, file.FullName, token);
|
||||
await this.CleanupFailedFileAsync(indexStore, vectorStore, dataSource, collectionName, file.FullName, optimizationTracker, token);
|
||||
|
||||
logger.LogWarning(exception, "Failed to embed file '{FilePath}' for data source '{DataSourceName}'.", file.FullName, dataSource.Name);
|
||||
this.UpsertStatus(this.CreateStatus(dataSource, DataSourceEmbeddingState.RUNNING, totalFiles, skippedFiles + completedFiles, failedFiles, file.Name, exception.Message, failureDetails, permanentlySkippedFiles));
|
||||
this.UpsertStatus(this.CreateStatus(dataSource, DataSourceEmbeddingState.RUNNING, totalFiles, skippedFiles + completedFiles, failedFiles, file.Name, failureMessage, failureDetails, permanentlySkippedFiles));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1175,7 +1182,7 @@ public sealed partial class DataSourceEmbeddingService(SettingsManager settingsM
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Initial embedding hash check failed for data source '{DataSourceName}' ({DataSourceId}).", dataSource.Name, dataSource.Id);
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, exception.Message));
|
||||
this.UpsertStatus(this.GetFallbackStatus(dataSource, string.Format(TB("The data source '{0}' could not be processed. The log file holds the details."), dataSource.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,12 @@ public sealed partial class RustService
|
||||
{
|
||||
await foreach (var segment in this.StreamArbitraryFileDataCore(path, false, true, embeddingProvider.TokenizerPath, token))
|
||||
{
|
||||
//
|
||||
// Carries a code so callers can classify it: the file itself is fine, the answer of
|
||||
// the runtime was not, which makes this worth another attempt.
|
||||
//
|
||||
if (segment.TokenCount is null)
|
||||
throw new InvalidOperationException($"Rust did not return a token count for an extracted segment from '{path}' using provider '{embeddingProvider.Name}'.");
|
||||
throw new FileExtractionException(FileExtractionErrorCode.INVALID_RESPONSE, $"Rust did not return a token count for an extracted segment from '{path}' using provider '{embeddingProvider.Name}'.");
|
||||
|
||||
yield return new(segment.Content, segment.TokenCount.Value);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user