langchain
langchain copied to clipboard
Unknown Agent: "structured-chat-zero-shot-react-description" Error
Getting a value error when trying to use the structured agent.
ValueError: Got unknown agent type: structured-chat-zero-shot-react-description. Valid types are: dict_keys([<AgentType.ZERO_SHOT_REACT_DESCRIPTION: 'zero-shot-react-description'>, <AgentType.REACT_DOCSTORE: 'react-docstore'>, <AgentType.SELF_ASK_WITH_SEARCH: 'self-ask-with-search'>, <AgentType.CONVERSATIONAL_REACT_DESCRIPTION: 'conversational-react-description'>, <AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION: 'chat-zero-shot-react-description'>, <AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION: 'chat-conversational-react-description'>]).
Please provide working code that can reproduce this issue.
import os os.environ["LANGCHAIN_TRACING"] = "true" # If you want to trace the execution of the program, set to "true"
import os os.environ["OPENAI_API_KEY"] = "XXXXXXXX"
import nest_asyncio nest_asyncio.apply()
from langchain.agents import AgentType from langchain.chat_models import ChatOpenAI from langchain.agents import initialize_agent
from langchain.agents.agent_toolkits import PlayWrightBrowserToolkit from langchain.tools.playwright.utils import ( create_async_playwright_browser, #create_sync_playwright_browser, # A synchronous browser is available, though it isn't compatible with jupyter. )
import asyncio
async def main(): async_browser = create_async_playwright_browser() browser_toolkit = PlayWrightBrowserToolkit.from_browser(async_browser=async_browser) tools = browser_toolkit.get_tools()
llm = ChatOpenAI(temperature=0)
agent_chain = initialize_agent(tools, llm, agent="structured-chat-zero-shot-react-description", verbose=True)
response = await agent_chain.arun(input="Browse to blog.langchain.dev and summarize the text, please.")
print(response)
if name == "main": asyncio.run(main())
What langchain version do you have ?
This is the newest agent type from this blog? Did you need to do anything special to get await working?
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
i'm using the latest version of langchain.
yes it's the newest agent i'm wanting to test out.
When i print out agent types it shows the new structured tool agent is there.
to get await working in put it in that function down the bottom of the code.
any ideas?
tried multiple fixes, still getting "AttributeError: STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION"
did you get the fix, am also getting same problem
Hi, @crabmun! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, you encountered a value error when trying to use the structured agent in LangChain. The error message indicated that the agent type "structured-chat-zero-shot-react-description" was unknown. You provided code to reproduce the issue and mentioned that you were using the latest version of LangChain. Other users in the comments also reported experiencing the same problem.
However, I'm happy to inform you that this issue has been resolved. The agent type "structured-chat-zero-shot-react-description" was not recognized because it was not included in the list of supported agent types in the LangChain library. The library has been updated to include this agent type, and the issue should no longer occur in the latest version of LangChain.
If this issue is still relevant to the latest version of LangChain, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days. Thank you for your understanding and contribution to the LangChain community!