Skip to content

Commit

Permalink
fix 优化命名空间
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzeyu91 committed Aug 13, 2024
1 parent 2ed9468 commit 5816593
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 15 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.13</Version>
<Version>0.1.14</Version>
<SKVersion>1.17.1</SKVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dotnet add package GraphRag.Net
添加包以后,需要进行配置文件的设置以及依赖注入
```
//OpenAI配置
builder.Configuration.GetSection("OpenAI").Get<OpenAIOption>();
builder.Configuration.GetSection("GraphOpenAI").Get<GraphOpenAIOption>();
//文档切片配置
builder.Configuration.GetSection("TextChunker").Get<TextChunkerOption>();
//配置数据库链接
Expand Down
3 changes: 1 addition & 2 deletions src/GraphRag.Net.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AntDesign.ProLayout;
using GraphRag.Net;
using GraphRag.Net.Common.Options;
using GraphRag.Net.Options;
using GraphRag.Net.Web.Mock;
using Microsoft.AspNetCore.Components;
Expand Down Expand Up @@ -34,7 +33,7 @@
c.IncludeXmlComments(xmlPath, true);
});

builder.Configuration.GetSection("OpenAI").Get<OpenAIOption>();
builder.Configuration.GetSection("GraphOpenAI").Get<GraphOpenAIOption>();
builder.Configuration.GetSection("TextChunker").Get<TextChunkerOption>();
//builder.Configuration.GetSection("GraphDBConnection").Get<GraphDBConnectionOption>();

Expand Down
2 changes: 1 addition & 1 deletion src/GraphRag.Net.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"MenuHeaderRender": true,
"HeaderHeight": 48
},
"OpenAI": {
"GraphOpenAI": {
"Key": "你的秘钥",
"Endpoint": "https://api.antsk.cn/",
"ChatModel": "gpt-4o",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace GraphRag.Net.Options
{
public class OpenAIOption
public class GraphOpenAIOption
{
public static string Endpoint { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/GraphRag.Net/Domain/Service/GraphService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GraphRag.Net.Common.Options;
using GraphRag.Net.Options;
using GraphRag.Net.Domain.Interface;
using GraphRag.Net.Domain.Model.Constant;
using GraphRag.Net.Domain.Model.Graph;
Expand Down
5 changes: 2 additions & 3 deletions src/GraphRag.Net/Domain/Service/SemanticService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Azure.AI.OpenAI;
using GraphRag.Net.Common.Options;
using GraphRag.Net.Domain.Interface;
using GraphRag.Net.Options;
using GraphRag.Net.Domain.Interface;
using GraphRag.Net.Utils;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
Expand Down Expand Up @@ -180,7 +179,7 @@ public async Task<SemanticTextMemory> GetTextMemory()
var handler = new OpenAIHttpClientHandler();
var httpClient = new HttpClient(handler);
httpClient.Timeout = TimeSpan.FromMinutes(10);
var embeddingGenerator = new OpenAITextEmbeddingGenerationService(OpenAIOption.EmbeddingModel, OpenAIOption.Key, httpClient: new HttpClient(handler));
var embeddingGenerator = new OpenAITextEmbeddingGenerationService(GraphOpenAIOption.EmbeddingModel, GraphOpenAIOption.Key, httpClient: new HttpClient(handler));
SemanticTextMemory textMemory = new(memoryStore, embeddingGenerator);

return textMemory;
Expand Down
6 changes: 3 additions & 3 deletions src/GraphRag.Net/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;
using GraphRag.Net;
using GraphRag.Net.Common.Options;
using GraphRag.Net.Options;
using GraphRag.Net.Repositories;
using GraphRag.Net.Utils;
using Microsoft.SemanticKernel;
Expand Down Expand Up @@ -69,8 +69,8 @@ static void InitSK(IServiceCollection services,Kernel _kernel = null)
{
_kernel = Kernel.CreateBuilder()
.AddOpenAIChatCompletion(
modelId: OpenAIOption.ChatModel,
apiKey: OpenAIOption.Key,
modelId: GraphOpenAIOption.ChatModel,
apiKey: GraphOpenAIOption.Key,
httpClient: new HttpClient(handler)
)
.Build();
Expand Down
4 changes: 2 additions & 2 deletions src/GraphRag.Net/Utils/OpenAIHttpClientHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GraphRag.Net.Common.Options;
using GraphRag.Net.Options;
using System.Text;
using System.Text.RegularExpressions;

Expand All @@ -12,7 +12,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
UriBuilder uriBuilder;
Regex regex = new Regex(@"(https?)://([^/:]+)(:\d+)?/(.*)");
Match match = regex.Match(OpenAIOption.Endpoint);
Match match = regex.Match(GraphOpenAIOption.Endpoint);

var mediaType = request.Content.Headers.ContentType.MediaType;
string requestBody = (await request.Content.ReadAsStringAsync()).Unescape();
Expand Down

0 comments on commit 5816593

Please sign in to comment.