LLMMathChain
LLMMathChain solves maths problems stated in natural language. An AI model reads the problem and turns it into a mathematical operation; that operation is then computed exactly, without relying on the model to get the arithmetic right.
Use it when the input is a text like “if we sell 340 units at €12.50 with an 8% discount, how much do we invoice?” and you need the correct number.
When to use it
- Calculating amounts, discounts or percentages from a question written by a user.
- Solving calculations that appear inside an email or a request.
- Avoiding arithmetic mistakes in answers that depend on an operation.
Configuration
| Field | What it does |
|---|---|
| Input (required) | The problem to solve, written in words or as an operation. You can type it or connect it to the text output of another component. |
| Connection | What to connect |
|---|---|
| Model (required) | An AI model component, for example OpenAI. |
Output
- Text: the result of the calculation, preceded by
Answer:. Connect it to a Chat Output or to any text input.
Example
Distribuciones Olmo wants its sales team to work out quick quotes from the chat:
- Connect a Chat Input to Input and a model to Model.
- Connect Text to a Chat Output.
- Type: “340 boxes at 12.50 euros each with an 8% discount”.
The answer starts with Answer: followed by the amount with the discount applied: 3910.
Good practices
- Write the problem with all the data needed; the component does not look for information elsewhere.
- If you want an agent to do calculations while it chats, connect a Calculator tool to it.