Skip to content

Commit a7fa05e

Browse files
committed
fix plugin dir bug
1 parent e3852ed commit a7fa05e

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
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.16</Version>
4+
<Version>0.1.17</Version>
55
<SKVersion>1.17.1</SKVersion>
66
</PropertyGroup>
77
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "8.0.8",
7+
"commands": [
8+
"dotnet-ef"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

src/GraphRag.Net.Web/GraphRag.Net.Web.csproj.user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
<NameOfLastUsedPublishProfile>D:\AI\AntBlazor\GraphRag.Net\src\GraphRag.Net.Web\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
56
</PropertyGroup>
67
</Project>

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public async Task InsertGraphDataAsync(string index, string input)
180180
var node1 = _nodes_Repositories.GetFirst(p => p.Id == memory.Metadata.Id);
181181
string text1 = $"Name:{node1.Name};Type:{node1.Type};Desc:{node1.Desc}";
182182
var relationShipJson = await _semanticService.GetRelationship(text1, text2);
183+
183184
var relationShip = JsonConvert.DeserializeObject<RelationShipModel>(relationShipJson);
184185
if (relationShip.IsRelationship)
185186
{
@@ -199,10 +200,6 @@ public async Task InsertGraphDataAsync(string index, string input)
199200
relationShip.Edge.Index = index;
200201
_edges_Repositories.Insert(relationShip.Edge);
201202
}
202-
else
203-
{
204-
//相同的边进行合并
205-
}
206203
}
207204
}
208205

@@ -271,7 +268,7 @@ public async Task InsertGraphDataAsync(string index, string input)
271268
}
272269
catch (Exception ex)
273270
{
274-
Console.WriteLine(ex.ToString());
271+
Console.WriteLine($"插入数据失败:{ex.ToString()}");
275272
}
276273
}
277274

src/GraphRag.Net/Utils/RepoUtils/RepoFiles.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,33 @@ internal static class RepoFiles
1212
/// <returns>The full path to samples/plugins</returns>
1313
public static string SamplePluginsPath()
1414
{
15-
string Parent = System.IO.Directory.GetCurrentDirectory();
16-
string Folder = "graphPlugins";
15+
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
16+
string folderName = "graphPlugins";
1717

18-
bool SearchPath(string pathToFind, out string result, int maxAttempts = 10)
18+
string FindPluginsDirectory(string startDir, string targetFolder)
1919
{
20-
var currDir = Path.GetFullPath(Assembly.GetExecutingAssembly().Location);
21-
bool found;
22-
do
20+
string currDir = Path.GetFullPath(startDir);
21+
const int maxAttempts = 10;
22+
23+
for (int i = 0; i < maxAttempts; i++)
2324
{
24-
result = Path.Join(currDir, pathToFind);
25-
found = Directory.Exists(result);
25+
string potentialPath = Path.Combine(currDir, targetFolder);
26+
if (Directory.Exists(potentialPath))
27+
{
28+
return potentialPath;
29+
}
30+
2631
currDir = Path.GetFullPath(Path.Combine(currDir, ".."));
27-
} while (maxAttempts-- > 0 && !found);
32+
}
2833

29-
return found;
34+
return null; // Not found after max attempts.
3035
}
3136

32-
if (!SearchPath(Parent + Path.DirectorySeparatorChar + Folder, out string path)
33-
&& !SearchPath(Folder, out path))
37+
// Check in the BaseDirectory and its parent directories
38+
string path = FindPluginsDirectory(baseDirectory, folderName)
39+
?? FindPluginsDirectory(baseDirectory + Path.DirectorySeparatorChar + folderName, folderName);
40+
41+
if (string.IsNullOrEmpty(path))
3442
{
3543
throw new AppException("Plugins directory not found. The app needs the plugins from the repo to work.");
3644
}

src/GraphRag.Net/graphPlugins/graph/create/skprompt.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
你是一个AI知识图谱生成助手,我需要生成一些节点和边的数据来构成一个图
1+
你是一个AI知识图谱生成助手,功能是根据我输入的内容生成知识图谱数据
22

3+
### 背景知识:知识图谱包含一些节点和边,其中
34
节点的数据结构包含以下字段:
45
- Id: 唯一标识符,例如 "node1"
56
- Name: 节点名称
@@ -13,10 +14,10 @@
1314

1415
输入的文本将描述节点和它们之间的关系。生成的数据应包括节点和边,并且每个节点和边的数据应以JSON格式表示。
1516

16-
### 示例输入
17+
### 示例输入
1718
大雄有5个苹果,碰到哆啦A梦给了2个,碰到静香,静香又给大雄一个,最后碰到了胖虎
1819

19-
### 示例输出,只返回JSON,不要包含markdown
20+
### 示例输出,只返回JSON,不要包含markdown
2021

2122
{
2223
"Nodes": [

src/GraphRag.Net/graphPlugins/graph/relationship/skprompt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
你是一个AI知识图谱生成助手,给定2个节点的描述,你需要确定他们是否相关
1+
你是一个AI知识图谱生成助手,给定2个节点的描述,你需要确定他们是否相关,输出json格式,不需要markdown格式。
22

33
### 示例输入
44
node1:Name:苹果;Type:Fruit;Desc:一种水果

0 commit comments

Comments
 (0)