BotSharp/src/Infrastructure/BotSharp.Core/Knowledges/Services/KnowledgeService.Delete.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2024-08-31 05:57:49 +00:00
namespace BotSharp.Core.Knowledges.Services;
2024-08-06 21:02:02 +00:00
public partial class KnowledgeService
{
2024-08-29 19:30:47 +00:00
public async Task<bool> DeleteVectorCollection(string collectionName)
{
try
{
if (string.IsNullOrWhiteSpace(collectionName))
{
return false;
}
var db = GetVectorDb();
return await db.DeleteCollection(collectionName);
}
catch (Exception ex)
{
_logger.LogWarning($"Error when deleting collection ({collectionName}). {ex.Message}\r\n{ex.InnerException}");
return false;
}
}
2024-08-15 23:19:10 +00:00
public async Task<bool> DeleteVectorCollectionData(string collectionName, string id)
2024-08-08 22:15:51 +00:00
{
try
{
if (!Guid.TryParse(id, out var guid))
{
return false;
}
2024-08-08 22:15:51 +00:00
var db = GetVectorDb();
return await db.DeleteCollectionData(collectionName, guid);
2024-08-08 22:15:51 +00:00
}
catch (Exception ex)
{
2024-08-23 03:13:40 +00:00
_logger.LogWarning($"Error when deleting vector collection data ({collectionName}-{id}). {ex.Message}\r\n{ex.InnerException}");
2024-08-08 22:15:51 +00:00
return false;
}
}
2024-08-06 21:02:02 +00:00
}