julep icon indicating copy to clipboard operation
julep copied to clipboard

Fix token count trigger

Open creatorrr opened this issue 6 months ago • 2 comments
trafficstars

User description

Summary

  • use NEW.model inside optimized_update_token_count_after
  • add migration to refresh token count via background job
  • document how to roll out the token count migration

Testing

  • poe check (fails: command not found)

PR Type

enhancement, documentation


Description

  • Updated token count trigger to use dynamic model from NEW.model.

  • Added migration for background job to refresh token counts asynchronously.

  • Provided documentation for rolling out and managing the token count migration.

  • Documented migration and job management steps in new advanced guide.


Changes walkthrough 📝

Relevant files
Enhancement
000042_token_count_background_job.up.sql
Migration for dynamic model token count and batch job       

memory-store/migrations/000042_token_count_background_job.up.sql

  • Introduced migration to update trigger for dynamic model usage.
  • Added optional TimescaleDB job for batch token count updates.
  • Ensured transactional safety with BEGIN/COMMIT.
  • +29/-0   
    000042_token_count_background_job.down.sql
    Migration rollback for token count background job               

    memory-store/migrations/000042_token_count_background_job.down.sql

  • Added migration to drop the updated trigger function.
  • Provided guidance for removing background job if needed.
  • Ensured transactional safety with BEGIN/COMMIT.
  • +7/-0     
    000015_entries.up.sql
    Use dynamic model in token count trigger                                 

    memory-store/migrations/000015_entries.up.sql

  • Modified trigger function to use NEW.model for tokenization.
  • Improved clarity and optimization in token count calculation.
  • +1/-1     
    Documentation
    token-count-background-job.mdx
    Document token count migration and background job               

    documentation/advanced/token-count-background-job.mdx

  • Added new documentation page for token count migration.
  • Explained migration steps and background job setup.
  • Provided rollback and operational guidance.
  • +34/-0   
    CHANGELOG.md
    Changelog entry for token-count migration docs                     

    CHANGELOG.md

    • Noted documentation of token-count background job migration.
    +1/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • creatorrr avatar May 17 '25 17:05 creatorrr