fix: models api return models in deactivate channels #2150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
/v1/models
这个接口,本来应该返回用户有权限且激活的 models,但实际上,如果在未激活的 channel 里存在和激活的 channel 同名的 models,这些未激活的 models 也会被返回。原因在于 one-api 里都是通过 model name 来存储元数据和匹配的,无法区分是否来自于激活的 channel。
修改
在匹配 model 时,改用
model_name:adaptor_name
的形式来匹配。自测
仅有 vertex 激活时,不会再错误的返回 gemini 的 models