mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-12 11:23:42 +08:00
fix: Refactor AWS Adapter for Improved Model Mapping and Error Handling
* Refactor AWS adapter to improve model management - Replace hardcoded model list in `adapter.go` with a function to get models from `awsModelIDMap` - Update `GetModelList` function to return model list directly - Add `GetChannelName` function to get channel name from `Adaptor` object * Improve error handling and code organization in main.go - Replace switch statement with a map to map AWS model IDs to OpenAI model IDs - Return an error if the model is not found in the map - Use a single return statement instead of wrapping multiple return statements in the `awsModelID` function - Add a new error message for when the model is not found in the map in the `Handler` function
This commit is contained in:
@@ -62,15 +62,12 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Met
|
||||
return
|
||||
}
|
||||
|
||||
// https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html
|
||||
var ModelList = []string{
|
||||
"claude-3-haiku-20240307",
|
||||
"claude-3-sonnet-20240229",
|
||||
"claude-3-opus-20240229",
|
||||
}
|
||||
func (a *Adaptor) GetModelList() (models []string) {
|
||||
for n := range awsModelIDMap {
|
||||
models = append(models, n)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetModelList() []string {
|
||||
return ModelList
|
||||
return
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetChannelName() string {
|
||||
|
||||
Reference in New Issue
Block a user