org.llm4s.toolapi

Members list

Packages

Built-in tools for common agent operations.

Built-in tools for common agent operations.

This package provides production-ready tools that can be used out of the box:

== Core Utilities (No API Keys Required) ==

import org.llm4s.toolapi.builtin.core._

val tools = new ToolRegistry(Seq(
 DateTimeTool.tool,
 CalculatorTool.tool,
 UUIDTool.tool,
 JSONTool.tool
))

== File System Tools ==

import org.llm4s.toolapi.builtin.filesystem._

val fileTools = new ToolRegistry(Seq(
 ReadFileTool.create(FileConfig(
   maxFileSize = 512 * 1024,
   allowedPaths = Some(Seq("/tmp"))
 )),
 ListDirectoryTool.tool,
 FileInfoTool.tool
))

== HTTP Tools ==

import org.llm4s.toolapi.builtin.http._

val httpTools = new ToolRegistry(Seq(
 HTTPTool.create(HttpConfig(
   timeoutMs = 10000,
   allowedDomains = Some(Seq("api.example.com"))
 ))
))

== Shell Tools ==

import org.llm4s.toolapi.builtin.shell._

// Read-only shell (safe commands)
val shellTools = new ToolRegistry(Seq(
 ShellTool.create(ShellConfig.readOnly())
))

// Development shell with common dev tools
val devShellTools = new ToolRegistry(Seq(
 ShellTool.create(ShellConfig.development())
))

== Search Tools ==

import org.llm4s.toolapi.builtin.search._

val searchTools = new ToolRegistry(Seq(
 WebSearchTool.tool
))

== All Built-in Tools ==

import org.llm4s.toolapi.builtin.BuiltinTools

// Get all safe tools (no shell, restricted filesystem)
val tools = BuiltinTools.safe()

// Get all tools with custom config
val allTools = BuiltinTools.all(
 fileConfig = FileConfig(allowedPaths = Some(Seq("/tmp")))
)

Attributes

See also

Type members

Classlikes

case class ArraySchema[A](description: String, itemSchema: SchemaDefinition[A], minItems: Option[Int], maxItems: Option[Int], uniqueItems: Boolean) extends SchemaDefinition[Seq[A]]

Array schema with validation options

Array schema with validation options

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[Seq[A]]
class Object
trait Matchable
class Any
Show all

Helper class to convert ToolRegistry to Azure OpenAI format

Helper class to convert ToolRegistry to Azure OpenAI format

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class BooleanSchema(description: String) extends SchemaDefinition[Boolean]

Boolean schema

Boolean schema

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[Boolean]
class Object
trait Matchable
class Any
Show all
case class IntegerSchema(description: String, minimum: Option[Int], maximum: Option[Int], exclusiveMinimum: Option[Int], exclusiveMaximum: Option[Int], multipleOf: Option[Int]) extends SchemaDefinition[Int]

Integer schema with validation options

Integer schema with validation options

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[Int]
class Object
trait Matchable
class Any
Show all
case class NullableSchema[T](underlying: SchemaDefinition[T]) extends SchemaDefinition[Option[T]]

Nullable schema wrapper

Nullable schema wrapper

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[Option[T]]
class Object
trait Matchable
class Any
Show all
case class NumberSchema(description: String, isInteger: Boolean, minimum: Option[Double], maximum: Option[Double], exclusiveMinimum: Option[Double], exclusiveMaximum: Option[Double], multipleOf: Option[Double]) extends SchemaDefinition[Double]

Number schema with validation options

Number schema with validation options

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[Double]
class Object
trait Matchable
class Any
Show all
case class ObjectSchema[T](description: String, properties: Seq[PropertyDefinition[_]], additionalProperties: Boolean) extends SchemaDefinition[T]

Object schema with properties

Object schema with properties

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[T]
class Object
trait Matchable
class Any
Show all
case class PropertyDefinition[T](name: String, schema: SchemaDefinition[T], required: Boolean)

Property definition for object schemas

Property definition for object schemas

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class SafeParameterExtractor(params: Value)

Safe parameter extraction with type checking and path navigation.

Safe parameter extraction with type checking and path navigation.

This extractor provides two modes of operation:

  1. Simple mode: Returns Either[String, T] for backward compatibility
  2. Enhanced mode: Returns Either[ToolParameterError, T] for structured error reporting

Value parameters

params

The JSON parameters to extract from

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Schema

Schema builder - fluent API for creating schema definitions

Schema builder - fluent API for creating schema definitions

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Schema.type
sealed trait SchemaDefinition[T]

Base trait for all schema definitions

Base trait for all schema definitions

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ArraySchema[A]
class NullableSchema[T]
class NumberSchema
class ObjectSchema[T]
class StringSchema
Show all
case class StringSchema(description: String, enumValues: Option[Seq[String]], minLength: Option[Int], maxLength: Option[Int]) extends SchemaDefinition[String]

String schema with validation options

String schema with validation options

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[String]
class Object
trait Matchable
class Any
Show all
class ToolBuilder[T, R]

Builder for tool definitions

Builder for tool definitions

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ToolBuilder

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait ToolCallError

Enhanced tool call errors with consistent formatting

Enhanced tool call errors with consistent formatting

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object ToolCallError

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ToolCallRequest(functionName: String, arguments: Value)

Request model for tool calls

Request model for tool calls

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait ToolExecutionStrategy

Strategy for executing multiple tool calls.

Strategy for executing multiple tool calls.

When an LLM requests multiple tool calls, they can be executed either sequentially (one at a time) or in parallel (simultaneously).

Attributes

Example
// Execute tools in parallel
agent.runWithStrategy(
 query = "Get weather in London, Paris, and Tokyo",
 tools = weatherTools,
 toolExecutionStrategy = ToolExecutionStrategy.Parallel
)
// Limit concurrency to 2 at a time
agent.runWithStrategy(
 query = "Search 10 different topics",
 tools = searchTools,
 toolExecutionStrategy = ToolExecutionStrategy.ParallelWithLimit(2)
)
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Parallel
object Sequential

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ToolFunction[T, R](name: String, description: String, schema: SchemaDefinition[T], handler: SafeParameterExtractor => Either[String, R])(implicit evidence$1: ReadWriter[R])

Core model for tool function definitions

Core model for tool function definitions

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait ToolParameterError

Structured error information for tool parameter validation

Structured error information for tool parameter validation

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
class ToolRegistry(initialTools: Seq[ToolFunction[_, _]])

Registry for tool functions with execution capabilities.

Registry for tool functions with execution capabilities.

Supports both synchronous and asynchronous tool execution:

  • execute() - Synchronous, blocking execution (original API)
  • executeAsync() - Asynchronous, non-blocking execution
  • executeAll() - Batch execution with configurable strategy

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object ToolRegistry

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type