Skip to content
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

Support str like behaviour for ModelPlatformType like ModelType to simplify interface #1681

Open
lightaime opened this issue Mar 2, 2025 · 0 comments · May be fixed by #1699
Open

Support str like behaviour for ModelPlatformType like ModelType to simplify interface #1681

lightaime opened this issue Mar 2, 2025 · 0 comments · May be fixed by #1699
Assignees
Labels
Agent Related to camel agents Model Related to backend models
Milestone

Comments

@lightaime
Copy link
Member

lightaime commented Mar 2, 2025

The goal is to simplify interface to enable creating a ChatAgent with one line of code.

The currect interface for create a ChatAgent with a model is like this:

from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.agents import ChatAgent

# Define the model, here in this case we use gpt-4o-mini
model = ModelFactory.create(
    model_platform=ModelPlatformType.OPENAI,
    model_type=ModelType.GPT_4O_MINI,
)

# Initialize the agent
ChatAgent("You are a helpful assistant.", model=model)

By supporting str like behaviour for ModelPlatformType we can do:

from camel.models import ModelFactory
from camel.agents import ChatAgent

# Define the model, here in this case we use gpt-4o-mini
model = ModelFactory.create(
    model_platform="openai",
    model_type="gpt-4o-mini",
)

# Initialize the agent
ChatAgent("You are a helpful assistant.", model=model)

By creating model inside ChatAgent with differnt if-else conditions we can do:

from camel.agents import ChatAgent

# Initialize the agent with a `tuple`
ChatAgent("You are a helpful assistant.", model=("openai", "gpt-4o-mini"))

# Or just a `str` for model type. Try to find the corresponding `ModelPlatformType` or use default `ModelPlatformType`
ChatAgent("You are a helpful assistant.", model="gpt-4o-mini") 

Of course we can also support:

from camel.agents import ChatAgent
from camel.types import ModelPlatformType, ModelType

# Initialize the agent with a `tuple` of `enum`
ChatAgent("You are a helpful assistant.", model=(ModelPlatformType.OPENAI, ModelType.GPT_4O_MINI))

# Or just a `enum` for model type. Try to find the corresponding `ModelPlatformType` or use default `ModelPlatformType`
ChatAgent("You are a helpful assistant.", model=ModelType.GPT_4O_MINI) 
@lightaime lightaime changed the title Support str for ModelPlatformType like ModelType to simplify interface Support str like behaviour for ModelPlatformType like ModelType to simplify interface Mar 2, 2025
@lightaime lightaime added Agent Related to camel agents Model Related to backend models labels Mar 2, 2025
@lightaime lightaime added this to the Sprint 24 milestone Mar 2, 2025
@MuggleJinx MuggleJinx self-assigned this Mar 3, 2025
@MuggleJinx MuggleJinx linked a pull request Mar 4, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Related to camel agents Model Related to backend models
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants