Skip to content

Commit cf564de

Browse files
committed
fix plugin
1 parent f35e506 commit cf564de

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
33
<PropertyGroup>
4-
<Version>0.1.20-dev2</Version>
4+
<Version>0.1.20-dev3</Version>
55
<SKVersion>1.17.1</SKVersion>
66
</PropertyGroup>
77
</Project>

src/GraphRag.Net/Domain/Service/SemanticService.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ namespace GraphRag.Net.Domain.Service
1616
public class SemanticService: ISemanticService
1717
{
1818
private readonly Kernel _kernel;
19+
20+
private KernelPlugin _plugin;
1921
public SemanticService(Kernel kernel)
2022
{
2123
_kernel = kernel;
2224
//导入插件
2325
if (!_kernel.Plugins.Any(p => p.Name == "graph"))
2426
{
2527
var basePath = AppDomain.CurrentDomain.BaseDirectory; // 或使用其他方式获取根路径
26-
var pluginPath = Path.Combine(basePath, RepoFiles.SamplePluginsPath());
28+
var pluginPath = Path.Combine(basePath, RepoFiles.SamplePluginsPath(), "graph");
2729
Console.WriteLine($"pluginPatth:{pluginPath}");
28-
_kernel.ImportPluginFromPromptDirectory(pluginPath, "graph");
30+
_plugin=_kernel.ImportPluginFromPromptDirectory(pluginPath);
31+
Console.WriteLine($"FunCount:{_plugin.Count()}");
2932
}
3033
}
3134
public async Task<string> CreateGraphAsync(string input)
@@ -35,7 +38,7 @@ public async Task<string> CreateGraphAsync(string input)
3538
Temperature = 0,
3639
ResponseFormat = ChatCompletionsResponseFormat.JsonObject
3740
};
38-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "create");
41+
KernelFunction createFun = _plugin["create"];
3942
var args = new KernelArguments(settings)
4043
{
4144
["input"] = input,
@@ -48,7 +51,7 @@ public async Task<string> CreateGraphAsync(string input)
4851
public async Task<string> GetGraphAnswerAsync(string graph, string input)
4952
{
5053

51-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "search");
54+
KernelFunction createFun = _plugin["search"];
5255
var args = new KernelArguments()
5356
{
5457
["graph"] = graph,
@@ -61,7 +64,7 @@ public async Task<string> GetGraphAnswerAsync(string graph, string input)
6164
}
6265
public async IAsyncEnumerable<StreamingKernelContent> GetGraphAnswerStreamAsync(string graph, string input)
6366
{
64-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "search");
67+
KernelFunction createFun = _plugin["search"];
6568
var args = new KernelArguments()
6669
{
6770
["graph"] = graph,
@@ -78,7 +81,7 @@ public async IAsyncEnumerable<StreamingKernelContent> GetGraphAnswerStreamAsync(
7881
public async Task<string> GetGraphCommunityAnswerAsync(string graph,string community,string global,string input)
7982
{
8083

81-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "community_search");
84+
KernelFunction createFun = _plugin["community_search"];
8285
var args = new KernelArguments()
8386
{
8487
["graph"] = graph,
@@ -95,7 +98,7 @@ public async Task<string> GetGraphCommunityAnswerAsync(string graph,string commu
9598
public async IAsyncEnumerable<StreamingKernelContent> GetGraphCommunityAnswerStreamAsync(string graph, string community, string global, string input)
9699
{
97100

98-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "community_search");
101+
KernelFunction createFun = _plugin["community_search"];
99102
var args = new KernelArguments()
100103
{
101104
["graph"] = graph,
@@ -114,7 +117,7 @@ public async IAsyncEnumerable<StreamingKernelContent> GetGraphCommunityAnswerStr
114117

115118
public async Task<string> GetRelationship(string node1, string node2)
116119
{
117-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "relationship");
120+
KernelFunction createFun = _plugin["relationship"];
118121
var args = new KernelArguments()
119122
{
120123
["node1"] = node1,
@@ -128,7 +131,7 @@ public async Task<string> GetRelationship(string node1, string node2)
128131

129132
public async Task<string> MergeDesc(string desc1, string desc2)
130133
{
131-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "mergedesc");
134+
KernelFunction createFun = _plugin["mergedesc"];
132135
var args = new KernelArguments()
133136
{
134137
["desc1"] = desc1,
@@ -141,7 +144,7 @@ public async Task<string> MergeDesc(string desc1, string desc2)
141144
}
142145
public async Task<string> CommunitySummaries(string nodes)
143146
{
144-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "community_summaries");
147+
KernelFunction createFun = _plugin["community_summaries"];
145148
var args = new KernelArguments()
146149
{
147150
["nodes"] = nodes
@@ -153,7 +156,7 @@ public async Task<string> CommunitySummaries(string nodes)
153156
}
154157
public async Task<string> GlobalSummaries(string community)
155158
{
156-
KernelFunction createFun = _kernel.Plugins.GetFunction("graph", "global_summaries");
159+
KernelFunction createFun = _plugin["global_summaries"];
157160
var args = new KernelArguments()
158161
{
159162
["community"] = community

0 commit comments

Comments
 (0)