A user tried to use AI21's models through LangChain agents by passing an AI21Client instance directly as the llm to loadtools and initializeagent, and the agent would not run. The problem: AI21Client is the raw API client, not a LangChain LLM, so it is not Runnable. Context: ai21-python SDK, LangChain initializeagent with AgentType.ZEROSHOTREACTDESCRIPTION. After switching to the proper LangChain wrapper, the reporter confirmed the agents ran.
AI21 LLM is not Runnable when using via LangChain
Dont pass AI21Client as the llm. Use the LangChain wrapper from the langchainai21 package instead: from langchainai21 import AI21LLM, then llm = AI21LLM(model="j2-ultra", your AI21 key parameter) and pass that llm to loadtools and initializeagent. If you want the chat model (Jamba), use ChatAI21 from the same package. The reporter confirmed their agents ran after the switch. Source: https://github.com/AI21Labs/ai21-python/issues/145
Source: https://github.com/AI21Labs/ai21-python/issues/145