Skip to content

Commit

Permalink
add plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzeyu91 committed Aug 15, 2024
1 parent 0aaa1a9 commit 897c5a3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>
<Version>0.1.20</Version>
<Version>0.1.20-dev1</Version>
<SKVersion>1.17.1</SKVersion>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion src/GraphRag.Net/Domain/Service/GraphService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace GraphRag.Net.Domain.Service
{
[ServiceDescription(typeof(IGraphService), ServiceLifetime.Scoped)]
public class GraphService(
Kernel _kernel,
INodes_Repositories _nodes_Repositories,
IEdges_Repositories _edges_Repositories,
ISemanticService _semanticService,
Expand Down
15 changes: 14 additions & 1 deletion src/GraphRag.Net/Domain/Service/SemanticService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@
namespace GraphRag.Net.Domain.Service
{
[ServiceDescription(typeof(ISemanticService), ServiceLifetime.Scoped)]
public class SemanticService(Kernel _kernel) : ISemanticService
public class SemanticService: ISemanticService
{
private readonly Kernel _kernel;
public SemanticService(Kernel kernel)
{
_kernel = kernel;
//导入插件
if (!_kernel.Plugins.Any(p => p.Name == "graph"))
{
var basePath = AppDomain.CurrentDomain.BaseDirectory; // 或使用其他方式获取根路径
var pluginPath = Path.Combine(basePath, RepoFiles.SamplePluginsPath(), "graph");
Console.WriteLine($"pluginPatth:{pluginPath}");
_kernel.ImportPluginFromPromptDirectory(pluginPath);
}
}
public async Task<string> CreateGraphAsync(string input)
{
OpenAIPromptExecutionSettings settings = new()
Expand Down
8 changes: 1 addition & 7 deletions src/GraphRag.Net/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,7 @@ static void InitSK(IServiceCollection services,Kernel _kernel = null)
)
.Build();
}
//导入插件
if (!_kernel.Plugins.Any(p => p.Name == "graph"))
{
var pluginPatth = Path.Combine(RepoFiles.SamplePluginsPath(), "graph");
Console.WriteLine($"pluginPatth:{pluginPatth}");
_kernel.ImportPluginFromPromptDirectory(pluginPatth);
}

return _kernel;
});
}
Expand Down
1 change: 0 additions & 1 deletion src/GraphRag.Net/Utils/RepoUtils/RepoFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ string FindPluginsDirectory(string startDir, string targetFolder)
{
throw new AppException("Plugins directory not found. The app needs the plugins from the repo to work.");
}
Console.WriteLine(path);
return path;
}
}

0 comments on commit 897c5a3

Please sign in to comment.