mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 17:18:00 +00:00
Used the live data source name when building retrieval contexts
This commit is contained in:
1 file changed
+6
-9
@@ -42,7 +42,6 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
string ChunkId,
|
string ChunkId,
|
||||||
string ParentFileId,
|
string ParentFileId,
|
||||||
string DataSourceId,
|
string DataSourceId,
|
||||||
string DataSourceName,
|
|
||||||
string DataSourceType,
|
string DataSourceType,
|
||||||
string AbsolutePath,
|
string AbsolutePath,
|
||||||
string FileName,
|
string FileName,
|
||||||
@@ -93,7 +92,7 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
|
|
||||||
return hits
|
return hits
|
||||||
.Where(hit => !string.IsNullOrWhiteSpace(hit.Text))
|
.Where(hit => !string.IsNullOrWhiteSpace(hit.Text))
|
||||||
.Select(ToRetrievalContext)
|
.Select(hit => ToRetrievalContext(hit, dataSource))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +341,6 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
result.ChunkId,
|
result.ChunkId,
|
||||||
result.ParentFileId,
|
result.ParentFileId,
|
||||||
result.DataSourceId,
|
result.DataSourceId,
|
||||||
result.DataSourceName,
|
|
||||||
result.DataSourceType,
|
result.DataSourceType,
|
||||||
FirstNonEmpty(result.AbsolutePath, result.FilePath),
|
FirstNonEmpty(result.AbsolutePath, result.FilePath),
|
||||||
result.FileName,
|
result.FileName,
|
||||||
@@ -360,7 +358,6 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
result.ChunkId,
|
result.ChunkId,
|
||||||
result.ParentFileId,
|
result.ParentFileId,
|
||||||
result.DataSourceId,
|
result.DataSourceId,
|
||||||
result.DataSourceName,
|
|
||||||
result.DataSourceType,
|
result.DataSourceType,
|
||||||
result.AbsolutePath,
|
result.AbsolutePath,
|
||||||
result.FileName,
|
result.FileName,
|
||||||
@@ -372,9 +369,9 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
result.Score,
|
result.Score,
|
||||||
rank);
|
rank);
|
||||||
|
|
||||||
private static RetrievalTextContext ToRetrievalContext(LocalRetrievalHit hit)
|
private static RetrievalTextContext ToRetrievalContext(LocalRetrievalHit hit, IInternalDataSource dataSource)
|
||||||
{
|
{
|
||||||
var sourceName = FirstNonEmpty(hit.FileName, hit.DataSourceName);
|
var sourceName = FirstNonEmpty(hit.FileName, dataSource.Name);
|
||||||
var path = FirstNonEmpty(hit.AbsolutePath, hit.RelativePath);
|
var path = FirstNonEmpty(hit.AbsolutePath, hit.RelativePath);
|
||||||
var referenceLink = string.IsNullOrWhiteSpace(path) ? string.Empty : BuildReferenceLink(path, hit);
|
var referenceLink = string.IsNullOrWhiteSpace(path) ? string.Empty : BuildReferenceLink(path, hit);
|
||||||
|
|
||||||
@@ -387,15 +384,15 @@ public sealed class DataSourceLocalRetrievalService(
|
|||||||
Links = [],
|
Links = [],
|
||||||
MatchedText = hit.Text,
|
MatchedText = hit.Text,
|
||||||
SurroundingContent = [],
|
SurroundingContent = [],
|
||||||
ReferenceTitle = BuildReferenceTitle(hit),
|
ReferenceTitle = BuildReferenceTitle(hit, dataSource),
|
||||||
ReferenceLink = referenceLink,
|
ReferenceLink = referenceLink,
|
||||||
PageNumber = hit.PageNumber is > 0 ? hit.PageNumber : null,
|
PageNumber = hit.PageNumber is > 0 ? hit.PageNumber : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string BuildReferenceTitle(LocalRetrievalHit hit)
|
private static string BuildReferenceTitle(LocalRetrievalHit hit, IInternalDataSource dataSource)
|
||||||
{
|
{
|
||||||
var sourceName = FirstNonEmpty(hit.FileName, hit.DataSourceName);
|
var sourceName = FirstNonEmpty(hit.FileName, dataSource.Name);
|
||||||
return BuildLocatedReferenceTitle(sourceName, hit.ChunkIndex, hit.PageNumber);
|
return BuildLocatedReferenceTitle(sourceName, hit.ChunkIndex, hit.PageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user