Skip to content

max_tokens args doesn't work on stanford_town #1675

Closed
@Fuyubai

Description

Bug description
max_tokens args doesn't work on STAction._run_gpt35_max_tokens()

class STAction(Action):
    async def _aask(self, prompt: str) -> str:
        return await self.llm.aask(prompt)

    async def _run_gpt35_max_tokens(self, prompt: str, max_tokens: int = 50, retry: int = 3):
        for idx in range(retry):
            try:
                tmp_max_tokens_rsp = getattr(config.llm, "max_token", 1500)
                setattr(config.llm, "max_token", max_tokens)
                self.llm.use_system_prompt = False  # to make it behave like a non-chat completions

                llm_resp = await self._aask(prompt)

                setattr(config.llm, "max_token", tmp_max_tokens_rsp)
                logger.info(f"Action: {self.cls_name} llm _run_gpt35_max_tokens raw resp: {llm_resp}")
                if self._func_validate(llm_resp, prompt):
                    return self._func_cleanup(llm_resp, prompt)
            except Exception as exp:
                logger.warning(f"Action: {self.cls_name} _run_gpt35_max_tokens exp: {exp}")
                time.sleep(5)
        return self.fail_default_resp

Actually, self.llm module use self.llm.config rather than config.llm, even though they are both same class type (id is not same)

Bug solved method
Simply, just replace config.llm to self.llm.config, max_tokens can work

But I think self.llm.config has same class type with config.llm, they should be same thing (id is same), maybe something wrong in initialization these class

  • LLM type and model name: openai api deployed by vllm
  • Python version: 3.10
  • MetaGPT version or branch: main (4954729)

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions