starflow/tool

Types

Represents a tool that can be used by the model. The type parameter input defines the expected input type, while output defines the return type.

pub type Tool {
  Tool(
    name: String,
    description: String,
    schema: schema.Schema,
    output: schema.Schema,
    apply: fn(dynamic.Dynamic) ->
      Result(ToolResult, List(dynamic.DecodeError)),
  )
}

Constructors

  • Tool(
      name: String,
      description: String,
      schema: schema.Schema,
      output: schema.Schema,
      apply: fn(dynamic.Dynamic) ->
        Result(ToolResult, List(dynamic.DecodeError)),
    )
pub type ToolResult {
  String(String)
  Number(Float)
  Integer(Int)
  Boolean(Bool)
  Null
  Array(List(ToolResult))
  Object(List(#(String, ToolResult)))
  Enum(String)
}

Constructors

  • String(String)
  • Number(Float)
  • Integer(Int)
  • Boolean(Bool)
  • Null
  • Array(List(ToolResult))
  • Object(List(#(String, ToolResult)))
  • Enum(String)

Functions

pub fn result(
  tool_use: #(String, Dynamic),
  tools: List(Tool),
) -> Result(ToolResult, DecodeError)
pub fn to_json(tool: Tool) -> Json

Converts a tool definition to a JSON object matching the API specification

Search Document