Skip to content

Conversation

@intelliking
Copy link

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?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Issue: #1198

@intelliking
Copy link
Author

@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
Copy link
Collaborator

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
Copy link
Collaborator

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("-", "_")
Copy link
Collaborator

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

Copy link
Collaborator

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("-", "_")?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@intelliking
Copy link
Author

@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]] = {
Copy link
Collaborator

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("-", "_")
Copy link
Collaborator

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 = {
Copy link
Collaborator

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(
Copy link
Collaborator

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

.catch((err) => {
console.error('Failed to fetch model type suggestions:', err);
// Cache empty array to avoid retrying on every render
suggestionsCache[cacheKey] = [];
Copy link
Collaborator

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("-", "_")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source = "camel"

# Platform name → model name prefixes for filtering
PLATFORM_PREFIXES: dict[str, list[str]] = {
Copy link
Collaborator

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?


const stateClasses =
state === 'error'
? 'border-input-border-cuation bg-input-bg-default'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

className={cn(
'mt-1.5 !text-body-xs',
state === 'error'
? 'text-text-cuation'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

… 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
@intelliking
Copy link
Author

@bytecii @Zephyroam Thanks for your feedback. I updated all according to your feedback. could you review again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support suggesting model type setting in model configuration

4 participants