From 90780f636213165ec2ead3320579210a8274f85c Mon Sep 17 00:00:00 2001 From: Cold <16419454+cold502@user.noreply.gitee.com> Date: Wed, 3 Dec 2025 10:09:00 +0800 Subject: [PATCH] =?UTF-8?q?ragflow=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ragflow/client.go | 25 ++++--------------------- ragflow/config.yaml | 10 ---------- 2 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 ragflow/config.yaml diff --git a/ragflow/client.go b/ragflow/client.go index bdbcd39..95ef503 100644 --- a/ragflow/client.go +++ b/ragflow/client.go @@ -11,7 +11,6 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gclient" - "github.com/gogf/gf/v2/os/gcfg" ) var ( @@ -28,7 +27,7 @@ func init() { // 如果配置不完整,跳过初始化 if baseURL == "" || apiKey == "" { - g.Log().Warning(ctx, "⚠️ RAGFlow 配置未找到,请在 common/ragflow/config.yaml 中配置") + g.Log().Warning(ctx, "⚠️ RAGFlow 配置未找到,请在项目 config.yml 中添加 ragflow.base_url 和 ragflow.api_key") return } @@ -48,25 +47,9 @@ func init() { // loadConfig 从配置文件加载 RAGFlow 配置 func loadConfig(ctx context.Context) (baseURL, apiKey string) { - // 创建配置实例 - cfg, err := gcfg.New() - if err != nil { - g.Log().Debugf(ctx, "创建配置实例失败: %v", err) - return "", "" - } - - // 设置配置文件 - adapter, ok := cfg.GetAdapter().(*gcfg.AdapterFile) - if !ok { - g.Log().Debug(ctx, "配置适配器类型不匹配") - return "", "" - } - - adapter.SetFileName("config.yaml") - - // 读取配置项 - baseURL = cfg.MustGet(ctx, "ragflow.base_url").String() - apiKey = cfg.MustGet(ctx, "ragflow.api_key").String() + // 使用 GoFrame 全局配置(从项目的 config.yml 读取) + baseURL = g.Cfg().MustGet(ctx, "ragflow.base_url", "").String() + apiKey = g.Cfg().MustGet(ctx, "ragflow.api_key", "").String() return baseURL, apiKey } diff --git a/ragflow/config.yaml b/ragflow/config.yaml deleted file mode 100644 index 95c7e13..0000000 --- a/ragflow/config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# RAGFlow 配置文件 -# 用于全局客户端自动初始化 - -ragflow: - # RAGFlow 服务地址 - base_url: "http://localhost:9380" - - # RAGFlow API Key - # 获取方式:登录 RAGFlow 管理界面 -> 设置 -> API Keys - api_key: "ragflow-your-api-key-here"