Skip to content

Agent Modules Reference

The Agent system in Hands-On AI includes several specialized agent modules, each focused on different domains of functionality. Each agent module registers a set of related tools that can be used together to solve specific types of problems.

Calculator Agent

The Calculator Agent provides mathematical computation tools ranging from basic arithmetic to advanced formulas and equation solving.

Tools Provided

  1. calc
  2. Description: Evaluate a basic mathematical expression
  3. Input: Mathematical expression as text (e.g., "2 + 2 * 3")
  4. Output: Numerical result
  5. Capabilities: Basic arithmetic (+, -, *, /), common functions (abs, round, max, min, sum, pow)
  6. Safety: Uses restricted evaluation environment to prevent code execution

  7. advanced_calc

  8. Description: Evaluate advanced mathematical expressions with scientific functions
  9. Input: Mathematical expression including advanced functions (e.g., "sqrt(16) + sin(pi/2)")
  10. Output: Numerical result
  11. Capabilities: All basic arithmetic plus trigonometric functions (sin, cos, tan), logarithms (log, log10), exponentiation (exp), constants (pi, e), and more
  12. Safety: Uses restricted evaluation environment with controlled access to math functions

  13. solve_quadratic

  14. Description: Solve a quadratic equation in the form ax² + bx + c = 0
  15. Input: Three coefficients (a, b, c)
  16. Output: Solutions to the equation
  17. Capabilities:
    • Finds both real and complex solutions
    • Handles special cases (discriminant = 0)
    • Provides formatted output with explanations

Example Usage

> solve_quadratic(1, -3, 2)
Two real solutions: x = 2.0 or x = 1.0

> advanced_calc("sin(pi/2) + sqrt(16)")
5.0

Dictionary Agent

The Dictionary Agent provides language assistance tools for looking up word meanings and relationships.

Tools Provided

  1. define
  2. Description: Look up the definition of a word
  3. Input: A single word
  4. Output: The word's definition
  5. Note: Uses a built-in dictionary with common words

  6. synonyms

  7. Description: Find synonyms (words with similar meaning)
  8. Input: A single word
  9. Output: List of synonyms for the word
  10. Example: For "happy" → joyful, cheerful, delighted, pleased, content

  11. antonyms

  12. Description: Find antonyms (words with opposite meaning)
  13. Input: A single word
  14. Output: List of antonyms for the word
  15. Example: For "happy" → sad, unhappy, miserable, depressed

  16. examples

  17. Description: Find example sentences using a word
  18. Input: A single word
  19. Output: Sample sentences demonstrating the word's usage
  20. Example: For "happy" → "I'm happy to see you.", "They were a happy family."

Example Usage

> define("happy")
Feeling or showing pleasure or contentment.

> synonyms("happy")
Synonyms for 'happy': joyful, cheerful, delighted, pleased, content

Converter Agent

The Converter Agent provides tools for converting values between different units of measurement.

Tools Provided

  1. convert
  2. Description: General-purpose unit conversion tool
  3. Input: Value, source unit, and target unit
  4. Output: Converted value
  5. Capabilities: Automatically detects unit types and performs appropriate conversion
  6. Error Handling: Prevents cross-category conversions (e.g., length to weight)

  7. convert_length

  8. Description: Convert between length units
  9. Input: Value, source unit, and target unit
  10. Output: Converted length value
  11. Supported Units: m, km, cm, mm, in, ft, yd, mi

  12. convert_weight

  13. Description: Convert between weight units
  14. Input: Value, source unit, and target unit
  15. Output: Converted weight value
  16. Supported Units: g, kg, mg, lb, oz, st, ton, tonne

  17. convert_temperature

  18. Description: Convert between temperature units
  19. Input: Value, source unit, and target unit
  20. Output: Converted temperature value
  21. Supported Units: c (Celsius), f (Fahrenheit), k (Kelvin)

Example Usage

> convert_length(5, "m", "ft")
5 m = 16.4 ft

> convert_temperature(32, "f", "c")
32 °F = 0 °C

Text Tools Agent

