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.
 
 
 
 
 
 

43 lines
1.3 KiB

package doubao
import "context"
type (
Message struct {
Role string `json:"role"`
Content string `json:"content"`
// Images 可选图片 url 列表:非空时以多模态格式(text + image_url)发送,用于豆包视觉模型。
// 为空时按纯文本发送,行为不变。
Images []string `json:"images,omitempty"`
}
//回应流式切片
ChatResponseChoice struct {
Role string `json:"role"`
Content string `json:"content,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
ISys interface {
Chat(ctx context.Context, msgs []Message) (result *ChatResponseChoice, err error)
ChatForSteams(ctx context.Context, msgs []Message, choiceChan chan *ChatResponseChoice) (err error)
}
)
var defsys ISys
func OnInit(config map[string]interface{}, option ...Option) (err error) {
defsys, err = newSys(newOptions(config, option...))
return
}
func NewSys(option ...Option) (sys ISys, err error) {
sys, err = newSys(newOptionsByOption(option...))
return
}
func Chat(ctx context.Context, msgs []Message) (result *ChatResponseChoice, err error) {
return defsys.Chat(ctx, msgs)
}
func ChatForSteams(ctx context.Context, msgs []Message, choiceChan chan *ChatResponseChoice) (err error) {
return defsys.ChatForSteams(ctx, msgs, choiceChan)
}