agents.react_class.react_v3.example

Test script for ReactAgent demonstrating various usage patterns.

from typing import Any This script shows how to: 1. Create ReactAgents with different tools 2. Use RetryPolicy with LangGraph 3. Schema composition with tool integration 4. Running agents with different input formats

Classes

Calculator

Tool for performing simple calculations.

Functions

calculate(args)

Perform a calculation based on the operation and numbers.

get_current_weather(location)

Get the current weather in a given location.

search_api(query)

Search for information about a topic (simulates random failures).

test_all()

Run all ReactAgent tests.

test_basic_react_agent()

Test a basic ReactAgent with simple tools.

test_multi_turn_conversation()

Test a ReactAgent with a multi-turn conversation.

test_retry_policy()

Test a ReactAgent with retry policies for flaky tools.

test_structured_tool_agent()

Test a ReactAgent with structured tools.

Module Contents

class agents.react_class.react_v3.example.Calculator(/, **data)

Bases: pydantic.BaseModel

Tool for performing simple calculations.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

agents.react_class.react_v3.example.calculate(args)

Perform a calculation based on the operation and numbers.

Parameters:

args (Calculator)

Return type:

str

agents.react_class.react_v3.example.get_current_weather(location)

Get the current weather in a given location.

Parameters:

location (str)

Return type:

str

agents.react_class.react_v3.example.search_api(query)

Search for information about a topic (simulates random failures).

Parameters:

query (str)

Return type:

str

agents.react_class.react_v3.example.test_all()

Run all ReactAgent tests.

Return type:

None

agents.react_class.react_v3.example.test_basic_react_agent()

Test a basic ReactAgent with simple tools.

Return type:

Any

agents.react_class.react_v3.example.test_multi_turn_conversation()

Test a ReactAgent with a multi-turn conversation.

Return type:

Any

agents.react_class.react_v3.example.test_retry_policy()

Test a ReactAgent with retry policies for flaky tools.

Return type:

Any

agents.react_class.react_v3.example.test_structured_tool_agent()

Test a ReactAgent with structured tools.

Return type:

Any