Skip to content

Commit b65a5a7

Browse files
committed
Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/local-test-pgt
2 parents fda4f5a + 052fa9f commit b65a5a7

143 files changed

Lines changed: 2731 additions & 1740 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public interface IAgentService
5353
/// <param name="id"></param>
5454
/// <returns>Original agent information</returns>
5555
Task<Agent> GetAgent(string id);
56-
56+
Task<AgentTemplate?> GetAgentTemplateDetail(string agentId, string templateName);
57+
5758
Task<bool> DeleteAgent(string id, AgentDeleteOptions? options = null);
5859
Task UpdateAgent(Agent agent, AgentField updateField);
5960

src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ namespace BotSharp.Abstraction.Agents.Models;
22

33
public class AgentLlmConfig
44
{
5+
public AgentLlmConfig() { }
6+
7+
public AgentLlmConfig(AgentTemplateLlmConfig templateLlmConfig)
8+
{
9+
Provider = templateLlmConfig.Provider;
10+
Model = templateLlmConfig.Model;
11+
MaxOutputTokens = templateLlmConfig.MaxOutputTokens;
12+
ReasoningEffortLevel = templateLlmConfig.ReasoningEffortLevel;
13+
}
14+
515
/// <summary>
616
/// Is inherited from default Agent Settings
717
/// </summary>
@@ -72,6 +82,6 @@ public class LlmAudioTranscriptionConfig : LlmProviderModel
7282
{
7383
}
7484

75-
public class LlmRealtimeConfig : LlmProviderModel
85+
public class LlmRealtimeConfig : LlmConfigBase
7686
{
7787
}

src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentTemplate.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
namespace BotSharp.Abstraction.Agents.Models;
22

3-
public class AgentTemplate
3+
public class AgentTemplate : AgentTemplateConfig
44
{
5-
public string Name { get; set; }
6-
public string Content { get; set; }
5+
public string Content { get; set; } = string.Empty;
76

87
public AgentTemplate()
98
{
@@ -20,3 +19,23 @@ public override string ToString()
2019
return Name;
2120
}
2221
}
22+
23+
public class AgentTemplateConfig
24+
{
25+
public string Name { get; set; }
26+
27+
/// <summary>
28+
/// Response format: json, xml, markdown, yaml, etc.
29+
/// </summary>
30+
[JsonPropertyName("response_format")]
31+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
32+
public string? ResponseFormat { get; set; }
33+
34+
[JsonPropertyName("llm_config")]
35+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
36+
public AgentTemplateLlmConfig? LlmConfig { get; set; }
37+
}
38+
39+
public class AgentTemplateLlmConfig : LlmConfigBase
40+
{
41+
}

src/Infrastructure/BotSharp.Abstraction/Entity/Models/EntityAnalysisOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class EntityAnalysisOptions
77
/// </summary>
88
[JsonPropertyName("data_providers")]
99
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
10-
public List<string>? DataProviders { get; set; }
10+
public IEnumerable<string>? DataProviders { get; set; }
1111

1212
/// <summary>
1313
/// Maximum n-gram size

src/Infrastructure/BotSharp.Abstraction/Files/IFileStorageService.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,9 @@ public interface IFileStorageService
6262
#endregion
6363

6464
#region Knowledge
65-
bool SaveKnowledgeBaseFile(string collectionName, string vectorStoreProvider, Guid fileId, string fileName, BinaryData fileData);
66-
67-
/// <summary>
68-
/// Delete files in a knowledge collection, given the vector store provider. If "fileId" is null, delete all files in the collection.
69-
/// </summary>
70-
/// <param name="collectionName"></param>
71-
/// <param name="vectorStoreProvider"></param>
72-
/// <param name="fileId"></param>
73-
/// <returns></returns>
74-
bool DeleteKnowledgeFile(string collectionName, string vectorStoreProvider, Guid? fileId = null);
75-
string GetKnowledgeBaseFileUrl(string collectionName, string vectorStoreProvider, Guid fileId, string fileName);
76-
BinaryData GetKnowledgeBaseFileBinaryData(string collectionName, string vectorStoreProvider, Guid fileId, string fileName);
65+
bool SaveKnowledgeBaseFile(string collectionName, string knowledgebaseProvider, Guid fileId, string fileName, BinaryData fileData);
66+
bool DeleteKnowledgeFile(string collectionName, string knowledgebaseProvider, Guid? fileId = null);
67+
string GetKnowledgeBaseFileUrl(string collectionName, string knowledgebaseProvider, Guid fileId, string fileName);
68+
BinaryData GetKnowledgeBaseFileBinaryData(string collectionName, string knowledgebaseProvider, Guid fileId, string fileName);
7769
#endregion
7870
}

src/Infrastructure/BotSharp.Abstraction/Files/Utilities/FileUtility.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ public static BinaryData BuildBinaryDataFromFile(IFormFile file)
6565

