ragflow配置

This commit is contained in:
Cold
2025-12-03 10:09:00 +08:00
committed by 张斌
parent 15b781e2e4
commit 90780f6362
2 changed files with 4 additions and 31 deletions

View File

@@ -11,7 +11,6 @@ import (
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/gclient" "github.com/gogf/gf/v2/net/gclient"
"github.com/gogf/gf/v2/os/gcfg"
) )
var ( var (
@@ -28,7 +27,7 @@ func init() {
// 如果配置不完整,跳过初始化 // 如果配置不完整,跳过初始化
if baseURL == "" || apiKey == "" { 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 return
} }
@@ -48,25 +47,9 @@ func init() {
// loadConfig 从配置文件加载 RAGFlow 配置 // loadConfig 从配置文件加载 RAGFlow 配置
func loadConfig(ctx context.Context) (baseURL, apiKey string) { func loadConfig(ctx context.Context) (baseURL, apiKey string) {
// 创建配置实例 // 使用 GoFrame 全局配置(从项目的 config.yml 读取)
cfg, err := gcfg.New() baseURL = g.Cfg().MustGet(ctx, "ragflow.base_url", "").String()
if err != nil { apiKey = g.Cfg().MustGet(ctx, "ragflow.api_key", "").String()
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()
return baseURL, apiKey return baseURL, apiKey
} }

View File

@@ -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"