Nous.Tools.StringTools (nous v0.13.3)
View SourceBuilt-in tools for string manipulation operations.
These tools provide common string functionality that AI agents often need:
- Text transformation (uppercase, lowercase, capitalize)
- String analysis (length, count occurrences)
- String operations (replace, split, join, trim)
- Pattern matching and extraction
- String validation
Usage
agent = Nous.new("lmstudio:qwen3-vl-4b-thinking-mlx",
tools: [
&StringTools.string_length/2,
&StringTools.replace_text/2,
&StringTools.split_text/2
]
)
{:ok, result} = Nous.run(agent, "How many characters in 'Hello World'?")
Summary
Functions
Capitalize the first letter of each word.
Check if a string contains a substring.
Count occurrences of a substring in a string.
Check if a string ends with a suffix.
Extract numbers from a string.
Extract words from a string.
Check if a string is a palindrome.
Join a list of strings with a delimiter.
Pad a string to a specific length.
Repeat a string N times.
Replace all occurrences of a pattern in a string.
Reverse a string.
Split a string into parts based on a delimiter.
Check if a string starts with a prefix.
Get the length of a string.
Extract a substring from a string.
Convert text to lowercase.
Convert text to uppercase.
Trim whitespace from a string.
Functions
Capitalize the first letter of each word.
Arguments
- text: The text to capitalize
- mode: "first" (first letter only), "words" (each word), "sentences" (each sentence)
Check if a string contains a substring.
Arguments
- text: The text to search in
- pattern: The pattern to search for
- case_sensitive: Whether to match case (default: true)
Count occurrences of a substring in a string.
Arguments
- text: The text to search in
- pattern: The pattern to count
- case_sensitive: Whether to match case (default: true)
Check if a string ends with a suffix.
Arguments
- text: The text to check
- suffix: The suffix to check for
- case_sensitive: Whether to match case (default: true)
Extract numbers from a string.
Arguments
- text: The text to extract numbers from
Extract words from a string.
Arguments
- text: The text to extract words from
- min_length: Minimum word length (default: 1)
Check if a string is a palindrome.
Arguments
- text: The text to check
- ignore_case: Whether to ignore case (default: true)
- ignore_spaces: Whether to ignore spaces (default: true)
Join a list of strings with a delimiter.
Arguments
- parts: List of strings to join (comma-separated string)
- delimiter: The delimiter to use (default: " ")
Pad a string to a specific length.
Arguments
- text: The text to pad
- length: Target length
- padding: Character to pad with (default: " ")
- side: "left", "right", or "both" (default: "right")
Repeat a string N times.
Arguments
- text: The text to repeat
- times: Number of times to repeat (max 100)
Replace all occurrences of a pattern in a string.
Arguments
- text: The original text
- pattern: The text to find
- replacement: The text to replace with
- case_sensitive: Whether to match case (default: true)
Reverse a string.
Arguments
- text: The text to reverse
Split a string into parts based on a delimiter.
Arguments
- text: The text to split
- delimiter: The delimiter to split on (default: " ")
- trim: Whether to trim whitespace from parts (default: false)
- remove_empty: Whether to remove empty strings (default: false)
Check if a string starts with a prefix.
Arguments
- text: The text to check
- prefix: The prefix to check for
- case_sensitive: Whether to match case (default: true)
Get the length of a string.
Arguments
- text: The string to measure
Extract a substring from a string.
Arguments
- text: The original text
- start: Starting position (0-indexed)
- length: Number of characters to extract (optional, extracts to end if not provided)
Convert text to lowercase.
Arguments
- text: The text to convert
Convert text to uppercase.
Arguments
- text: The text to convert
Trim whitespace from a string.
Arguments
- text: The text to trim
- side: "both" (default), "left", "right"