Skip to content

Serialize chat-created model pricing as hashes#796

Merged
crmne merged 1 commit into
crmne:mainfrom
cyphercodes:fix-chat-model-pricing-jsonb-784
Jun 8, 2026
Merged

Serialize chat-created model pricing as hashes#796
crmne merged 1 commit into
crmne:mainfrom
cyphercodes:fix-chat-model-pricing-jsonb-784

Conversation

@cyphercodes

Copy link
Copy Markdown
Contributor

What this does

Fixes #784 by converting Model::Info wrapper objects to plain hashes before persisting models created through chat model resolution. This keeps modalities and pricing JSON columns in the same shape as acts_as_model registry sync.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Required for new features

  • I opened an issue before writing code and received maintainer approval
  • Linked issue: #___

PRs for new features or enhancements without a prior approved issue will be closed.

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
    • For provider changes: Re-recorded VCR cassettes with bundle exec rake vcr:record[provider_name]
    • All tests pass: bundle exec rspec
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

AI-generated code

  • I used AI tools to help write this code
  • I have reviewed and understand all generated code (required if above is checked)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Tests

  • bundle exec rspec spec/ruby_llm/active_record/acts_as_model_spec.rb
  • bundle exec rubocop lib/ruby_llm/active_record/chat_methods.rb spec/ruby_llm/active_record/acts_as_model_spec.rb
  • bundle exec rspec spec/ruby_llm/active_record
  • Pre-commit overcommit hooks (Gitleaks, TrailingWhitespace, RuboCop, AppraisalUpdate, Flay, RSpec)

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.55%. Comparing base (4c24878) to head (70e564d).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #796   +/-   ##
=======================================
  Coverage   87.55%   87.55%           
=======================================
  Files         125      125           
  Lines        5872     5872           
  Branches     1460     1460           
=======================================
  Hits         5141     5141           
  Misses        731      731           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@crmne crmne merged commit 03a636e into crmne:main Jun 8, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] find_or_create_model! writes pricing to JSONB without .to_h

2 participants