@@ -16,16 +16,19 @@ namespace GraphRag.Net.Domain.Service
16
16
public class SemanticService : ISemanticService
17
17
{
18
18
private readonly Kernel _kernel ;
19
+
20
+ private KernelPlugin _plugin ;
19
21
public SemanticService ( Kernel kernel )
20
22
{
21
23
_kernel = kernel ;
22
24
//导入插件
23
25
if ( ! _kernel . Plugins . Any ( p => p . Name == "graph" ) )
24
26
{
25
27
var basePath = AppDomain . CurrentDomain . BaseDirectory ; // 或使用其他方式获取根路径
26
- var pluginPath = Path . Combine ( basePath , RepoFiles . SamplePluginsPath ( ) ) ;
28
+ var pluginPath = Path . Combine ( basePath , RepoFiles . SamplePluginsPath ( ) , "graph" ) ;
27
29
Console . WriteLine ( $ "pluginPatth:{ pluginPath } ") ;
28
- _kernel . ImportPluginFromPromptDirectory ( pluginPath , "graph" ) ;
30
+ _plugin = _kernel . ImportPluginFromPromptDirectory ( pluginPath ) ;
31
+ Console . WriteLine ( $ "FunCount:{ _plugin . Count ( ) } ") ;
29
32
}
30
33
}
31
34
public async Task < string > CreateGraphAsync ( string input )
@@ -35,7 +38,7 @@ public async Task<string> CreateGraphAsync(string input)
35
38
Temperature = 0 ,
36
39
ResponseFormat = ChatCompletionsResponseFormat . JsonObject
37
40
} ;
38
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " create") ;
41
+ KernelFunction createFun = _plugin [ " create"] ;
39
42
var args = new KernelArguments ( settings )
40
43
{
41
44
[ "input" ] = input ,
@@ -48,7 +51,7 @@ public async Task<string> CreateGraphAsync(string input)
48
51
public async Task < string > GetGraphAnswerAsync ( string graph , string input )
49
52
{
50
53
51
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " search") ;
54
+ KernelFunction createFun = _plugin [ " search"] ;
52
55
var args = new KernelArguments ( )
53
56
{
54
57
[ "graph" ] = graph ,
@@ -61,7 +64,7 @@ public async Task<string> GetGraphAnswerAsync(string graph, string input)
61
64
}
62
65
public async IAsyncEnumerable < StreamingKernelContent > GetGraphAnswerStreamAsync ( string graph , string input )
63
66
{
64
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " search") ;
67
+ KernelFunction createFun = _plugin [ " search"] ;
65
68
var args = new KernelArguments ( )
66
69
{
67
70
[ "graph" ] = graph ,
@@ -78,7 +81,7 @@ public async IAsyncEnumerable<StreamingKernelContent> GetGraphAnswerStreamAsync(
78
81
public async Task < string > GetGraphCommunityAnswerAsync ( string graph , string community , string global , string input )
79
82
{
80
83
81
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " community_search") ;
84
+ KernelFunction createFun = _plugin [ " community_search"] ;
82
85
var args = new KernelArguments ( )
83
86
{
84
87
[ "graph" ] = graph ,
@@ -95,7 +98,7 @@ public async Task<string> GetGraphCommunityAnswerAsync(string graph,string commu
95
98
public async IAsyncEnumerable < StreamingKernelContent > GetGraphCommunityAnswerStreamAsync ( string graph , string community , string global , string input )
96
99
{
97
100
98
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " community_search") ;
101
+ KernelFunction createFun = _plugin [ " community_search"] ;
99
102
var args = new KernelArguments ( )
100
103
{
101
104
[ "graph" ] = graph ,
@@ -114,7 +117,7 @@ public async IAsyncEnumerable<StreamingKernelContent> GetGraphCommunityAnswerStr
114
117
115
118
public async Task < string > GetRelationship ( string node1 , string node2 )
116
119
{
117
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " relationship") ;
120
+ KernelFunction createFun = _plugin [ " relationship"] ;
118
121
var args = new KernelArguments ( )
119
122
{
120
123
[ "node1" ] = node1 ,
@@ -128,7 +131,7 @@ public async Task<string> GetRelationship(string node1, string node2)
128
131
129
132
public async Task < string > MergeDesc ( string desc1 , string desc2 )
130
133
{
131
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " mergedesc") ;
134
+ KernelFunction createFun = _plugin [ " mergedesc"] ;
132
135
var args = new KernelArguments ( )
133
136
{
134
137
[ "desc1" ] = desc1 ,
@@ -141,7 +144,7 @@ public async Task<string> MergeDesc(string desc1, string desc2)
141
144
}
142
145
public async Task < string > CommunitySummaries ( string nodes )
143
146
{
144
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " community_summaries") ;
147
+ KernelFunction createFun = _plugin [ " community_summaries"] ;
145
148
var args = new KernelArguments ( )
146
149
{
147
150
[ "nodes" ] = nodes
@@ -153,7 +156,7 @@ public async Task<string> CommunitySummaries(string nodes)
153
156
}
154
157
public async Task < string > GlobalSummaries ( string community )
155
158
{
156
- KernelFunction createFun = _kernel . Plugins . GetFunction ( "graph" , " global_summaries") ;
159
+ KernelFunction createFun = _plugin [ " global_summaries"] ;
157
160
var args = new KernelArguments ( )
158
161
{
159
162
[ "community" ] = community
0 commit comments