61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package agent
|
|
|
|
type ChatMessage struct {
|
|
Role string
|
|
Contents []ChatMessageContent
|
|
}
|
|
|
|
type ChatMessageContent struct {
|
|
Type string // text, image, audio, video
|
|
Content string
|
|
}
|
|
|
|
type ChatModelConfig struct {
|
|
defaultConfig *ChatModelConfig
|
|
Model string
|
|
Ratio float64
|
|
MaxTokens int
|
|
Temperature float64
|
|
TopP float64
|
|
Tools map[string]any
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) SetDefault(config *ChatModelConfig) {
|
|
cmc.defaultConfig = config
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) GetModel() string {
|
|
if cmc.Model == "" && cmc.defaultConfig != nil {
|
|
return cmc.defaultConfig.Model
|
|
}
|
|
return cmc.Model
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) GetMaxTokens() int {
|
|
if cmc.MaxTokens == 0 && cmc.defaultConfig != nil {
|
|
return cmc.defaultConfig.MaxTokens
|
|
}
|
|
return cmc.MaxTokens
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) GetTemperature() float64 {
|
|
if cmc.Temperature == 0 && cmc.defaultConfig != nil {
|
|
return cmc.defaultConfig.Temperature
|
|
}
|
|
return cmc.Temperature
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) GetTopP() float64 {
|
|
if cmc.TopP == 0 && cmc.defaultConfig != nil {
|
|
return cmc.defaultConfig.TopP
|
|
}
|
|
return cmc.TopP
|
|
}
|
|
|
|
func (cmc *ChatModelConfig) GetTools() map[string]any {
|
|
if cmc.Tools == nil && cmc.defaultConfig != nil {
|
|
return cmc.defaultConfig.Tools
|
|
}
|
|
return cmc.Tools
|
|
}
|