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

Add detailed error message for missing model configurations #1632

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,6 @@ cov.xml
*.csv
metagpt/ext/sela/results/*
.chainlit/

metagpt/ext/aflow/data
metagpt/ext/aflow/scripts
shenchucheng marked this conversation as resolved.
Show resolved Hide resolved
35 changes: 30 additions & 5 deletions examples/aflow/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,48 @@ def parse_args():
default=True,
help="Whether to download dataset for the first time",
)
parser.add_argument(
"--opt_model_name",
type=str,
default="claude-3-5-sonnet-20240620",
help="Specifies the name of the model used for optimization tasks.",
)
parser.add_argument(
"--exec_model_name",
type=str,
default="gpt-4o-mini",
help="Specifies the name of the model used for execution tasks.",
)
return parser.parse_args()


if __name__ == "__main__":
args = parse_args()

download(["datasets", "initial_rounds"], if_first_download=args.if_first_optimize)
config = EXPERIMENT_CONFIGS[args.dataset]

mini_llm_config = ModelsConfig.default().get("gpt-4o-mini")
claude_llm_config = ModelsConfig.default().get("claude-3-5-sonnet-20240620")
models_config = ModelsConfig.default()
opt_llm_config = models_config.get(args.opt_model_name)
if opt_llm_config is None:
raise ValueError(
f"The optimization model '{args.opt_model_name}' was not found in the 'models' section of the configuration file. "
"Please add it to the configuration file or specify a valid model using the --opt_model_name flag. "
)

exec_llm_config = models_config.get(args.exec_model_name)
if exec_llm_config is None:
raise ValueError(
f"The execution model '{args.exec_model_name}' was not found in the 'models' section of the configuration file. "
"Please add it to the configuration file or specify a valid model using the --exec_model_name flag. "
)

download(["datasets", "initial_rounds"], if_first_download=args.if_first_optimize)

optimizer = Optimizer(
dataset=config.dataset,
question_type=config.question_type,
opt_llm_config=claude_llm_config,
exec_llm_config=mini_llm_config,
opt_llm_config=opt_llm_config,
exec_llm_config=exec_llm_config,
check_convergence=args.check_convergence,
operators=config.operators,
optimized_path=args.optimized_path,
Expand Down
Loading