feat: add model type autocomplete with api based suggestions and plat…#1204
feat: add model type autocomplete with api based suggestions and plat…#1204intelliking wants to merge 5 commits intoeigent-ai:mainfrom
Conversation
|
@lightaime @Wendong-Fan @eureka928 Please review my first PR. I would really appreciate your feedback. Thank you |
| If api_key is provided for OpenAI-compatible platforms, | ||
| also fetches available models from the API. | ||
| """ | ||
| from camel.types import ModelType |
There was a problem hiding this comment.
import at the top of the file
| platform_lower = (platform or "").lower().replace("-", "_") | ||
| if api_key and platform_lower in openai_like: | ||
| try: | ||
| import httpx |
| all_model_types = [mt.value for mt in ModelType] | ||
|
|
||
| if platform: | ||
| platform_lower = platform.lower().replace("-", "_") |
There was a problem hiding this comment.
This seems not match with the PLATFORM_PREFIXES for example for the openai
There was a problem hiding this comment.
Any reason why we need .replace("-", "_")?
There was a problem hiding this comment.
platform_lower is calc twice, the other time is at https://github.com/eigent-ai/eigent/pull/1204/changes#diff-eaaca13f9e3defe932ff766fdf47ab89c4ea0163bbd21bad80fc94f82b22e4a8R273
…t/model-type-suggestions-combobox
…inconsistencies in model_controller.py
|
@bytecii Thanks for your feedback! I fixed all. Could you please review again? |
| source = "camel" | ||
|
|
||
| # Platform name → model name prefixes for filtering | ||
| PLATFORM_PREFIXES: dict[str, list[str]] = { |
There was a problem hiding this comment.
Rename to MODEL_PREFIXES?
| all_model_types = [mt.value for mt in ModelType] | ||
|
|
||
| if platform: | ||
| platform_lower = platform.lower().replace("-", "_") |
There was a problem hiding this comment.
Any reason why we need .replace("-", "_")?
| # For OpenAI-compatible platforms with an API key, | ||
| # also fetch live models from the API | ||
| # Note: platform names are normalized (lowercase, hyphens → underscores) | ||
| openai_like = { |
There was a problem hiding this comment.
Let's define them as types some where?
| platform_lower = (platform or "").lower().replace("-", "_") | ||
| if api_key and platform_lower in openai_like: | ||
| try: | ||
| api_base_url = (api_url or "https://api.openai.com/v1").rstrip( |
There was a problem hiding this comment.
Also define the api url as some constants somewhere
src/components/ModelTypeCombobox.tsx
Outdated
| .catch((err) => { | ||
| console.error('Failed to fetch model type suggestions:', err); | ||
| // Cache empty array to avoid retrying on every render | ||
| suggestionsCache[cacheKey] = []; |
There was a problem hiding this comment.
When meet network instability, there is no way to retry.
| all_model_types = [mt.value for mt in ModelType] | ||
|
|
||
| if platform: | ||
| platform_lower = platform.lower().replace("-", "_") |
There was a problem hiding this comment.
platform_lower is calc twice, the other time is at https://github.com/eigent-ai/eigent/pull/1204/changes#diff-eaaca13f9e3defe932ff766fdf47ab89c4ea0163bbd21bad80fc94f82b22e4a8R273
| source = "camel" | ||
|
|
||
| # Platform name → model name prefixes for filtering | ||
| PLATFORM_PREFIXES: dict[str, list[str]] = { |
There was a problem hiding this comment.
Could you move it to module level?
src/components/ui/combobox.tsx
Outdated
|
|
||
| const stateClasses = | ||
| state === 'error' | ||
| ? 'border-input-border-cuation bg-input-bg-default' |
src/components/ui/combobox.tsx
Outdated
| className={cn( | ||
| 'mt-1.5 !text-body-xs', | ||
| state === 'error' | ||
| ? 'text-text-cuation' |
…t/model-type-suggestions-combobox
… fix duplicate platform normalization, rename PLATFORM_PREFIXES to MODEL_PREFIXES, fix typos cuation to caution in combobox, and remove error caching to allow network retry
|
@bytecii @Zephyroam Thanks for your feedback. I updated all according to your feedback. could you review again? |
|
@Wendong-Fan @bytecii Would you please review this PR? thank you. |
Description
Support suggesting model types in model configuration. When configuring an AI model provider, the model type field now shows a searchable dropdown with all available model types from CAMEL enum, filtered by platform. For OpenAI-compatible platforms with an API key, live models are also fetched from the API and merged into suggestions.
What is the purpose of this pull request?
Issue: #1198