feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user