split collection name
This commit is contained in:
parent
ac4e856f7b
commit
1ba98db5c9
|
|
@ -14,6 +14,6 @@ public interface IKnowledgeService
|
|||
|
||||
#region List
|
||||
Task<KnowledgeCollectionInfo> GetKnowledgeCollectionInfo(string collectionName);
|
||||
Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(KnowledgeFilter filter);
|
||||
Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter);
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ namespace BotSharp.Abstraction.Knowledges.Models;
|
|||
|
||||
public class KnowledgeFilter : StringIdPagination
|
||||
{
|
||||
[JsonPropertyName("collection_name")]
|
||||
public string CollectionName { get; set; }
|
||||
|
||||
[JsonPropertyName("with_vector")]
|
||||
public bool WithVector { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ public interface IVectorDb
|
|||
{
|
||||
Task<List<string>> GetCollections();
|
||||
Task<KnowledgeCollectionInfo> GetCollectionInfo(string collectionName);
|
||||
Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(KnowledgeFilter filter);
|
||||
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);
|
||||
Task<List<string>> Search(string collectionName, float[] vector, string returnFieldName, int limit = 5, float confidence = 0.5f);
|
||||
|
|
|
|||
|
|
@ -92,17 +92,17 @@ public class KnowledgeBaseController : ControllerBase
|
|||
return Ok(new { count = files.Count, size });
|
||||
}
|
||||
|
||||
[HttpGet("/knowledge/collection/info")]
|
||||
public async Task<KnowledgeCollectionInfoViewModel> GetKnowledgeCollectionInfo([FromQuery] string collectionName)
|
||||
[HttpGet("/knowledge/{collection}/info")]
|
||||
public async Task<KnowledgeCollectionInfoViewModel> GetKnowledgeCollectionInfo([FromRoute] string collection)
|
||||
{
|
||||
var info = await _knowledgeService.GetKnowledgeCollectionInfo(collectionName);
|
||||
var info = await _knowledgeService.GetKnowledgeCollectionInfo(collection);
|
||||
return KnowledgeCollectionInfoViewModel.ToViewModel(info);
|
||||
}
|
||||
|
||||
[HttpPost("/knowledge/collection/data")]
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionDataViewModel>> GetKnowledgeCollectionData([FromBody] KnowledgeFilter filter)
|
||||
{
|
||||
var data = await _knowledgeService.GetKnowledgeCollectionData(filter);
|
||||
[HttpPost("/knowledge/{collection}/data")]
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionDataViewModel>> GetKnowledgeCollectionData([FromRoute] string collection, [FromBody] KnowledgeFilter filter)
|
||||
{;
|
||||
var data = await _knowledgeService.GetKnowledgeCollectionData(collection, filter);
|
||||
var items = data.Items?.Select(x => KnowledgeCollectionDataViewModel.ToViewModel(x))?
|
||||
.ToList() ?? new List<KnowledgeCollectionDataViewModel>();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class MemVectorDatabase : IVectorDb
|
|||
};
|
||||
}
|
||||
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(KnowledgeFilter filter)
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ public partial class KnowledgeService
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(KnowledgeFilter filter)
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = GetVectorDb();
|
||||
return await db.GetCollectionData(filter);
|
||||
return await db.GetCollectionData(collectionName, filter);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class FaissDb : IVectorDb
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(KnowledgeFilter filter)
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ public class QdrantDb : IVectorDb
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(KnowledgeFilter filter)
|
||||
public async Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
|
||||
{
|
||||
var client = GetClient();
|
||||
var exists = await client.CollectionExistsAsync(filter.CollectionName);
|
||||
var exists = await client.CollectionExistsAsync(collectionName);
|
||||
if (!exists)
|
||||
{
|
||||
return new StringIdPagedItems<KnowledgeCollectionData>();
|
||||
}
|
||||
|
||||
var totalPointCount = await client.CountAsync(filter.CollectionName);
|
||||
var response = await client.ScrollAsync(filter.CollectionName, limit: (uint)filter.Size,
|
||||
var totalPointCount = await client.CountAsync(collectionName);
|
||||
var response = await client.ScrollAsync(collectionName, limit: (uint)filter.Size,
|
||||
offset: !string.IsNullOrWhiteSpace(filter.StartId) ? new PointId { Uuid = filter.StartId } : 0,
|
||||
vectorsSelector: filter.WithVector);
|
||||
var points = response?.Result?.Select(x => new KnowledgeCollectionData
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace BotSharp.Plugin.SemanticKernel
|
|||
await _memoryStore.CreateCollectionAsync(collectionName);
|
||||
}
|
||||
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(KnowledgeFilter filter)
|
||||
public Task<StringIdPagedItems<KnowledgeCollectionData>> GetCollectionData(string collectionName, KnowledgeFilter filter)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue