langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

Unknown agent type when loading from hub

Open elier opened this issue 1 year ago • 1 comments

Loading the following agent fails with "UnhandledPromiseRejectionWarning: Error: Unknown agent type":
https://github.com/hwchase17/langchain-hub/tree/master/agents/zero-shot-react-conversation

  const model = new ChatOpenAI({ temperature: 0});
  const tools: Tool[] = [new SerpAPI(), new Calculator()];
  const agent = await loadAgent(
    "lc://agents/zero-shot-react-conversation/agent.json",
    { llm: model, tools }
  );

However, the other agent works:
https://github.com/hwchase17/langchain-hub/tree/master/agents/zero-shot-react-description

The reason is very clear, only "zero-shot-react-description" is supported:

    /**
     * Load an agent from a json-like object describing it.
     */
    static async deserialize(data) {
        switch (data._type) {
            case "zero-shot-react-description": {
                const { ZeroShotAgent } = await import("./mrkl/index.js");
                return ZeroShotAgent.deserialize(data);
            }
            default:
                throw new Error("Unknown agent type");
        }
    }

elier avatar Apr 11 '23 18:04 elier