Files
langchain/cookbook/llm_math.ipynb
T
standby24x7 6c9177681d docs: Update function "run" to "invoke" in llm_math.ipynb (#18505)
This patch updates function "run" to "invoke".
Without this patch you see following warning.

LangChainDeprecationWarning: The function `run` was deprecated in
LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
2024-03-04 10:42:36 -08:00

1.9 KiB

Math chain

This notebook showcases using LLMs and Python REPLs to do complex word math problems.

In [4]:
from langchain.chains import LLMMathChain
from langchain_openai import OpenAI

llm = OpenAI(temperature=0)
llm_math = LLMMathChain.from_llm(llm, verbose=True)

llm_math.invoke("What is 13 raised to the .3432 power?")
Out [4]:

> Entering new LLMMathChain chain...
What is 13 raised to the .3432 power?
```text
13 ** .3432
```
...numexpr.evaluate("13 ** .3432")...

Answer: 2.4116004626599237
> Finished chain.
'Answer: 2.4116004626599237'
In [ ]: