Files
sure/db/migrate/20251022144638_create_llm_usages.rb
soky srm bb364fab38 LLM cost estimation (#223)
* Password reset back button also after confirmation

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>

* Implement a filter for category (#215)

- Also implement an is empty/is null condition.

* Implement an LLM cost estimation page

Track costs across all the cost categories: auto categorization, auto merchant detection and chat.
Show warning with estimated cost when running a rule that contains AI.

* Update pricing

* Add google pricing

and fix inferred model everywhere.

* Update app/models/llm_usage.rb

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: soky srm <sokysrm@gmail.com>

* FIX address review

* Linter

* Address review

- Lowered log level
- extracted the duplicated record_usage method into a shared concern

* Update app/controllers/settings/llm_usages_controller.rb

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: soky srm <sokysrm@gmail.com>

* Moved attr_reader out of private

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Signed-off-by: soky srm <sokysrm@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-10-24 00:08:59 +02:00

21 lines
737 B
Ruby

class CreateLlmUsages < ActiveRecord::Migration[7.2]
def change
create_table :llm_usages, id: :uuid do |t|
t.references :family, null: false, foreign_key: true, type: :uuid
t.string :provider, null: false
t.string :model, null: false
t.string :operation, null: false
t.integer :prompt_tokens, null: false, default: 0
t.integer :completion_tokens, null: false, default: 0
t.integer :total_tokens, null: false, default: 0
t.decimal :estimated_cost, precision: 10, scale: 6, null: false, default: 0.0
t.jsonb :metadata, default: {}
t.timestamps
end
add_index :llm_usages, [ :family_id, :created_at ]
add_index :llm_usages, [ :family_id, :operation ]
end
end