add default collection
This commit is contained in:
parent
e6b54c6ed3
commit
548cd558c0
|
|
@ -1,8 +1,11 @@
|
|||
using BotSharp.Abstraction.Knowledges.Enums;
|
||||
|
||||
namespace BotSharp.Abstraction.Knowledges.Settings;
|
||||
|
||||
public class KnowledgeBaseSettings
|
||||
{
|
||||
public string VectorDb { get; set; }
|
||||
public string DefaultCollection { get; set; } = KnowledgeCollectionName.BotSharp;
|
||||
public KnowledgeModelSetting TextEmbedding { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ namespace BotSharp.Core.Repository
|
|||
var json = JsonSerializer.Serialize(agent, _options);
|
||||
File.WriteAllText(agentFile, json);
|
||||
|
||||
UpdateAgentInstructions(inputAgent.Id, inputAgent.Instruction, agent.ChannelInstructions);
|
||||
UpdateAgentInstructions(inputAgent.Id, inputAgent.Instruction, inputAgent.ChannelInstructions);
|
||||
UpdateAgentResponses(inputAgent.Id, inputAgent.Responses);
|
||||
UpdateAgentTemplates(inputAgent.Id, inputAgent.Templates);
|
||||
UpdateAgentFunctions(inputAgent.Id, inputAgent.Functions);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ public class KnowledgeRetrievalFn : IFunctionCallback
|
|||
|
||||
var vector = await embedding.GetVectorAsync(args.Question);
|
||||
var vectorDb = _services.GetServices<IVectorDb>().FirstOrDefault(x => x.Name == _settings.VectorDb);
|
||||
var knowledges = await vectorDb.Search(KnowledgeCollectionName.BotSharp, vector, new List<string> { KnowledgePayloadName.Answer });
|
||||
var collectionName = !string.IsNullOrWhiteSpace(_settings.DefaultCollection) ? _settings.DefaultCollection : KnowledgeCollectionName.BotSharp;
|
||||
var knowledges = await vectorDb.Search(collectionName, vector, new List<string> { KnowledgePayloadName.Answer });
|
||||
|
||||
if (!knowledges.IsNullOrEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ public class MemorizeKnowledgeFn : IFunctionCallback
|
|||
});
|
||||
|
||||
var vectorDb = _services.GetServices<IVectorDb>().FirstOrDefault(x => x.Name == _settings.VectorDb);
|
||||
await vectorDb.CreateCollection(KnowledgeCollectionName.BotSharp, vector[0].Length);
|
||||
var collectionName = !string.IsNullOrWhiteSpace(_settings.DefaultCollection) ? _settings.DefaultCollection : KnowledgeCollectionName.BotSharp;
|
||||
await vectorDb.CreateCollection(collectionName, vector[0].Length);
|
||||
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var result = await vectorDb.Upsert(KnowledgeCollectionName.BotSharp, id, vector[0],
|
||||
var result = await vectorDb.Upsert(collectionName, id, vector[0],
|
||||
args.Question,
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -259,6 +259,7 @@
|
|||
|
||||
"KnowledgeBase": {
|
||||
"VectorDb": "Qdrant",
|
||||
"DefaultCollection": "BotSharp",
|
||||
"TextEmbedding": {
|
||||
"Provider": "openai",
|
||||
"Model": "text-embedding-3-small"
|
||||
|
|
|
|||
Loading…
Reference in a new issue