mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-12 19:33:41 +08:00
feat: Map channel model changes to ability mappings
Fix: Add model mappings to a channel's abilities - Add model mappings to a channel's abilities. - Add model mapping unit tests.
This commit is contained in:
@@ -55,6 +55,21 @@ func (channel *Channel) AddAbilities() error {
|
||||
abilities = append(abilities, ability)
|
||||
}
|
||||
}
|
||||
|
||||
// add model mappings
|
||||
for model := range channel.GetModelMapping() {
|
||||
for _, group := range groups_ {
|
||||
ability := Ability{
|
||||
Group: group,
|
||||
Model: model,
|
||||
ChannelId: channel.Id,
|
||||
Enabled: channel.Status == common.ChannelStatusEnabled,
|
||||
Priority: channel.Priority,
|
||||
}
|
||||
abilities = append(abilities, ability)
|
||||
}
|
||||
}
|
||||
|
||||
return DB.Create(&abilities).Error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user