Skip to content

Commit 48a5427

Browse files
authored
Merge pull request #1280 from iceljc/master
rename graph query
2 parents db970ee + d29d896 commit 48a5427

File tree

11 files changed

+31
-25
lines changed

11 files changed

+31
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface IGraphDb
99
{
1010
public string Provider { get; }
1111

12-
Task<GraphSearchResult> SearchAsync(string query, GraphSearchOptions? options = null)
12+
Task<GraphQueryResult> ExecuteQueryAsync(string query, GraphQueryExecuteOptions? options = null)
1313
=> throw new NotImplementedException();
1414

1515
#region Node

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BotSharp.Abstraction.Graph;
77

88
public interface IGraphKnowledgeService
99
{
10-
Task<GraphSearchResult> SearchAsync(string query, GraphSearchOptions? options = null);
10+
Task<GraphQueryResult> ExecuteQueryAsync(string query, GraphQueryOptions? options = null);
1111

1212
#region Node
1313
Task<GraphNode?> GetNodeAsync(string graphId, string nodeId, GraphNodeOptions? options = null);

src/Infrastructure/BotSharp.Abstraction/Graph/Models/GraphSearchResult.cs renamed to src/Infrastructure/BotSharp.Abstraction/Graph/Models/GraphQueryResult.cs

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

3-
public class GraphSearchResult
3+
public class GraphQueryResult
44
{
55
public string Result { get; set; } = string.Empty;
66
public string[] Keys { get; set; } = [];

src/Infrastructure/BotSharp.Abstraction/Graph/Options/GraphSearchOptions.cs renamed to src/Infrastructure/BotSharp.Abstraction/Graph/Options/GraphQueryOptions.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
namespace BotSharp.Abstraction.Graph.Options;
22

3-
public class GraphSearchOptions
3+
public class GraphQueryOptions : GraphQueryExecuteOptions
4+
{
5+
public string Provider { get; set; }
6+
}
7+
8+
public class GraphQueryExecuteOptions
49
{
5-
public string? Provider { get; set; }
610
public string? GraphId { get; set; }
711
public Dictionary<string, object>? Arguments { get; set; }
812
public string? Method { get; set; }
9-
}
13+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ public async Task<bool> DeleteVectorCollectionSnapshots([FromRoute] string colle
208208
[HttpPost("/knowledge/graph/search")]
209209
public async Task<GraphKnowledgeViewModel> SearchGraphKnowledge([FromBody] SearchGraphKnowledgeRequest request)
210210
{
211-
var options = new GraphSearchOptions
211+
var options = new GraphQueryOptions
212212
{
213213
Provider = request.Provider,
214214
GraphId = request.GraphId,
215215
Arguments = request.Arguments,
216216
Method = request.Method
217217
};
218218

219-
var result = await _graphKnowledgeService.SearchAsync(request.Query, options);
219+
var result = await _graphKnowledgeService.ExecuteQueryAsync(request.Query, options);
220220
return new GraphKnowledgeViewModel
221221
{
222222
Result = result.Result

src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public GraphDb(
3838

3939
public string Provider => "Remote";
4040

41-
public async Task<GraphSearchResult> SearchAsync(string query, GraphSearchOptions? options = null)
41+
public async Task<GraphQueryResult> ExecuteQueryAsync(string query, GraphQueryExecuteOptions? options = null)
4242
{
4343
if (string.IsNullOrWhiteSpace(_settings.BaseUrl))
4444
{
45-
return new GraphSearchResult();
45+
return new GraphQueryResult();
4646
}
4747

4848
var url = $"{_settings.BaseUrl}{_settings.SearchPath}";
@@ -56,9 +56,9 @@ public async Task<GraphSearchResult> SearchAsync(string query, GraphSearchOption
5656

5757

5858
#region Private methods
59-
private async Task<GraphSearchResult> SendRequest(string url, GraphQueryRequest request)
59+
private async Task<GraphQueryResult> SendRequest(string url, GraphQueryRequest request)
6060
{
61-
var result = new GraphSearchResult();
61+
var result = new GraphQueryResult();
6262
var http = _services.GetRequiredService<IHttpClientFactory>();
6363

6464
using (var client = http.CreateClient())
@@ -79,7 +79,7 @@ private async Task<GraphSearchResult> SendRequest(string url, GraphQueryRequest
7979
rawResponse.EnsureSuccessStatusCode();
8080

8181
var responseStr = await rawResponse.Content.ReadAsStringAsync();
82-
result = JsonSerializer.Deserialize<GraphSearchResult>(responseStr, _jsonOptions);
82+
result = JsonSerializer.Deserialize<GraphQueryResult>(responseStr, _jsonOptions);
8383
return result;
8484
}
8585
catch (Exception ex)

src/Plugins/BotSharp.Plugin.KnowledgeBase/Graph/GraphKnowledgeService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public GraphKnowledgeService(
1818
_settings = settings;
1919
}
2020

21-
public async Task<GraphSearchResult> SearchAsync(string query, GraphSearchOptions? options = null)
21+
public async Task<GraphQueryResult> ExecuteQueryAsync(string query, GraphQueryOptions? options = null)
2222
{
2323
try
2424
{
2525
var db = GetGraphDb(options?.Provider);
26-
var result = await db.SearchAsync(query, options);
26+
var result = await db.ExecuteQueryAsync(query, options);
2727
return result;
2828
}
2929
catch (Exception ex)
3030
{
3131
_logger.LogError(ex, $"Error when searching graph knowledge (Query: {query}).");
32-
return new GraphSearchResult();
32+
return new GraphQueryResult();
3333
}
3434
}
3535

src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeHook.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ public async Task<List<string>> GetDomainKnowledges(RoleDialogModel message, str
3636
{
3737
if (knowledgeBase.Type == "relationships")
3838
{
39-
var options = new GraphSearchOptions
39+
var options = new GraphQueryOptions
4040
{
41+
Provider = "Remote",
4142
Method = "local"
4243
};
43-
var result = await _graphKnowledgeService.SearchAsync(text, options);
44+
var result = await _graphKnowledgeService.ExecuteQueryAsync(text, options);
4445
results.Add(result.Result);
4546
}
4647
else if (knowledgeBase.Type == "document")
@@ -89,11 +90,12 @@ public async Task<List<string>> GetGlobalKnowledges(RoleDialogModel message)
8990
{
9091
if (knowledgeBase.Type == "relationships")
9192
{
92-
var options = new GraphSearchOptions
93+
var options = new GraphQueryOptions
9394
{
95+
Provider = "Remote",
9496
Method = "local"
9597
};
96-
var result = await _graphKnowledgeService.SearchAsync(text, options);
98+
var result = await _graphKnowledgeService.ExecuteQueryAsync(text, options);
9799
results.Add(result.Result);
98100
}
99101
else

src/Plugins/BotSharp.Plugin.Membase/Controllers/MembaseController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task<IActionResult> ExecuteGraphQuery(string graphId, [FromBody] Cy
4040
try
4141
{
4242
var graph = _services.GetServices<IGraphDb>().First(x => x.Provider == "membase");
43-
var result = await graph.SearchAsync(query: request.Query, options: new()
43+
var result = await graph.ExecuteQueryAsync(query: request.Query, options: new()
4444
{
4545
GraphId = graphId,
4646
Arguments = request.Parameters

src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public MembaseGraphDb(
2424

2525
public string Provider => "membase";
2626

27-
public async Task<GraphSearchResult> SearchAsync(string query, GraphSearchOptions? options = null)
27+
public async Task<GraphQueryResult> ExecuteQueryAsync(string query, GraphQueryExecuteOptions? options = null)
2828
{
2929
if (string.IsNullOrEmpty(options?.GraphId))
3030
{
@@ -39,7 +39,7 @@ public async Task<GraphSearchResult> SearchAsync(string query, GraphSearchOption
3939
Parameters = options.Arguments ?? new Dictionary<string, object>()
4040
});
4141

42-
return new GraphSearchResult
42+
return new GraphQueryResult
4343
{
4444
Keys = response.Columns,
4545
Values = response.Data,

0 commit comments

Comments
 (0)