cpacker / MemGPT

Create LLM agents with long-term memory and custom tools 📚🦙
https://memgpt.readme.io
Apache License 2.0
11.36k stars 1.23k forks source link

cli tools not found. #1674

Open ChavesLiu opened 3 weeks ago

ChavesLiu commented 3 weeks ago

File "/opt/anaconda3/envs/pymemgpt/lib/python3.11/site-packages/memgpt/cli/cli.py", line 585, in run memgpt_agent = Agent(agent_state=agent_state, interface=interface(), tools=tools) UnboundLocalError: cannot access local variable 'tools' where it is not associated with a value

ChavesLiu commented 3 weeks ago

Add code to line 583

        # Update the agent with any overrides
        agent_state = client.update_agent(
            agent_id=agent_state.id,
            name=agent_state.name,
            llm_config=agent_state.llm_config,
            embedding_config=agent_state.embedding_config,
        )
        # >>>> add code
        tools = []
        for tool_name in agent_state.tools:
            tool = ms.get_tool(tool_name, agent_state.user_id)
            if tool is None:
                typer.secho(f"Couldn't find tool {tool_name} in database, please run `memgpt add tool`", fg=typer.colors.RED)
            tools.append(tool)
        # <<< end
        # create agent
        memgpt_agent = Agent(agent_state=agent_state, interface=interface(), tools=tools)
ChavesLiu commented 1 week ago

How to merge into the main branch.