Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

LangChain with HuggingFace model and DuckDuckSearch not working

$
0
0

I'm trying to create an agent that uses HuggingFace models and also uses internet search to answer the queries

import osimport getpassfrom langchain.agents import load_toolsfrom langchain.agents import initialize_agentfrom langchain.llms import OpenAIfrom langchain.agents import load_huggingface_toolfrom langchain import PromptTemplate, HuggingFaceHub, LLMChainos.environ\["HUGGINGFACEHUB_API_TOKEN"\] = getpass.getpass("HF Token:")llm = HuggingFaceHub(repo_id="huggingfaceh4/zephyr-7b-alpha",model_kwargs={"temperature": 0.5, "max_length": 64, "max_new_tokens": 512},)tools = load_tools(\["ddg-search"\], llm=llm)agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)agent.run("What is LangChain and how does it work? ")

But I keep getting Observation: the action to take, should be one of [duckduckgo_search] is not a valid tool, try one of [duckduckgo_search]. and it just keeps looping without any useful error. How can I fix this?

Thank you


Viewing all articles
Browse latest Browse all 13921

Trending Articles