feat(weknoracloud): implement credential management and status checks
- Introduced a new WeKnoraCloudSettings component for managing APPID and APPSECRET. - Added functionality to save WeKnoraCloud credentials without automatically creating models. - Implemented credential status checks across various components to provide user feedback on configuration status. - Updated API endpoints to handle credential saving and status retrieval. - Enhanced UI elements to guide users in configuring WeKnoraCloud settings. This update improves the integration of WeKnoraCloud by allowing users to manage their credentials more effectively and receive real-time feedback on their configuration status.
This commit is contained in:
@@ -6,9 +6,10 @@ import (
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
// WeKnoraCloudService 处理 WeKnoraCloud 厂商的初始化逻辑
|
||||
// WeKnoraCloudService 处理 WeKnoraCloud 凭证管理
|
||||
type WeKnoraCloudService interface {
|
||||
Initialize(ctx context.Context, appID, appSecret string) (*types.InitializeResult, error)
|
||||
// SaveCredentials 仅保存 APPID/APPSECRET 凭证到租户配置,不自动创建模型
|
||||
SaveCredentials(ctx context.Context, appID, appSecret string) error
|
||||
// CheckStatus 检查当前租户的 WeKnoraCloud 凭证是否可正常解密
|
||||
// needsReinit=true 表示加密状态已损坏(salt 变更等),需要用户重新填写凭证
|
||||
CheckStatus(ctx context.Context) (*types.WeKnoraCloudStatusResult, error)
|
||||
|
||||
@@ -233,7 +233,6 @@ func (c *ConversationConfig) Scan(value interface{}) error {
|
||||
// ParserEngineConfig holds tenant-level overrides for document parser engines (e.g. MinerU endpoint, API key).
|
||||
// These values take precedence over environment variables when parsing documents.
|
||||
type ParserEngineConfig struct {
|
||||
DocReaderAddr string `json:"docreader_addr"` // 文档解析服务地址
|
||||
// docreader 凭证
|
||||
DocreaderAppID string `json:"docreader_app_id,omitempty"`
|
||||
DocreaderAPIKey string `json:"docreader_api_key,omitempty"`
|
||||
@@ -263,8 +262,8 @@ func (c *ParserEngineConfig) ToOverridesMap() map[string]string {
|
||||
return nil
|
||||
}
|
||||
m := make(map[string]string)
|
||||
if c.DocReaderAddr != "" {
|
||||
m["docreader_addr"] = c.DocReaderAddr
|
||||
if c.DocreaderAppID != "" {
|
||||
m["docreader_app_id"] = c.DocreaderAppID
|
||||
}
|
||||
if c.MinerUEndpoint != "" {
|
||||
m["mineru_endpoint"] = c.MinerUEndpoint
|
||||
|
||||
@@ -2,23 +2,11 @@ package types
|
||||
|
||||
// WeKnoraCloudStatusResult 状态检查结果
|
||||
type WeKnoraCloudStatusResult struct {
|
||||
HasModels bool `json:"has_models"` // 是否已配置 WeKnoraCloud 模型
|
||||
HasModels bool `json:"has_models"` // 是否已配置 WeKnoraCloud 凭证
|
||||
NeedsReinit bool `json:"needs_reinit"` // 是否需要重新初始化(凭证损坏)
|
||||
Reason string `json:"reason,omitempty"` // 需要重新初始化的原因
|
||||
}
|
||||
|
||||
// InitializeResult 返回每个模型的操作结果
|
||||
type InitializeResult struct {
|
||||
Models []ModelAction `json:"models"`
|
||||
}
|
||||
|
||||
// ModelAction 单个模型的操作结果
|
||||
type ModelAction struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Action string `json:"action"` // "created" | "updated"
|
||||
}
|
||||
|
||||
type DocreaderCredentials struct {
|
||||
AppID string
|
||||
APIKey string
|
||||
|
||||
Reference in New Issue
Block a user