Class: FeatherAi::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/feather_ai/identifier.rb

Overview

Core bird identification using LLM vision and audio transcription. rubocop:disable Metrics/ClassLength

Constant Summary collapse

SCHEMA =
RubyLLM::Schema.create do
  string :reasoning,
         description: "Step-by-step visual analysis: describe body size, bill shape, " \
                      "plumage, markings, and rule out similar species before identifying"
  string :common_name, description: "Common name of the bird"
  string :species, description: "Scientific species name (Genus species)"
  string :family, description: "Bird family name"
  string :confidence, description: "Identification confidence: high, medium, or low"
  boolean :region_native, description: "Whether this species is native to the given region"
  array :candidates, min_items: 1, max_items: 3,
                     description: "Candidate species ranked most to least likely; " \
                                  "the first entry must match your identification" do
    object do
      string :common_name, description: "Common name of the candidate"
      string :species, description: "Scientific species name (Genus species)"
      number :score, minimum: 0, maximum: 1, description: "Relative likelihood of this candidate"
    end
  end
end
PROVIDER_RATES =

Approximate mid-2025 rates (USD per 1M tokens). Use your provider's dashboard for billing accuracy — these are estimates.

{
  anthropic: { input: 3.00, output: 15.00 }
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config: FeatherAi.configuration) ⇒ Identifier

Returns a new instance of Identifier.



33
34
35
# File 'lib/feather_ai/identifier.rb', line 33

def initialize(config: FeatherAi.configuration)
  @config = config
end

Instance Method Details

#identify(image = nil, audio = nil, location: nil, tools: nil) ⇒ Object

Parameters:

  • image (String, Array<String>, nil) (defaults to: nil)

    path(s) to image file(s)

  • audio (String, nil) (defaults to: nil)

    path to audio file

  • tools (Array, nil) (defaults to: nil)

    RubyLLM tools (classes or instances) the model may call for grounding



40
41
42
43
44
# File 'lib/feather_ai/identifier.rb', line 40

def identify(image = nil, audio = nil, location: nil, tools: nil)
  images = normalize_images(image)
  validate_inputs!(images, audio)
  run_identification(images, audio, location || @config.location, Array(tools || @config.tools))
end