feat: integrate ChatBot provider and docreader
This commit is contained in:
@@ -28,6 +28,8 @@ type TenantService interface {
|
||||
SearchTenants(ctx context.Context, keyword string, tenantID uint64, page, pageSize int) ([]*types.Tenant, int64, error)
|
||||
// GetTenantByIDForUser gets a tenant by ID with permission check
|
||||
GetTenantByIDForUser(ctx context.Context, tenantID uint64, userID string) (*types.Tenant, error)
|
||||
// GetTenantByAPIKey gets a tenant by API key
|
||||
GetDocreaderCredentials(ctx context.Context) *types.DocreaderCredentials
|
||||
}
|
||||
|
||||
// TenantRepository defines the tenant repository interface
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package interfaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
// WeKnoraCloudService 处理 WeKnoraCloud 厂商的初始化逻辑
|
||||
type WeKnoraCloudService interface {
|
||||
Initialize(ctx context.Context, appID, appSecret string) (*types.InitializeResult, error)
|
||||
// CheckStatus 检查当前租户的 WeKnoraCloud 凭证是否可正常解密
|
||||
// needsReinit=true 表示加密状态已损坏(salt 变更等),需要用户重新填写凭证
|
||||
CheckStatus(ctx context.Context) (*types.WeKnoraCloudStatusResult, error)
|
||||
}
|
||||
@@ -68,6 +68,9 @@ type ModelParameters struct {
|
||||
Provider string `yaml:"provider" json:"provider"` // Provider identifier: openai, aliyun, zhipu, generic
|
||||
ExtraConfig map[string]string `yaml:"extra_config" json:"extra_config"` // Provider-specific configuration
|
||||
SupportsVision bool `yaml:"supports_vision" json:"supports_vision"` // Whether the model accepts image/multimodal input
|
||||
// WeKnoraCloud 厂商专用凭证
|
||||
AppID string `yaml:"app_id,omitempty" json:"app_id,omitempty"`
|
||||
AppSecret string `yaml:"app_secret,omitempty" json:"app_secret,omitempty"` // AES-256 加密存储,实际承载上游 API Key
|
||||
}
|
||||
|
||||
// Model represents the AI model
|
||||
|
||||
@@ -233,7 +233,11 @@ 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"` // 文档解析服务地址
|
||||
DocReaderAddr string `json:"docreader_addr"` // 文档解析服务地址
|
||||
// docreader 凭证
|
||||
DocreaderAppID string `json:"docreader_app_id,omitempty"`
|
||||
DocreaderAPIKey string `json:"docreader_api_key,omitempty"`
|
||||
|
||||
MinerUEndpoint string `json:"mineru_endpoint"` // MinerU 自建服务端点
|
||||
MinerUAPIKey string `json:"mineru_api_key"` // MinerU 云 API Key
|
||||
|
||||
@@ -259,6 +263,9 @@ func (c *ParserEngineConfig) ToOverridesMap() map[string]string {
|
||||
return nil
|
||||
}
|
||||
m := make(map[string]string)
|
||||
if c.DocReaderAddr != "" {
|
||||
m["docreader_addr"] = c.DocReaderAddr
|
||||
}
|
||||
if c.MinerUEndpoint != "" {
|
||||
m["mineru_endpoint"] = c.MinerUEndpoint
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package types
|
||||
|
||||
// WeKnoraCloudStatusResult 状态检查结果
|
||||
type WeKnoraCloudStatusResult struct {
|
||||
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