You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.3 KiB

package filetrans
import (
"yunyan/lego/sys/log"
"yunyan/lego/utils/mapstructure"
)
type Option func(*Options)
type Options struct {
Debug bool
Log log.ILogger
ApiKey string // 百炼 API Key(sk-xxx)
// WorkspaceId 百炼工作空间 ID(ws-xxx)。填了走新模型 qwen-audio-3.0-asr-flash-filetrans
// (端点 https://<ws>.cn-beijing.maas.aliyuncs.com,支持 27 个语种);
// 留空则兼容存量配置,退回老端点 dashscope.aliyuncs.com + paraformer-v2(仅 8 个语种)。
// 两种模式的语种支持范围不同,见 filetrans.go 的 modelLangs。
WorkspaceId string
}
func SetApiKey(v string) Option {
return func(o *Options) {
o.ApiKey = v
}
}
func SetWorkspaceId(v string) Option {
return func(o *Options) {
o.WorkspaceId = v
}
}
func newOptions(config map[string]interface{}, opts ...Option) Options {
options := Options{}
if config != nil {
mapstructure.Decode(config, &options)
}
for _, o := range opts {
o(&options)
}
if options.Log == nil {
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.ali_filetrans", 3))
}
return options
}
func newOptionsByOption(opts ...Option) Options {
options := Options{}
for _, o := range opts {
o(&options)
}
if options.Log == nil {
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.ali_filetrans", 3))
}
return options
}