Module: LLM::Fillin

Defined in:
lib/llm/fillin/toys.rb,
lib/llm/fillin/version.rb,
lib/llm/fillin/registry.rb,
lib/llm/fillin/validators.rb,
lib/llm/fillin/idempotency.rb,
lib/llm/fillin/orchestrator.rb,
lib/llm/fillin/adapters/store_memory.rb,
lib/llm/fillin/adapters/openai_adapter.rb

Defined Under Namespace

Modules: Idempotency Classes: OpenAIAdapter, Orchestrator, Registry, StoreMemory, Tool, Validators

Constant Summary collapse

CREATE_TOY_V1 =
{
  type: "object", additionalProperties: false,
  properties: {
    name: { type: "string", description: "Toy name" },
    category: { type: "string", enum: %w[plush puzzle doll car lego other] },
    price_minor: { type: "integer", minimum: 0, description: "Price in cents" },
    color: { type: "string", description: "Primary color" }
  },
  required: %w[name category price_minor]
}
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.register_toy_tools!(registry) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/llm/fillin/toys.rb', line 17

def self.register_toy_tools!(registry)
  registry.register!(
    name: "create_toy", version: "v1",
    schema: CREATE_TOY_V1,
    description: "Create a toy with name, category, price (in cents), and optional color.",
    handler: ->(args, ctx) {
      key = Idempotency.generate(thread_id: ctx[:thread_id])
      {
        id: "TOY-#{SecureRandom.hex(3).upcase}",
        name: args["name"],
        category: args["category"],
        price_minor: args["price_minor"],
        color: args["color"] || "unspecified",
        created_by: ctx[:actor_id],
        tenant: ctx[:tenant_id],
        idempotency_key: key
      }
    }
  )
end