From cdd3025408cfb2cb83c91545df3e329383fc713e Mon Sep 17 00:00:00 2001 From: Blq <243987385@qq.com> Date: Fri, 23 Feb 2024 08:39:44 +0000 Subject: [PATCH] Assigned configs for actions to prevent action.llm.model being overridden in Role._init_action. --- examples/debate_simple.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/debate_simple.py b/examples/debate_simple.py index 869e02a0e..953f664f3 100644 --- a/examples/debate_simple.py +++ b/examples/debate_simple.py @@ -8,14 +8,17 @@ import asyncio from metagpt.actions import Action +from metagpt.config2 import Config from metagpt.environment import Environment from metagpt.roles import Role from metagpt.team import Team -action1 = Action(name="AlexSay", instruction="Express your opinion with emotion and don't repeat it") -action1.llm.model = "gpt-4-1106-preview" -action2 = Action(name="BobSay", instruction="Express your opinion with emotion and don't repeat it") -action2.llm.model = "gpt-3.5-turbo-1106" +gpt35 = Config.default() +gpt35.llm.model = "gpt-3.5-turbo-1106" +gpt4 = Config.default() +gpt4.llm.model = "gpt-4-1106-preview" +action1 = Action(config=gpt4, name="AlexSay", instruction="Express your opinion with emotion and don't repeat it") +action2 = Action(config=gpt35, name="BobSay", instruction="Express your opinion with emotion and don't repeat it") alex = Role(name="Alex", profile="Democratic candidate", goal="Win the election", actions=[action1], watch=[action2]) bob = Role(name="Bob", profile="Republican candidate", goal="Win the election", actions=[action2], watch=[action1]) env = Environment(desc="US election live broadcast")