Tools

org.llm4s.schema.Tools
@Experimental
object Tools

Tools derived from a whole service: one per public method of a trait or class.

trait CustomerService:
 /** Orders placed by a customer, newest first.
   * @param customerId the customer's id, for example C-1001
   */
 def findOrders(customerId: String): Result[List[Order]]

val tools: Result[Seq[ToolFunction[?, ?]]] = Tools.derive[CustomerService](liveService)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Tools.type

Members list

Value members

Concrete methods

inline def derive[S](service: S): Result[Seq[ToolFunction[_, _]]]

One tool per public method of S, each built as Tool.fromMethod builds one, and calling that method on service; in the order of their tool names, ready for a ToolRegistry.

One tool per public method of S, each built as Tool.fromMethod builds one, and calling that method on service; in the order of their tool names, ready for a ToolRegistry.

Left out: methods S inherits from Any, Object, Product, Equals and Serializable, synthetic methods (a case class's copy), private, protected and extension methods, vals, and every method marked notATool. A method with no parameter list (def status: String) is a tool without parameters.

Refused at compile time, with a message naming the method: whatever Tool.fromMethod refuses, an overloaded method (a model cannot tell two tools of one name apart: rename one, give it a toolName, or mark it notATool), and two methods whose tool names are the same.

Type parameters

S

the trait or class whose methods are the tools; its Scaladoc and annotations describe them

Value parameters

service

the instance whose methods the tools call

Attributes

Returns

the tools, or the first ValidationError a parameter's schema gave (see SchemaOf)