From f70ba27d35333da1ac7d7c58e91d96c20461ce8c Mon Sep 17 00:00:00 2001 From: stellahsr Date: Sat, 7 Oct 2023 20:24:55 +0800 Subject: [PATCH] add different llms for different agents --- metagpt/actions/minecraft/design_curriculumn.py | 1 + metagpt/actions/minecraft/manage_skills.py | 3 +++ metagpt/actions/minecraft/review_task.py | 1 + metagpt/provider/openai_api.py | 6 +++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/minecraft/design_curriculumn.py b/metagpt/actions/minecraft/design_curriculumn.py index 9d0daa72e..a5e321326 100644 --- a/metagpt/actions/minecraft/design_curriculumn.py +++ b/metagpt/actions/minecraft/design_curriculumn.py @@ -24,6 +24,7 @@ class DesignTask(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) + self.llm.model = "gpt-3.5-turbo" async def decompose_task(self, query, events): system_msgs = SystemMessage( diff --git a/metagpt/actions/minecraft/manage_skills.py b/metagpt/actions/minecraft/manage_skills.py index 9b205dd19..35d35e27b 100644 --- a/metagpt/actions/minecraft/manage_skills.py +++ b/metagpt/actions/minecraft/manage_skills.py @@ -18,6 +18,7 @@ class RetrieveSkills(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) + self.llm.model = "gpt-3.5-turbo" async def run(self, query, skills, *args, **kwargs): # Implement the logic for retrieving skills here. @@ -44,6 +45,7 @@ class AddNewSkills(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) + self.llm.model = "gpt-3.5-turbo" async def run( self, task, program_name, program_code, skills, skill_desp, *args, **kwargs @@ -100,6 +102,7 @@ class GenerateSkillDescription(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) + self.llm.model = "gpt-3.5-turbo" async def run(self, program_name, human_message, system_message, *args, **kwargs): # Implement the logic for generating skill descriptions here. diff --git a/metagpt/actions/minecraft/review_task.py b/metagpt/actions/minecraft/review_task.py index 3a46b9752..ed2f34a4f 100644 --- a/metagpt/actions/minecraft/review_task.py +++ b/metagpt/actions/minecraft/review_task.py @@ -15,6 +15,7 @@ class VerifyTask(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) + self.llm.model = "gpt-3.5-turbo" async def run(self,human_msg, system_msg, max_retries=5, *args, **kwargs): # Implement the logic to verify the task here. diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index 303b1bbf7..00e36d13a 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -142,10 +142,10 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter): Check https://platform.openai.com/examples for examples """ - def __init__(self): - self.__init_openai(CONFIG) + def __init__(self, conf=CONFIG, **kwargs): + self.__init_openai(conf) self.llm = openai - self.model = CONFIG.openai_api_model + self.model = conf.openai_api_model self.auto_max_tokens = False self._cost_manager = CostManager() RateLimiter.__init__(self, rpm=self.rpm)