langflow/docs/docs/Tutorials/tutorials-math-agent.md
Mendon Kissling 37fc581472
docs: v1.3 (#7160)
* lint-plaintext

* Squashed commit of the following:

commit 0820877007091550e196c1ec9189580a1adcfe80
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Wed Feb 19 17:34:54 2025 -0500

    fix-links

commit b47fbfe04e3f3c2239147df59b14626839f6b07c
Merge: 22987155fa 02617ffad2
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Wed Feb 19 17:18:18 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit 22987155fa3bbf39ab2f2a31fe6db643cb98f43f
Merge: bf01a75e72 e8529eaecb
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Wed Feb 19 16:25:52 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit bf01a75e7252f61303c237c7f39c35b6e9831278
Merge: 85770ae167 b43bf8f783
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Wed Feb 19 14:42:10 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit 85770ae167914837a2e0eb5b8848d79726507f3e
Merge: fda54f8f43 e970cdbca3
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Wed Feb 19 11:19:11 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit fda54f8f4344ea629ef8028c388ce65ebc0cac51
Merge: 3027a9c3a4 25ac555e8f
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Tue Feb 18 11:43:21 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit 3027a9c3a44a0c270333d033394eda9b8cd521de
Merge: 0046d1884e 45e2f739d5
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Fri Feb 14 13:20:44 2025 -0500

    Merge branch 'main' into docs-publish-v0

commit 0046d1884e30794f9e372ecba2c484a00675be9a
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Thu Feb 13 13:31:22 2025 -0500

    delete-site-and-redirect

commit 1bf763b3b102b2a7cffb75705c5614a114f3a50a
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Thu Feb 13 13:17:49 2025 -0500

    docs: Add information about sharing the Langflow application's Playground endpoint

commit 4eb34bd746fe16c1e81c92d74640d803d0473dcd
Author: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date:   Thu Feb 13 13:06:46 2025 -0500

    docs: Update references from "API pane" to "Publish pane" in documentation

* s3-bucket-init

* add-bundles-page

* output-parser-component

* language-model-component

* legacy-components

* update-file-component

* parser-component

* publish-doc

* update-agent-starter-flows

* voice-mode

* webhook-component-update

* file-management

* update-env-vars

* make-env-var-table-more-readable

* file-management-link

* bump-version

* add-graph-rag-component

* docs-lambda-filter-component

* docs-add-watsonx-model-component

* add-langchain-links-for-watson-package

* remove-s3-bucket-data-component

* docs: publish-flows introduction

* docs: update voice mode instructions for clarity and detail

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* plurals

* docs-review

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* steps-for-file-component

* parse-data-and-dataframe-in-legacy

* remove-beta-from-parser-component

---------

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>
2025-03-31 16:05:23 -03:00

2.1 KiB
Raw Blame History

title slug
Math agent /tutorials-math-agent

import Icon from "@site/src/components/icon";

Build a Math Agent flow for an agentic application using the Tool-calling agent component.

In this flow, the Tool-calling agent reasons using an Open AI LLM to solve math problems. It selects the Calculator tool for simpler math and the Python REPL tool (with the Python math library) for more complex problems.

Prerequisites

To use this flow, you need an OpenAI API key.

Open Langflow and start a new flow

Click New Flow, and then select the Math Agent flow.

This opens a starter flow with the necessary components to run an agentic application using the Tool-calling agent.

Math Agent flow

The Math Agent flow consists of these components:

  • The Tool calling agent component uses the connected LLM to reason through the user's input and select among the connected tools to complete its task.
  • The Python REPL tool component executes Python code in a REPL (Read-Evaluate-Print Loop) interpreter.
  • The Calculator component performs basic arithmetic operations.
  • The Chat Input component accepts user input to the chat.
  • The Chat Output component prints the flow's output to the chat.

Run the Math Agent flow

  1. Add your credentials to the Agent component.
  2. Click Playground to start a chat session.
  3. Enter a simple math problem, like 2 + 2, and then make sure the bot responds with the correct answer.
  4. To confirm the REPL interpreter is working, prompt the math library directly with math.sqrt(4) and see if the bot responds with 4.
  5. The agent will also reason through more complex word problems. For example, prompt the agent with the following math problem:
The equation 24x2+25x47ax2=8x353ax2 is true for all values of x≠2a, where a is a constant.
What is the value of a?
A) -16
B) -3
C) 3
D) 16

The agent should respond with B.

Now that your query has completed the journey from Chat input to Chat output, you have completed the Math Agent flow.