Merge pull request #645 from iceljc/features/add-knowledge-docs

add web url in file meta
This commit is contained in:
iceljc 2024-09-17 15:23:40 -05:00 committed by GitHub
commit 6c9ba170f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 6 deletions

View file

@ -23,6 +23,9 @@ public class KnowledgeDocMetaData
[JsonPropertyName("vector_data_ids")]
public IEnumerable<string> VectorDataIds { get; set; } = new List<string>();
[JsonPropertyName("web_url")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? WebUrl { get; set; }
[JsonPropertyName("create_date")]
public DateTime CreateDate { get; set; } = DateTime.UtcNow;

View file

@ -150,13 +150,19 @@ public partial class KnowledgeService
Size = filter.Size
});
var files = pagedData.Items?.Select(x => new KnowledgeFileModel
var files = pagedData.Items?.Select(x =>
{
FileId = x.FileId,
FileName = x.FileName,
FileExtension = Path.GetExtension(x.FileName),
ContentType = x.ContentType,
FileUrl = fileStorage.GetKnowledgeBaseFileUrl(collectionName, vectorStoreProvider, x.FileId, x.FileName)
var fileUrl = x.ContentType == MediaTypeNames.Text.Html ?
x.WebUrl : fileStorage.GetKnowledgeBaseFileUrl(collectionName, vectorStoreProvider, x.FileId, x.FileName);
return new KnowledgeFileModel
{
FileId = x.FileId,
FileName = x.FileName,
FileExtension = Path.GetExtension(x.FileName),
ContentType = x.ContentType,
FileUrl = fileUrl
};
})?.ToList() ?? new List<KnowledgeFileModel>();
return new PagedItems<KnowledgeFileModel>

View file

@ -9,6 +9,7 @@ public class KnowledgeCollectionFileMetaDocument : MongoBase
public string ContentType { get; set; }
public string VectorStoreProvider { get; set; }
public IEnumerable<string> VectorDataIds { get; set; } = new List<string>();
public string? WebUrl { get; set; }
public DateTime CreateDate { get; set; }
public string CreateUserId { get; set; }
}

View file

@ -135,6 +135,7 @@ public partial class MongoRepository
ContentType = metaData.ContentType,
VectorStoreProvider = metaData.VectorStoreProvider,
VectorDataIds = metaData.VectorDataIds,
WebUrl = metaData.WebUrl,
CreateDate = metaData.CreateDate,
CreateUserId = metaData.CreateUserId
};
@ -202,6 +203,7 @@ public partial class MongoRepository
ContentType = x.ContentType,
VectorStoreProvider = x.VectorStoreProvider,
VectorDataIds = x.VectorDataIds,
WebUrl = x.WebUrl,
CreateDate = x.CreateDate,
CreateUserId = x.CreateUserId
})?.ToList() ?? new List<KnowledgeDocMetaData>();