Skip to content

Conversation

@keitwb
Copy link
Contributor

@keitwb keitwb commented Aug 11, 2025

This makes it easier to analyze differences between models.

Before it would only add the model/provider if it was customized in the query.

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

Generate some transcripts and see if the new fields are there.

Summary by CodeRabbit

  • New Features
    • Transcripts now include both the actual model and provider used and the originally requested model/provider for standard and streaming queries.
    • Transcript details (query, response, RAG chunks, truncation, attachments) remain unchanged aside from the added identifiers.
    • Applies when transcript logging is enabled; no changes to query behavior or results.

This makes it easier to analyze differences between models.

Before it would only add the model/provider if it was customized in the query.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Walkthrough

The transcript storage now receives and persists resolved model_id and provider_id alongside the request’s originals. store_transcript’s signature changed to include these IDs, and metadata keys were updated to distinguish actual usage (provider/model) from requested (query_provider/query_model). Unit tests were adjusted to reflect the new parameters and metadata.

Changes

Cohort / File(s) Summary of Changes
Endpoint transcript updates
src/app/endpoints/query.py, src/app/endpoints/streaming_query.py
store_transcript signature expanded to include model_id and provider_id; call sites updated to pass resolved IDs; metadata now records provider/model as actual and adds query_provider/query_model for requested values.
Unit test adjustments
tests/unit/app/endpoints/test_query.py, tests/unit/app/endpoints/test_streaming_query.py
Tests updated to expect new store_transcript parameters and metadata layout; assertions check inclusion of model_id/provider_id and separation of actual vs. requested provider/model.

Sequence Diagram(s)

sequenceDiagram
  participant C as Client
  participant Q as /query endpoint
  participant L as LLM Provider
  participant T as store_transcript

  C->>Q: POST /query (QueryRequest)
  Q->>L: Invoke LLM (resolved provider/model)
  L-->>Q: Response
  Q->>T: store_transcript(user_id, conversation_id, model_id, provider_id, ...)
  T-->>Q: Persisted
  Q-->>C: JSON response
Loading
sequenceDiagram
  participant C as Client
  participant S as /streaming_query endpoint
  participant L as LLM Provider (stream)
  participant T as store_transcript

  C->>S: POST /streaming_query
  S->>L: Start streaming (resolved IDs)
  L-->>S: Streamed tokens
  S-->>C: Streamed tokens
  S->>T: On finalize: store_transcript(..., model_id, provider_id, ...)
  T-->>S: Persisted
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I thump my paws on data trails,
Now model IDs ride the gales.
Provider prints, both asked and used,
Are neatly logged, no bits confused.
With carrots cached and bytes aligned,
This bunny sleeps with peace of mind. 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93f1079 and f7beb32.

📒 Files selected for processing (4)
  • src/app/endpoints/query.py (3 hunks)
  • src/app/endpoints/streaming_query.py (1 hunks)
  • tests/unit/app/endpoints/test_query.py (3 hunks)
  • tests/unit/app/endpoints/test_streaming_query.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e_tests
🔇 Additional comments (8)
src/app/endpoints/query.py (3)

208-209: LGTM! Function call updated correctly.

The resolved model_id and provider_id are now properly passed to store_transcript, enabling better analytics of actual vs requested model/provider usage.


461-462: Function signature extended appropriately.

The new model_id and provider_id parameters are well-positioned and properly typed. The optional nature of provider_id aligns with the function's usage patterns.


489-492: Excellent metadata structure enhancement!

The distinction between actual usage (provider/model) and requested values (query_provider/query_model) enables valuable analytics on model selection patterns and fallback behavior. This design maintains backward compatibility while adding significant analytical capability.

src/app/endpoints/streaming_query.py (1)

467-468: Consistent implementation across streaming endpoint.

The streaming query endpoint correctly mirrors the changes in the non-streaming endpoint, ensuring consistent transcript metadata across both query paths.

tests/unit/app/endpoints/test_streaming_query.py (1)

321-322: Test updated correctly for new function signature.

The test expectations properly validate that store_transcript is called with the resolved model_id and provider_id parameters, ensuring the streaming query endpoint behavior is correctly tested.

tests/unit/app/endpoints/test_query.py (3)

162-163: Test expectations updated correctly.

The test properly validates that store_transcript is called with the resolved model_id and provider_id parameters, ensuring the query endpoint behavior is correctly tested.


1050-1051: Function call test updated appropriately.

The direct test of the store_transcript function correctly passes the new model and provider parameters, maintaining test coverage of the updated function signature.


1065-1068: Comprehensive metadata validation.

The test correctly validates both the actual usage fields (provider/model) and the requested fields (query_provider/query_model), ensuring the enhanced metadata structure is properly tested.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik tisnik merged commit a59de96 into lightspeed-core:main Aug 11, 2025
18 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 15, 2025
18 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 17, 2025
18 tasks
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.

2 participants