remove knowledge info

This commit is contained in:
Jicheng Lu 2024-08-07 13:18:41 -05:00
parent 1ba98db5c9
commit cdf02c10c5
9 changed files with 1 additions and 83 deletions

View file

@ -13,7 +13,6 @@ public interface IKnowledgeService
Task<List<RetrievedResult>> GetAnswer(KnowledgeRetrievalModel retrievalModel);
#region List
Task<KnowledgeCollectionInfo> GetKnowledgeCollectionInfo(string collectionName);
Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter);
#endregion
}

View file

@ -5,7 +5,6 @@ namespace BotSharp.Abstraction.VectorStorage;
public interface IVectorDb
{
Task<List<string>> GetCollections();
Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName);
Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter);
Task CreateCollection(string collectionName, int dim);
Task<bool> Upsert(string collectionName, string id, float[] vector, string text, Dictionary<string, string>? payload = null);

View file

@ -92,12 +92,6 @@ public class KnowledgeBaseController : ControllerBase
return Ok(new { count = files.Count, size });
}
[HttpGet("/knowledge/{collection}/info")]
public async Task<KnowledgeCollectionInfoViewModel> GetKnowledgeCollectionInfo([FromRoute] string collection)
{
var info = await _knowledgeService.GetKnowledgeCollectionInfo(collection);
return KnowledgeCollectionInfoViewModel.ToViewModel(info);
}
[HttpPost("/knowledge/{collection}/data")]
public async Task<StringIdPagedItems<KnowledgeCollectionDataViewModel>> GetKnowledgeCollectionData([FromRoute] string collection, [FromBody] KnowledgeFilter filter)

View file

@ -1,22 +0,0 @@
using BotSharp.Abstraction.Knowledges.Models;
using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Knowledges;
public class KnowledgeCollectionInfoViewModel
{
[JsonPropertyName("data_count")]
public ulong DataCount { get; set; }
[JsonPropertyName("vector_count")]
public ulong VectorCount { get; set; }
public static KnowledgeCollectionInfoViewModel ToViewModel(KnowledgeCollectionInfo info)
{
return new KnowledgeCollectionInfoViewModel
{
DataCount = info.DataCount,
VectorCount = info.VectorCount
};
}
}

View file

@ -18,20 +18,6 @@ public class MemVectorDatabase : IVectorDb
return _collections.Select(x => x.Key).ToList();
}
public async Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName)
{
if (_vectors.TryGetValue(collectionName, out var info))
{
info = new List<VecRecord>();
}
return new KnowledgeCollectionInfo
{
DataCount = (ulong)(info?.Count ?? 0),
VectorCount = (ulong)(info?.Count(x => x.Vector != null && x.Vector.Length > 0) ?? 0)
};
}
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
{
throw new NotImplementedException();

View file

@ -2,20 +2,6 @@ namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService
{
public async Task<KnowledgeCollectionInfo> GetKnowledgeCollectionInfo(string collectionName)
{
try
{
var db = GetVectorDb();
return await db.GetCollectionInfo(collectionName);
}
catch (Exception ex)
{
_logger.LogWarning($"Error when getting knowledge collectio info. {ex.Message}\r\n{ex.InnerException}");
return new KnowledgeCollectionInfo();
}
}
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter)
{
try

View file

@ -14,11 +14,6 @@ public class FaissDb : IVectorDb
throw new NotImplementedException();
}
public Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName)
{
throw new NotImplementedException();
}
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
{
throw new NotImplementedException();

View file

@ -39,24 +39,10 @@ public class QdrantDb : IVectorDb
return collections.ToList();
}
public async Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName)
{
var client = GetClient();
var exists = await client.CollectionExistsAsync(collectionName);
if (!exists) return new KnowledgeCollectionInfo();
var info = await client.GetCollectionInfoAsync(collectionName);
return new KnowledgeCollectionInfo
{
DataCount = info.PointsCount,
VectorCount = info.VectorsCount
};
}
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
{
var client = GetClient();
var exists = await client.CollectionExistsAsync(collectionName);
if (!exists)
{

View file

@ -29,11 +29,6 @@ namespace BotSharp.Plugin.SemanticKernel
throw new System.NotImplementedException();
}
public Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName)
{
throw new System.NotImplementedException();
}
public async Task<List<string>> GetCollections()
{
var result = new List<string>();