feather-ai 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/CLAUDE.md +1 -1
- data/README.md +3 -2
- data/lib/feather_ai/consensus.rb +2 -0
- data/lib/feather_ai/identifier.rb +24 -2
- data/lib/feather_ai/rails/acts_as_sighting.rb +1 -0
- data/lib/feather_ai/result.rb +3 -1
- data/lib/feather_ai/version.rb +1 -1
- data/lib/generators/feather_ai/templates/migration.rb.tt +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6095127574afcfa266d46eb362e8cc0fe26d0ef15aab75c56ac4a0e21f7ce78
|
|
4
|
+
data.tar.gz: 9f12db0e48af3afbe0d14d8cacaee0f926ba1412752ca5ebe95ad7a7bbba702a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76305cb6279ef89a2ed44ddca0c9c93104a7dd5386c4ec31b9043892bcbcb744c80e5751e4852226f959cb8031738d7289326e4daafccb01a05ccac5b3c3bec9
|
|
7
|
+
data.tar.gz: bc11c564716fcce4a28206672d6dd6d5be8269203c7bc7c4339f49bcb42abbd6b261580aead6e4cf65d60d03d34b4ca303c39d886ff1b5b5f3121769e99e3f66
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0 - 2026-11-24
|
|
4
|
+
|
|
5
|
+
- `Result#field_marks`: up to four `{ category:, summary: }` hashes giving the evidence for the identification in plain language, one per category (`FeatherAi::Identifier::FIELD_MARK_CATEGORIES`). Written for the person who took the photo, unlike `reasoning`, which stays the model's working.
|
|
6
|
+
- Each entry in `candidates` now carries a `note:` — one sentence on what separates that alternative from the identification (`nil` for the first entry and for vote-share candidates on consensus disagreement).
|
|
7
|
+
- Consensus: when the models agree, the result now carries the primary model's `reasoning` (previously dropped) and `field_marks`. On disagreement `field_marks` is empty.
|
|
8
|
+
- Rails: `identify!` persists `field_marks` when the model has that column, and the install generator adds it (jsonb). Existing apps need their own migration to store it.
|
|
9
|
+
|
|
3
10
|
## 0.6.0 - 2026-11-24
|
|
4
11
|
|
|
5
12
|
- **Breaking:** default `model` (and the first of `consensus_models`) is now `claude-sonnet-5-5`. Anthropic retires `claude-sonnet-4-5` on 2026-11-30, after which the old default stops working. `tips_model` stays on `claude-haiku-4-5`.
|
data/CLAUDE.md
CHANGED
|
@@ -52,7 +52,7 @@ The gem's only runtime dependency is `ruby_llm` 2.x (which pulls in `schematist`
|
|
|
52
52
|
|
|
53
53
|
2. **Consensus** (`lib/feather_ai/consensus.rb`) — When `consensus: true`, runs identification through the configured `consensus_models` in parallel threads. Agreement is compared on normalized species name. If they agree, returns `confident: true`; if they disagree, returns both as `candidates` with low confidence. Token counts, cost, and duration are summed across models.
|
|
54
54
|
|
|
55
|
-
3. **Result** (`lib/feather_ai/result.rb`) — Immutable value object wrapping all identification output. Identification fields: `common_name`, `species`, `family`, `confidence` (`:high`/`:medium`/`:low`), `confident?`, `region_native?`, `reasoning`, `candidates
|
|
55
|
+
3. **Result** (`lib/feather_ai/result.rb`) — Immutable value object wrapping all identification output. Identification fields: `common_name`, `species`, `family`, `confidence` (`:high`/`:medium`/`:low`), `confident?`, `region_native?`, `reasoning`, `field_marks` (plain-language evidence, one per category), `candidates` (each with a `note`), `photography_tips`, `to_h`. Observability fields from the LLM call: `model_id`, `input_tokens`, `output_tokens`, `cost`, `duration_ms`, `source` (`:vision`/`:audio`/`:multimodal`), `consensus_models`. Photography tips are lazy-loaded via a second cheap LLM call only when accessed.
|
|
56
56
|
|
|
57
57
|
4. **PhotographyTips** (`lib/feather_ai/photography_tips.rb`) — Separate LLM call (uses `tips_model`, a small model) returning structured shooting advice for the identified species. Only invoked when `result.photography_tips` is called.
|
|
58
58
|
|
data/README.md
CHANGED
|
@@ -160,7 +160,8 @@ All identification calls return a `FeatherAi::Result`:
|
|
|
160
160
|
| `confidence` | Symbol | `:high`, `:medium`, or `:low` |
|
|
161
161
|
| `confident?` | Boolean | `true` when confidence is `:high` |
|
|
162
162
|
| `region_native?` | Boolean | Whether species is native to the given region |
|
|
163
|
-
| `
|
|
163
|
+
| `field_marks` | Array | Up to four `{ category:, summary: }` hashes: the evidence for the identification in plain language, one per category (`plumage`, `size_and_shape`, `behaviour`, `habitat`, `flight`, `voice`) |
|
|
164
|
+
| `candidates` | Array | Ranked candidate hashes (`common_name`, `species`, `score`, `note`); `note` says what separates an alternative from the identification. Vote-share ranked, without notes, on consensus disagreement |
|
|
164
165
|
| `photography_tips` | Hash | Lazy-loaded shooting advice |
|
|
165
166
|
| `to_h` | Hash | All fields as a plain hash |
|
|
166
167
|
|
|
@@ -206,7 +207,7 @@ class Sighting < ApplicationRecord
|
|
|
206
207
|
end
|
|
207
208
|
```
|
|
208
209
|
|
|
209
|
-
The generator adds these columns to the model's table: `common_name`, `species`, `family`, `confidence`, `region_native`, `candidates` (jsonb). On existing tables, `identify!` persists ranked candidates only when a `candidates` column is present — add
|
|
210
|
+
The generator adds these columns to the model's table: `common_name`, `species`, `family`, `confidence`, `region_native`, `candidates` (jsonb), `field_marks` (jsonb). On existing tables, `identify!` persists ranked candidates and field marks only when a `candidates` / `field_marks` column is present — add them in your own migration or skip them.
|
|
210
211
|
|
|
211
212
|
### Identifying Records
|
|
212
213
|
|
data/lib/feather_ai/consensus.rb
CHANGED
|
@@ -69,6 +69,8 @@ module FeatherAi
|
|
|
69
69
|
confidence: :high,
|
|
70
70
|
region_native: primary.region_native?,
|
|
71
71
|
model_id: primary.model_id,
|
|
72
|
+
reasoning: primary.reasoning,
|
|
73
|
+
field_marks: primary.field_marks,
|
|
72
74
|
candidates: primary.candidates,
|
|
73
75
|
photography_tips_loader: tips_loader_for(primary)
|
|
74
76
|
}
|
|
@@ -4,7 +4,9 @@ module FeatherAi
|
|
|
4
4
|
# Core bird identification using LLM vision and audio transcription.
|
|
5
5
|
# rubocop:disable-next Metrics/ClassLength
|
|
6
6
|
class Identifier
|
|
7
|
-
|
|
7
|
+
FIELD_MARK_CATEGORIES = %w[plumage size_and_shape behaviour habitat flight voice].freeze
|
|
8
|
+
|
|
9
|
+
SCHEMA = Schematist::Schema.create do # rubocop:disable Metrics/BlockLength
|
|
8
10
|
string :reasoning,
|
|
9
11
|
description: "Step-by-step visual analysis: describe body size, bill shape, " \
|
|
10
12
|
"plumage, markings, and rule out similar species before identifying"
|
|
@@ -13,6 +15,16 @@ module FeatherAi
|
|
|
13
15
|
string :family, description: "Bird family name"
|
|
14
16
|
string :confidence, description: "Identification confidence: high, medium, or low"
|
|
15
17
|
boolean :region_native, description: "Whether this species is native to the given region"
|
|
18
|
+
array :field_marks, max_items: 4,
|
|
19
|
+
description: "The evidence for your identification, for the person who took the photo: " \
|
|
20
|
+
"each category may appear only once, most diagnostic first, " \
|
|
21
|
+
"only what you actually observed" do
|
|
22
|
+
object do
|
|
23
|
+
string :category, enum: FIELD_MARK_CATEGORIES
|
|
24
|
+
string :summary, description: "One sentence of at most 15 words in everyday English that a beginner " \
|
|
25
|
+
"can check against the photo; no technical terms"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
16
28
|
array :candidates, min_items: 1, max_items: 3,
|
|
17
29
|
description: "Candidate species ranked most to least likely; " \
|
|
18
30
|
"the first entry must match your identification" do
|
|
@@ -20,6 +32,8 @@ module FeatherAi
|
|
|
20
32
|
string :common_name, description: "Common name of the candidate"
|
|
21
33
|
string :species, description: "Scientific species name (Genus species)"
|
|
22
34
|
number :score, minimum: 0, maximum: 1, description: "Relative likelihood of this candidate"
|
|
35
|
+
string :note, description: "One sentence of at most 15 words in everyday English on what separates " \
|
|
36
|
+
"this candidate from your identification; empty string for the first entry"
|
|
23
37
|
end
|
|
24
38
|
end
|
|
25
39
|
end
|
|
@@ -121,17 +135,25 @@ module FeatherAi
|
|
|
121
135
|
family: parsed["family"],
|
|
122
136
|
confidence: parsed["confidence"],
|
|
123
137
|
region_native: parsed["region_native"],
|
|
138
|
+
field_marks: normalize_field_marks(parsed["field_marks"]),
|
|
124
139
|
candidates: normalize_candidates(parsed["candidates"]),
|
|
125
140
|
photography_tips_loader: tips_loader(parsed)
|
|
126
141
|
}
|
|
127
142
|
end
|
|
128
143
|
|
|
144
|
+
def normalize_field_marks(field_marks)
|
|
145
|
+
Array(field_marks).map { |mark| { category: mark["category"], summary: mark["summary"] } }
|
|
146
|
+
.uniq { |mark| mark[:category] }
|
|
147
|
+
end
|
|
148
|
+
|
|
129
149
|
def normalize_candidates(candidates)
|
|
130
150
|
Array(candidates).map do |candidate|
|
|
151
|
+
note = candidate["note"].to_s.strip
|
|
131
152
|
{
|
|
132
153
|
common_name: candidate["common_name"],
|
|
133
154
|
species: candidate["species"],
|
|
134
|
-
score: candidate["score"]
|
|
155
|
+
score: candidate["score"],
|
|
156
|
+
note: note.empty? ? nil : note
|
|
135
157
|
}
|
|
136
158
|
end
|
|
137
159
|
end
|
data/lib/feather_ai/result.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module FeatherAi
|
|
4
4
|
# Immutable value object wrapping all identification output.
|
|
5
5
|
class Result
|
|
6
|
-
attr_reader :common_name, :species, :family, :confidence, :region_native, :reasoning, :candidates,
|
|
6
|
+
attr_reader :common_name, :species, :family, :confidence, :region_native, :reasoning, :candidates, :field_marks,
|
|
7
7
|
:input_tokens, :output_tokens, :cost, :model_id, :duration_ms, :source,
|
|
8
8
|
:consensus_models
|
|
9
9
|
|
|
@@ -44,6 +44,7 @@ module FeatherAi
|
|
|
44
44
|
@region_native = attrs[:region_native]
|
|
45
45
|
@reasoning = attrs[:reasoning]
|
|
46
46
|
@candidates = attrs[:candidates] || []
|
|
47
|
+
@field_marks = attrs[:field_marks] || []
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def assign_photography_attrs(attrs)
|
|
@@ -71,6 +72,7 @@ module FeatherAi
|
|
|
71
72
|
confidence: @confidence,
|
|
72
73
|
confident: confident?,
|
|
73
74
|
region_native: region_native?,
|
|
75
|
+
field_marks: @field_marks,
|
|
74
76
|
candidates: @candidates
|
|
75
77
|
}
|
|
76
78
|
end
|
data/lib/feather_ai/version.rb
CHANGED
|
@@ -6,5 +6,6 @@ class AddFeatherAiFieldsTo<%= model_name.camelize.pluralize %> < ActiveRecord::M
|
|
|
6
6
|
add_column :<%= model_name.underscore.pluralize %>, :confidence, :string
|
|
7
7
|
add_column :<%= model_name.underscore.pluralize %>, :region_native, :boolean
|
|
8
8
|
add_column :<%= model_name.underscore.pluralize %>, :candidates, :jsonb
|
|
9
|
+
add_column :<%= model_name.underscore.pluralize %>, :field_marks, :jsonb
|
|
9
10
|
end
|
|
10
11
|
end
|