aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.38k stars 591 forks source link

Error missing numexpr dependency when running 07_Agents/00_Function_DIY_Agents.ipynb #155

Closed lovaarte closed 5 months ago

lovaarte commented 9 months ago

When running in 07_Agents/00_Function_DIY_Agents.ipynb notebook

from langchain import LLMMathChain

math_tool_template = """\
Given a question from the Human with a math problem, provide only a single line mathematical expression that solves the problem in the following format.
Never solve the expression only create a parsable expression.
```text
${{single line mathematical expression that solves the problem}}
```

Here is an example response with a single line mathematical expression for solving a math problem:
```text
37593**(1/5)
```

Human: {question}

Assistant:"""

llm_math_chain = LLMMathChain.from_llm(llm=agent_llm, verbose=True)
llm_math_chain.llm_chain.prompt.template = math_tool_template
result = llm_math_chain('What is nine times 465?')

getting following error:

ImportError: LLMMathChain requires the numexpr package. Please install it with `pip install numexpr`.

Solution that works for me:

pip install numexpr
w601sxs commented 5 months ago

Closing this; please refer to the latest bedrock workshop update and reopen if still relevant