Skip to content

Commit 7ed9211

Browse files
author
Jicheng Lu
committed
refine
1 parent fb36f2e commit 7ed9211

File tree

13 files changed

+207
-97
lines changed

13 files changed

+207
-97
lines changed

src/Infrastructure/BotSharp.Abstraction/Files/Proccessors/IFileProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using BotSharp.Abstraction.Files.Options;
22
using BotSharp.Abstraction.Files.Responses;
3+
using BotSharp.Abstraction.Knowledges.Options;
4+
using BotSharp.Abstraction.Knowledges.Responses;
35

46
namespace BotSharp.Abstraction.Files.Proccessors;
57

@@ -9,4 +11,7 @@ public interface IFileProcessor
911

1012
Task<FileHandleResponse> HandleFilesAsync(Agent agent, string text, IEnumerable<InstructFileModel> files, FileHandleOptions? options = null)
1113
=> throw new NotImplementedException();
14+
15+
Task<FileKnowledgeResponse> GetFileKnowledgeAsync(FileBinaryDataModel file, FileKnowledgeProcessOptions? options = null)
16+
=> throw new NotImplementedException();
1217
}

src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ public interface IKnowledgeService
3636
/// </summary>
3737
/// <param name="collectionName"></param>
3838
/// <param name="files"></param>
39+
/// <param name="option"></param>
3940
/// <returns></returns>
40-
Task<UploadKnowledgeResponse> UploadDocumentsToKnowledge(string collectionName, IEnumerable<ExternalFileModel> files, ChunkOption? option = null);
41+
Task<UploadKnowledgeResponse> UploadDocumentsToKnowledge(string collectionName, IEnumerable<ExternalFileModel> files, KnowledgeDocOptions? options = null);
4142
/// <summary>
4243
/// Save document content to knowledgebase without saving the document
4344
/// </summary>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using BotSharp.Abstraction.VectorStorage.Models;
2+
3+
namespace BotSharp.Abstraction.Knowledges.Models;
4+
5+
public class FileKnowledgeModel
6+
{
7+
public IEnumerable<string> Contents { get; set; } = [];
8+
public IDictionary<string, VectorPayloadValue>? Payload { get; set; }
9+
}
10+
11+
12+
public class FileKnowledgeWrapper
13+
{
14+
public Guid FileId { get; set; }
15+
public string? FileSource { get; set; }
16+
public FileBinaryDataModel FileData { get; set; }
17+
public IEnumerable<FileKnowledgeModel> FileKnowledges { get; set; } = [];
18+
}

src/Infrastructure/BotSharp.Abstraction/Files/Models/KnowledgeFileModel.cs renamed to src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeFileModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BotSharp.Abstraction.Files.Models;
1+
namespace BotSharp.Abstraction.Knowledges.Models;
22

33
public class KnowledgeFileModel
44
{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace BotSharp.Abstraction.Knowledges.Options;
2+
3+
public class FileKnowledgeProcessOptions
4+
{
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BotSharp.Abstraction.Knowledges.Options;
2+
3+
public class KnowledgeDocOptions
4+
{
5+
public string? Processor { get; set; }
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BotSharp.Abstraction.Knowledges.Responses;
2+
3+
public class FileKnowledgeResponse
4+
{
5+
public IEnumerable<FileKnowledgeModel> Knowledges { get; set; } = [];
6+
}

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public interface IRuleEngine
1111
/// <param name="options"></param>
1212
/// <returns></returns>
1313
/// <exception cref="NotImplementedException"></exception>
14-
Task<IEnumerable<string>> Trigger(IRuleTrigger trigger, string text, IEnumerable<MessageState>? states = null, RuleTriggerOptions? options = null)
14+
Task<IEnumerable<string>> Triggered(IRuleTrigger trigger, string text, IEnumerable<MessageState>? states = null, RuleTriggerOptions? options = null)
1515
=> throw new NotImplementedException();
1616
}

src/Infrastructure/BotSharp.Core.Rules/Engines/RuleEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public RuleEngine(
2424
_logger = logger;
2525
}
2626

27-
public async Task<IEnumerable<string>> Trigger(IRuleTrigger trigger, string text, IEnumerable<MessageState>? states = null, RuleTriggerOptions? options = null)
27+
public async Task<IEnumerable<string>> Triggered(IRuleTrigger trigger, string text, IEnumerable<MessageState>? states = null, RuleTriggerOptions? options = null)
2828
{
2929
var newConversationIds = new List<string>();
3030

src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBase/KnowledgeBaseController.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ public async Task<bool> DeleteVectorCollectionSnapshots([FromRoute] string colle
207207
[HttpPost("/knowledge/document/{collection}/upload")]
208208
public async Task<UploadKnowledgeResponse> UploadKnowledgeDocuments([FromRoute] string collection, [FromBody] VectorKnowledgeUploadRequest request)
209209
{
210-
var response = await _knowledgeService.UploadDocumentsToKnowledge(collection, request.Files, request.ChunkOption);
210+
var response = await _knowledgeService.UploadDocumentsToKnowledge(collection, request.Files, request.Options);
211211
return response;
212212
}
213213

214-
[HttpPost("/knowledge/document/{collection}/form-upload")]
215-
public async Task<UploadKnowledgeResponse> UploadKnowledgeDocuments([FromRoute] string collection,
216-
[FromForm] IEnumerable<IFormFile> files, [FromForm] ChunkOption? option = null)
214+
[HttpPost("/knowledge/document/{collection}/form")]
215+
public async Task<UploadKnowledgeResponse> UploadKnowledgeDocuments(
216+
[FromRoute] string collection,
217+
[FromForm] IEnumerable<IFormFile> files,
218+
[FromForm] KnowledgeDocOptions? options = null)
217219
{
218220
if (files.IsNullOrEmpty())
219221
{
@@ -231,7 +233,7 @@ public async Task<UploadKnowledgeResponse> UploadKnowledgeDocuments([FromRoute]
231233
});
232234
}
233235

234-
var response = await _knowledgeService.UploadDocumentsToKnowledge(collection, docs, option);
236+
var response = await _knowledgeService.UploadDocumentsToKnowledge(collection, docs, options);
235237
return response;
236238
}
237239

0 commit comments

Comments
 (0)