org.llm4s.tapir

package org.llm4s.tapir

Members list

Type members

Classlikes

@Experimental
final case class EndpointTool

One tapir endpoint offered to a model as a tool, before it is built into a ToolFunction by EndpointTools.registry.

One tapir endpoint offered to a model as a tool, before it is built into a ToolFunction by EndpointTools.registry.

The tool's parameters are the endpoint's inputs: each path capture, query parameter and request body becomes a property of the tool's JSON schema, under its tapir name (the body under body). A header input is a parameter only when it is listed in modelHeaders; any other header, and every authentication input, is the application's: its value comes from headers, never from the model.

Create one with EndpointTools.tool.

Value parameters

description

the description shown to the model; the endpoint's own description, summary or METHOD /path when absent

endpoint

the tapir endpoint the tool calls

headers

the headers the application sends on every call, such as Authorization

modelHeaders

the header inputs the model may set, by name, compared without regard to case

name

the tool's name, as the model calls it; [a-zA-Z0-9_-]{1,64}

requiresApproval

whether the tool changes something, so that an agent should ask before it runs; read it with EndpointTools.requiringApproval

Attributes

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

Creates an EndpointTool; EndpointTools.tool is the usual way in.

Creates an EndpointTool; EndpointTools.tool is the usual way in.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
object EndpointTools

Turns tapir endpoints a service already has into tools a model can call, with each tool's parameter schema derived from the endpoint's own inputs.

Turns tapir endpoints a service already has into tools a model can call, with each tool's parameter schema derived from the endpoint's own inputs.

val tools: Result[ToolRegistry] = EndpointTools.registry(
 uri"https://orders.internal",
 HttpClientSyncBackend(),
 EndpointTools.tool("get_order", getOrder),
 EndpointTools.tool("cancel_order", cancelOrder)
)

A call decodes the model's arguments with the endpoint's own codecs, so its types and validators check them before anything is sent, then calls the endpoint through sttp. Every failure (an argument the endpoint rejects, an error response, a server error, a request that cannot be sent) is a tool error the model reads; nothing throws.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type