The Text Tools Agent provides tools for analyzing and manipulating text content.

Tools Provided

  1. word_count
  2. Description: Count words, characters, sentences, and paragraphs in text
  3. Input: Text content
  4. Output: Text statistics including word count, character count, sentence count, paragraph count, unique words, and average word length

  5. readability

  6. Description: Calculate readability scores for text
  7. Input: Text content
  8. Output: Readability metrics including:

    • Flesch Reading Ease score and interpretation
    • Flesch-Kincaid Grade Level
    • SMOG Index
    • Text statistics (words per sentence, syllables per word)
  9. summarize

  10. Description: Create a summary of text
  11. Input: Text content and optional ratio parameter (0.1-0.5)
  12. Output: Extractive summary highlighting key sentences
  13. Algorithm: Uses frequency analysis and position-based weighting to select important sentences

Example Usage

> word_count("This is a sample text. It has two sentences.")
Word count: 9
Character count: 45
Character count (without spaces): 37
Sentence count: 2
Paragraph count: 1
Unique words: 8
Average word length: 3.8 characters

Education Tools Agent

The Education Tools Agent provides tools for educational purposes across various subjects.

Tools Provided

  1. periodic_table
  2. Description: Look up element information in the periodic table
  3. Input: Element name or symbol
  4. Output: Element details including symbol, atomic number, atomic weight, category, group, and period
  5. Coverage: Includes common elements with detailed properties

  6. multiplication_table

  7. Description: Generate a multiplication table for a number
  8. Input: Base number and optional size parameter
  9. Output: Formatted multiplication table
  10. Example: For input 7, generates a table of 7×1 through 7×10

  11. prime_check

  12. Description: Check if a number is prime
  13. Input: Integer number
  14. Output: Prime status, factors (if not prime), and nearest prime numbers
  15. Capabilities: Efficiently determines primality and provides educational context

Example Usage

> periodic_table("oxygen")
Element: Oxygen
Symbol: O
Atomic Number: 8
Atomic Weight: 15.999
Category: Nonmetal
Group: 16
Period: 2

> prime_check(17)
17 is a prime number.
The next prime number is 19.
The previous prime number is 13.

Date and Time Tools Agent

The Date and Time Tools Agent provides tools for working with dates and time calculations.

Tools Provided

  1. date_diff
  2. Description: Calculate the difference between two dates
  3. Input: Two dates in YYYY-MM-DD format
  4. Output: Time span in years, months, days, and total days
  5. Features: Handles date ordering automatically, provides human-readable output

  6. format_date

  7. Description: Format a date in different styles
  8. Input: Date in YYYY-MM-DD format and optional format code
  9. Output: Date in the requested format
  10. Format Options: iso, short, medium, long, full

  11. days_until

  12. Description: Calculate days until a future date
  13. Input: Target date in YYYY-MM-DD format
  14. Output: Time remaining until the target date
  15. Features: Different output formats based on timeframe (days, weeks, months)

Example Usage

> date_diff("2023-01-01", "2023-12-31")
Difference between 2023-01-01 and 2023-12-31:
0 years, 11 months, 30 days
Total: 364 days

> days_until("2023-12-25")
There are 85 days until 2023-12-25 (about 12 weeks)

Using Agents in Hands-On AI

Agents are collections of related tools designed to work together. When you run the Hands-On AI agent system, it has access to all these specialized agents and can choose the appropriate tools based on the task.

Via Python API

from hands_on_ai.agent import run_agent

response = run_agent("Convert 25 degrees Celsius to Fahrenheit and tell me if it's hot or cold.")
print(response)

Via Command Line

agent ask "What's the atomic weight of oxygen, and can you convert 5 miles to kilometers?"

In both cases, the agent system will: 1. Analyze the task 2. Select the appropriate tools (periodic_table from Education Tools Agent and convert_length from Converter Agent) 3. Execute the tools with the correct parameters 4. Combine the results into a coherent response

This modular agent system allows Hands-On AI to handle a wide range of tasks with specialized, purpose-built tools that can work together seamlessly.