feat: add more builtin model#588
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the system’s builtin model catalog and improves how model configuration and usage context are handled across backend pricing/usage and the web admin UI (notably adding a “Builtin Models” import flow and a model “exclude from tests” flag).
Changes:
- Web: add a Builtin Models dialog to import builtin model configs by channel type; add
exclude_from_teststo model create/edit; displaynative_resolutionin logs. - Core: significantly expand builtin model lists (OpenAI/Gemini/Anthropic), refine conditional price selection (specificity-based), and extend usage context with
native_resolutionfor pricing/telemetry. - Tests: add/extend resolution-matching matrices and conditional pricing selection behaviors.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/validation/model.ts | Adds exclude_from_tests to the model create form schema. |
| web/src/types/log.ts | Extends log usage context typing with native_resolution. |
| web/src/feature/model/hooks.ts | Adds useChannelBuiltinModels query hook. |
| web/src/feature/model/components/ModelTable.tsx | Adds UI trigger + state wiring for the builtin models dialog and “create from builtin” flow. |
| web/src/feature/model/components/ModelForm.tsx | Adds exclude_from_tests field; refactors create payload to use formData merge logic. |
| web/src/feature/model/components/ModelDialog.tsx | Adds preserveModelNameOnCreate option and passes base config for create-from-copy/builtin scenarios. |
| web/src/feature/model/components/BuiltinModelsDialog.tsx | New dialog to browse/filter/select builtin models and import/create from selection. |
| web/src/feature/log/components/ExpandedLogContent.tsx | Displays native_resolution in billing context panel. |
| web/src/api/model.ts | Adds getChannelBuiltinModels API call and response typing. |
| web/public/locales/zh/translation.json | Adds i18n strings for builtin models dialog + exclude-from-tests + native resolution label. |
| web/public/locales/en/translation.json | Adds i18n strings for builtin models dialog + exclude-from-tests + native resolution label. |
| core/relay/controller/video_test.go | Adds resolution validation/usage matrix tests for video flows. |
| core/relay/controller/image_test.go | Adds resolution validation matrix tests for image flows. |
| core/relay/adaptor/vertexai/adaptor_test.go | Updates async usage context expectations to include native/protocol resolution split. |
| core/relay/adaptor/openai/reasoning_test.go | Adjusts reasoning effort assertions for responses-only models in chat mode. |
| core/relay/adaptor/openai/constants.go | Expands OpenAI builtin models + pricing; updates responses-only model detection map. |
| core/relay/adaptor/gemini/video.go | Tracks native vs protocol resolution in metadata/usage context; updates stored metadata fields. |
| core/relay/adaptor/gemini/video_test.go | Updates expectations for resolution vs native resolution throughout video tests. |
| core/relay/adaptor/gemini/image.go | Derives fallback image output tokens based on model/size context when upstream usage metadata is absent. |
| core/relay/adaptor/gemini/image_test.go | Updates image usage token expectations for new fallback token logic. |
| core/relay/adaptor/gemini/constants.go | Adds/updates Gemini builtin models and pricing; adjusts cached and media pricing values. |
| core/relay/adaptor/gemini/constants_test.go | Updates pricing test expectations for revised image token assumptions. |
| core/relay/adaptor/gemini/async_usage.go | Sets NativeResolution and computes protocol resolution for async usage. |
| core/relay/adaptor/cloudflare/constant.go | Replaces Cloudflare builtin model list with an empty list. |
| core/relay/adaptor/anthropic/constants.go | Adds many Anthropic builtin models + pricing metadata. |
| core/model/usage.go | Adds NativeResolution; improves condition normalization; specificity-based conditional price selection. |
| core/model/usage_test.go | Updates/expands tests for conditional price specificity/ordering and resolution normalization. |
| core/common/consume/consume_test.go | Adds tests ensuring “more specific service tier wins” in conditional pricing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+5
| import "github.com/labring/aiproxy/core/model" | ||
|
|
||
| var ModelList = []model.ModelConfig{ | ||
| { | ||
| Model: "@cf/meta/llama-3.1-8b-instruct", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@cf/meta/llama-2-7b-chat-fp16", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@cf/meta/llama-2-7b-chat-int8", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@cf/mistral/mistral-7b-instruct-v0.1", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/deepseek-coder-6.7b-base-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerDeepSeek, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/deepseek-coder-6.7b-instruct-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerDeepSeek, | ||
| }, | ||
| { | ||
| Model: "@cf/deepseek-ai/deepseek-math-7b-base", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerDeepSeek, | ||
| }, | ||
| { | ||
| Model: "@cf/deepseek-ai/deepseek-math-7b-instruct", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerDeepSeek, | ||
| }, | ||
| { | ||
| Model: "@cf/google/gemma-2b-it-lora", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerGoogle, | ||
| }, | ||
| { | ||
| Model: "@hf/google/gemma-7b-it", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerGoogle, | ||
| }, | ||
| { | ||
| Model: "@cf/google/gemma-7b-it-lora", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerGoogle, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/llama-2-13b-chat-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@cf/meta-llama/llama-2-7b-chat-hf-lora", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@cf/meta/llama-3-8b-instruct", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/llamaguard-7b-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/mistral-7b-instruct-v0.1-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@hf/mistralai/mistral-7b-instruct-v0.2", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@cf/mistral/mistral-7b-instruct-v0.2-lora", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/neural-chat-7b-v3-1-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@cf/openchat/openchat-3.5-0106", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerOpenChat, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/openhermes-2.5-mistral-7b-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| { | ||
| Model: "@cf/microsoft/phi-2", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMicrosoft, | ||
| }, | ||
| { | ||
| Model: "@cf/qwen/qwen1.5-0.5b-chat", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerAlibaba, | ||
| }, | ||
| { | ||
| Model: "@cf/qwen/qwen1.5-1.8b-chat", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerAlibaba, | ||
| }, | ||
| { | ||
| Model: "@cf/qwen/qwen1.5-14b-chat-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerAlibaba, | ||
| }, | ||
| { | ||
| Model: "@cf/qwen/qwen1.5-7b-chat-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerAlibaba, | ||
| }, | ||
| { | ||
| Model: "@cf/defog/sqlcoder-7b-2", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerDefog, | ||
| }, | ||
| { | ||
| Model: "@hf/nexusflow/starling-lm-7b-beta", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerNexusFlow, | ||
| }, | ||
| { | ||
| Model: "@cf/tinyllama/tinyllama-1.1b-chat-v1.0", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMeta, | ||
| }, | ||
| { | ||
| Model: "@hf/thebloke/zephyr-7b-beta-awq", | ||
| Type: mode.ChatCompletions, | ||
| Owner: model.ModelOwnerMistral, | ||
| }, | ||
| } | ||
| var ModelList = []model.ModelConfig{} |
| <button | ||
| type="button" | ||
| className="flex h-5 w-5 items-center justify-center rounded border border-input bg-background disabled:cursor-not-allowed disabled:opacity-50" | ||
| disabled={filteredRows.length === 0} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.