Generic LLMs improvements (#605)

* Generic LLMs improvements

  1. app/models/provider/openai/auto_categorizer.rb:535-540
  - If description is blank, now falls back to merchant name

  2. app/models/provider/openai/auto_merchant_detector.rb:492-498
  - Now includes merchant first, then description (joined with " - ")

* FIX linter
This commit is contained in:
soky srm
2026-01-11 10:32:03 +01:00
committed by GitHub
parent 3dfa569bed
commit a5bccaf2a1
4 changed files with 9 additions and 6 deletions

View File

@@ -534,7 +534,8 @@ class Provider::Openai::AutoCategorizer
# Format transactions in a simpler, more readable way for smaller LLMs
def format_transactions_simply
transactions.map do |t|
"- ID: #{t[:id]}, Amount: #{t[:amount]}, Type: #{t[:classification]}, Description: \"#{t[:description]}\""
description = t[:description].presence || t[:merchant].presence || ""
"- ID: #{t[:id]}, Amount: #{t[:amount]}, Type: #{t[:classification]}, Description: \"#{description}\""
end.join("\n")
end
end

View File

@@ -491,7 +491,9 @@ class Provider::Openai::AutoMerchantDetector
# Format transactions in a simpler, more readable way for smaller LLMs
def format_transactions_simply
transactions.map do |t|
"- ID: #{t[:id]}, Description: \"#{t[:name] || t[:description]}\""
parts = [ t[:merchant], t[:description] ].compact.reject(&:blank?)
combined = parts.join(" - ")
"- ID: #{t[:id]}, Description: \"#{combined}\""
end.join("\n")
end
end