ragflow配置
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user