6666
public static string GetFileContentType(string fileName)
6767
{
68+
if (string.IsNullOrEmpty(fileName))
69+
{
70+
return string.Empty;
71+
}
72+
73+
// For URLs (e.g. signed S3/CloudFront URLs with query strings), extract the path portion
74+
// so that FileExtensionContentTypeProvider can correctly resolve the extension.
75+
if (Uri.TryCreate(fileName, UriKind.Absolute, out var uri)
76+
&& (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps))
77+
{
78+
fileName = uri.AbsolutePath;
79+
}
80+
6881
string contentType;
6982
var provider = new FileExtensionContentTypeProvider();
7083
if (!provider.TryGetContentType(fileName, out contentType))

src/Infrastructure/BotSharp.Abstraction/Graph/IGraphKnowledgeService.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Infrastructure/BotSharp.Abstraction/Knowledges/Enums/KnowledgeCollectionType.cs renamed to src/Infrastructure/BotSharp.Abstraction/Knowledges/Enums/KnowledgeBaseType.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace BotSharp.Abstraction.Knowledges.Enums;
22

3-
public static class KnowledgeCollectionType
3+
public static class KnowledgeBaseType
44
{
55
public static string QuestionAnswer = "question-answer";
66
public static string Document = "document";
7+
public static string Taxonomy = "taxonomy";
8+
public static string SemanticGraph = "semantic-graph";
79
}

src/Infrastructure/BotSharp.Abstraction/Knowledges/Filters/KnowledgeFileFilter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ namespace BotSharp.Abstraction.Knowledges.Filters;
22

33
public class KnowledgeFileFilter : Pagination
44
{
5+
public string? DbProvider { get; set; }
56
public IEnumerable<Guid>? FileIds { get; set; }
6-
77
public IEnumerable<string>? FileNames { get; set; }
8-
98
public IEnumerable<string>? ContentTypes { get; set; }
10-
119
public IEnumerable<string>? FileSources { get; set; }
1210

1311
public KnowledgeFileFilter()
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using BotSharp.Abstraction.Knowledges.Filters;
2+
using BotSharp.Abstraction.Knowledges.Responses;
3+
4+
namespace BotSharp.Abstraction.Knowledges;
5+
6+
public interface IKnowledgeFileOrchestrator
7+
{
8+
string Provider { get; }
9+
10+
/// <summary>
11+
/// Save files and their contents to knowledgebase
12+
/// </summary>
13+
/// <param name="collectionName"></param>
14+
/// <param name="files"></param>
15+
/// <param name="options"></param>
16+
/// <returns></returns>
17+
Task<UploadKnowledgeResponse> UploadFilesToKnowledge(string collectionName,
18+
IEnumerable<ExternalFileModel> files, KnowledgeFileHandleOptions? options = null);
19+
20+
/// <summary>
21+
/// Import file content to knowledgebase without saving the file
22+
/// </summary>
23+
/// <param name="collectionName"></param>
24+
/// <param name="fileName"></param>
25+
/// <param name="fileSource"></param>
26+
/// <param name="contents"></param>
27+
/// <param name="options"></param>
28+
/// <returns></returns>
29+
Task<bool> ImportFileContentToKnowledge(string collectionName, string fileName, string fileSource,
30+
IEnumerable<string> contents, ImportKnowledgeFileOptions? options = null);
31+
32+
/// <summary>
33+
/// Delete one file and its related knowledge in the collection
34+
/// </summary>
35+
/// <param name="collectionName"></param>
36+
/// <param name="fileId"></param>
37+
/// <param name="options"></param>
38+
/// <returns></returns>
39+
Task<bool> DeleteKnowledgeFile(string collectionName, Guid fileId, KnowledgeFileOptions? options = null);
40+
41+
/// <summary>
42+
/// Delete all files and their related knowledge in the collection
43+
/// </summary>
44+
/// <param name="collectionName"></param>
45+
/// <param name="filter"></param>
46+
/// <returns></returns>
47+
Task<bool> DeleteKnowledgeFiles(string collectionName, KnowledgeFileFilter filter);
48+
49+
/// <summary>
50+
/// Get knowledge files by pagination
51+
/// </summary>
52+
/// <param name="collectionName"></param>
53+
/// <param name="filter"></param>
54+
/// <returns></returns>
55+
Task<PagedItems<KnowledgeFileModel>> GetPagedKnowledgeFiles(string collectionName, KnowledgeFileFilter filter);
56+
57+
/// <summary>
58+
/// Get knowledge file binary data
59+
/// </summary>
60+
/// <param name="collectionName"></param>
61+
/// <param name="fileId"></param>
62+
/// <param name="options"></param>
63+
/// <returns></returns>
64+
Task<FileBinaryDataModel> GetKnowledgeFileBinaryData(string collectionName, Guid fileId, KnowledgeFileOptions? options = null);
65+
}

0 commit comments

Comments
 (0)