-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add model type autocomplete with api based suggestions and plat… #1204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add model type autocomplete with api based suggestions and plat… #1204
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| all_model_types = [mt.value for mt in ModelType] | ||
|
|
||
| if platform: | ||
| platform_lower = platform.lower().replace("-", "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not match with the PLATFORM_PREFIXES for example for the openai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we need .replace("-", "_")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
src/components/ui/combobox.tsx
Outdated
| className={cn( | ||
| 'mt-1.5 !text-body-xs', | ||
| state === 'error' | ||
| ? 'text-text-cuation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
…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? |
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