feat(dingtalk): enable secure multimodal image QA

This commit is contained in:
姚章浩
2026-07-16 00:17:16 +08:00
parent 4022040e98
commit c9c4f0aaa5
59 changed files with 3279 additions and 429 deletions
+36 -17
View File
@@ -98,14 +98,27 @@ type Chat interface {
GetModelID() string
}
type imageInputCapable interface {
SupportsImageInput() bool
}
// SupportsImageInput reports whether the concrete Chat transport can preserve
// image input. Unknown implementations fail closed instead of trusting model
// metadata alone.
func SupportsImageInput(model Chat) bool {
capable, ok := model.(imageInputCapable)
return ok && capable.SupportsImageInput()
}
type ChatConfig struct {
Source types.ModelSource
BaseURL string
ModelName string
APIKey string
ModelID string
Provider string
ExtraConfig map[string]string
Source types.ModelSource
BaseURL string
ModelName string
APIKey string
ModelID string
Provider string
SupportsVision bool
ExtraConfig map[string]string
// CustomHeaders 允许在调用远程 OpenAI 兼容 API 时附加自定义 HTTP 请求头(类似 OpenAI Python SDK 的 extra_headers)。
CustomHeaders map[string]string
AppID string
@@ -120,17 +133,23 @@ func ConfigFromModel(m *types.Model, appID, appSecret string) *ChatConfig {
if m == nil {
return nil
}
supportsVision := m.Parameters.SupportsVision
if provider.ProviderName(m.Parameters.Provider) == provider.ProviderWeKnoraCloud &&
m.Type == types.ModelTypeKnowledgeQA && strings.EqualFold(strings.TrimSpace(m.Name), "chat") {
supportsVision = true
}
return &ChatConfig{
ModelID: m.ID,
APIKey: m.Parameters.APIKey,
BaseURL: m.Parameters.BaseURL,
ModelName: m.Name,
Source: m.Source,
Provider: m.Parameters.Provider,
ExtraConfig: m.Parameters.ExtraConfig,
CustomHeaders: m.Parameters.CustomHeaders,
AppID: appID,
AppSecret: appSecret,
ModelID: m.ID,
APIKey: m.Parameters.APIKey,
BaseURL: m.Parameters.BaseURL,
ModelName: m.Name,
Source: m.Source,
Provider: m.Parameters.Provider,
SupportsVision: supportsVision,
ExtraConfig: m.Parameters.ExtraConfig,
CustomHeaders: m.Parameters.CustomHeaders,
AppID: appID,
AppSecret: appSecret,
}
}