Skip to content

Conversation

@andrej1991
Copy link
Contributor

@andrej1991 andrej1991 commented Oct 28, 2025

Description

This change is needed, due to the llama_stack and llama_stack_client config was moved to the release 0.2.22 in the lightspeed-core v0.3.0.
Llama-stack release-0.2.21 introduced this change: https://github.com/llamastack/llama-stack/pull/3253/files
The change was introduced because llama-stack in the future will support VectorStores against VectorDBs.

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

Related Tickets & Documents

  • Related Issue #
  • Closes #

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

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • New Features

    • Persist and surface provider vector DB identifiers in saved configs; add local filesystem files provider support.
  • Bug Fixes

    • Stricter handling of node types: non-text nodes are warned, excluded from results, and return structured errors in JSON mode.
    • Improved text extraction with a fallback and clearer debug logging for skipped entries.
  • Chores

    • Relaxed dependency pins to allow newer releases; added stricter type-checking settings.
  • Tests

    • Updated tests to validate provider vector DB persistence and adjusted YAML expectations.

@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Walkthrough

Relaxed exact dependency pins and added mypy options in pyproject.toml. Strengthened node-type checks and JSON/error handling in scripts/query_rag.py. Added provider_vector_db_id propagation and a local filesystem provider to LlamaStack YAML generation and switched to the core llama-stack client. Tests updated to validate YAML and provider_vector_db_id flow.

Changes

Cohort / File(s) Summary
Configuration & Dependencies
pyproject.toml
Added mypy options (mypy_path, namespace_packages, explicit_package_bases) and relaxed exact dependency pins (== → >=) for PyYAML, faiss-cpu, torch, aiosqlite, sqlite-vec, llama-index packages; bumped llama-stack and llama-stack-client versions.
Query Logic
scripts/query_rag.py
Enforced stricter typing: single-node path requires TextNode (warns/errors otherwise); multi-node aggregation filters to NodeWithScore only and uses cast(...); improved text fallback using base_node.node.get_content(); added JSON error output and logging adjustments; updated llama-stack client import to stack_lib.core.library_client.
Document Processing & LlamaStack Integration
src/lightspeed_rag_content/document_processor.py
Extended LlamaStack YAML template with a files local filesystem provider and {provider_vector_db_id} placeholder. write_yaml_config signature gains optional provider_vector_db_id. save now threads provider_vector_db_id into YAML generation and uses llama_stack.core.library_client.
Tests & Fixtures
tests/test_document_processor_llama_stack.py
Added FAISS_EXPECTED YAML fixture constant and tests verifying provider_vector_db_id; updated tests to use dynamic vector_store_id and to pass/mock provider_vector_db_id through write_yaml_config and save flows.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Processor as _LlamaStackDB.save
    participant Config as write_yaml_config
    participant Client as LlamaStackAsLibraryClient
    participant VectorDB as vector_io.insert

    User->>Processor: save(documents, index_id)
    Processor->>Config: write_yaml_config(index_id, filename, db_file, provider_vector_db_id)
    Config-->>Processor: YAML with provider_vector_db_id persisted
    Processor->>Client: start client (llama_stack.core.library_client)
    Client-->>Processor: client instance
    Processor->>Client: vector_dbs.list()/select -> provider_vector_db_id
    Processor->>VectorDB: insert(..., vector_db_id=provider_vector_db_id)
    VectorDB-->>Processor: success
    Processor-->>User: save complete
Loading
sequenceDiagram
    participant User
    participant QueryScript as scripts/query_rag.py
    participant Index as llama-index search
    participant Output as stdout/JSON

    User->>QueryScript: run query
    QueryScript->>Index: search
    Index-->>QueryScript: result (single-node or multiple)
    alt single-node
        QueryScript->>QueryScript: require TextNode else warn/error
        QueryScript->>Output: TextNode content or JSON error (exit 1)
    else multi-node
        QueryScript->>QueryScript: filter NodeWithScore entries only
        QueryScript->>Output: list of {id, score, text, metadata}
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • YAML template formatting/indentation for the new files provider block and {provider_vector_db_id} placeholder
    • Correct propagation and naming of provider_vector_db_id in write_yaml_config, save, and vector insert calls
    • scripts/query_rag.py changes around TextNode vs NodeWithScore handling and JSON error semantics
    • Updated import path for the llama-stack client and any runtime compatibility consequences

Possibly related PRs

Suggested reviewers

  • tisnik
  • umago
  • lpiwowar

Poem

🐰 I nibble YAML lines and tuck a vector id inside,
I cast a node by score and gently skip the stride.
From distribution to core I hopped the client door,
Tests clap tiny paws — configs bloom and code hops more! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "adding the ability to work with llama_stack release-0.2.22" directly captures the primary objective of this changeset. The modifications across all files—including updated dependency pins (llama-stack 0.2.22), client import path changes (from distribution to core library client), YAML configuration extensions with new placeholders, and node type filtering enhancements—are all essential to achieve compatibility with llama_stack 0.2.22. The title is concise, clear, and specific enough that a teammate reviewing the history would immediately understand the core purpose without needing to examine individual file changes.
Docstring Coverage ✅ Passed Docstring coverage is 81.82% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@andrej1991 andrej1991 force-pushed the update_llama branch 5 times, most recently from 1b6456a to a744ec6 Compare October 30, 2025 20:38
@andrej1991 andrej1991 marked this pull request as ready for review October 30, 2025 20:57
@andrej1991 andrej1991 force-pushed the update_llama branch 2 times, most recently from da9ef91 to 5b19e46 Compare October 30, 2025 20:59
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d4c9c8 and 5b19e46.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • pyproject.toml (2 hunks)
  • scripts/query_rag.py (4 hunks)
  • src/lightspeed_rag_content/document_processor.py (6 hunks)
  • tests/test_document_processor_llama_stack.py (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_document_processor_llama_stack.py (1)
src/lightspeed_rag_content/document_processor.py (5)
  • write_yaml_config (301-327)
  • _LlamaStackDB (187-404)
  • save (145-150)
  • save (372-404)
  • save (515-518)
⏰ 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). (2)
  • GitHub Check: build-and-push-dev
  • GitHub Check: Pylinter

@andrej1991 andrej1991 force-pushed the update_llama branch 3 times, most recently from 376381d to 00885ce Compare October 31, 2025 12:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lightspeed_rag_content/document_processor.py (1)

1-1: Fix Black formatting to pass CI checks.

The Black formatter reports this file needs reformatting. Please run uv tool run black --write src/lightspeed_rag_content/document_processor.py to fix the formatting issues.

🧹 Nitpick comments (1)
scripts/query_rag.py (1)

39-66: Consider using sys.exit(1) for consistency.

The enhanced single-node type checking and error handling is well-implemented. However, line 66 uses the built-in exit(1) while sys is already imported at line 8. For consistency and explicitness, consider using sys.exit(1).

Apply this diff:

             )
             if args.json:
                 result = {
                     "query": args.query,
                     "type": "single_node",
                     "node_id": args.node,
                     "error": f"Node is not a TextNode (type: {type(node).__name__})",
                 }
                 print(json.dumps(result, indent=2))
-            exit(1)
+            sys.exit(1)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f35c812 and 00885ce.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • pyproject.toml (2 hunks)
  • scripts/query_rag.py (4 hunks)
  • src/lightspeed_rag_content/document_processor.py (6 hunks)
  • tests/test_document_processor_llama_stack.py (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_document_processor_llama_stack.py
🧰 Additional context used
🪛 GitHub Actions: Black
src/lightspeed_rag_content/document_processor.py

[error] 1-1: Black formatting check failed. This file would be reformatted by running 'uv tool run black --write'.

⏰ 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). (2)
  • GitHub Check: build-and-push-dev
  • GitHub Check: Pylinter
🔇 Additional comments (10)
pyproject.toml (2)

23-25: LGTM: Mypy configuration enhances type checking.

The added mypy configuration options properly configure type checking for the project structure with the src layout.


40-52: Verify the broader dependency relaxation aligns with project requirements.

The git diff confirms this PR relaxes version constraints for most dependencies (PyYAML, llama-index packages, faiss-cpu, torch, aiosqlite, sqlite-vec) from exact pins (==) to minimum versions (>=), while keeping llama-stack and llama-stack-client pinned to 0.2.22. The commit message states "adding the ability to work with llama_stack release-0.2.22," but doesn't explain the rationale for the broader relaxation.

This systematic change represents a significant shift in dependency management policy. Please clarify:

  1. Is this broader relaxation intentional, or should it be limited to llama-stack packages only?
  2. Have these relaxed dependencies been tested for compatibility with their latest versions?
  3. Should upper bound constraints be considered (e.g., >=X.Y.Z,<X+1.0.0) to prevent major version jumps?
scripts/query_rag.py (3)

10-10: LGTM: Type safety imports improve code robustness.

The additions of cast, NodeWithScore, and TextNode imports support enhanced type checking and safer node handling throughout the script.

Also applies to: 15-15


106-121: LGTM: Robust multi-node filtering with proper type handling.

The implementation correctly filters nodes to only process NodeWithScore instances, with defensive text extraction that falls back to base_node.node.get_content() when needed. Debug logging for skipped nodes aids troubleshooting.


161-161: LGTM: Client import path updated for llama-stack 0.2.22.

The client import path correctly reflects the library reorganization from distribution.library_client to core.library_client introduced in llama-stack 0.2.22.

src/lightspeed_rag_content/document_processor.py (5)

189-238: LGTM: YAML template updated for llama-stack 0.2.22 configuration structure.

The template additions correctly incorporate the new files API, localfs provider, and provider_vector_db_id placeholder to align with llama-stack's updated configuration schema.


301-307: LGTM: Backward-compatible signature enhancement.

The addition of the optional provider_vector_db_id parameter maintains backward compatibility while supporting the new llama-stack configuration requirements.


295-295: LGTM: Client class path updated for llama-stack 0.2.22.

The client class path correctly reflects the reorganization from distribution.library_client to core.library_client in llama-stack 0.2.22.


325-325: Verify YAML handling when provider_vector_db_id is None.

When provider_vector_db_id is None, the template substitution on line 237 will insert an empty string, resulting in a blank line in the generated YAML. Please verify:

  1. Is a blank line acceptable in the llama-stack YAML configuration?
  2. Should the template conditionally omit the provider_vector_db_id line entirely when it's None?

If blank lines cause YAML parsing issues, consider modifying the template to handle this case explicitly (e.g., using conditional formatting or post-processing to remove empty lines).


384-390: LGTM: Updated save flow correctly propagates provider_vector_db_id.

The save method properly constructs the provider_vector_db_id YAML line and passes it to write_yaml_config, and the vector_io.insert call correctly uses the vector_db_id parameter with manual chunks.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
pyproject.toml (1)

40-52: Verify compatibility with relaxed version constraints.

The dependencies have been changed from exact pins (==) to minimum versions (>=), which improves flexibility but may introduce compatibility issues with newer releases. While llama-stack packages remain pinned to 0.2.22, other dependencies like PyYAML, torch, and llama-index components can now float to newer versions.

Consider testing with the upper bounds of these dependencies to ensure no breaking changes occur, or document the tested version range if specific upper limits are known to cause issues.

src/lightspeed_rag_content/document_processor.py (1)

237-237: Consider YAML formatting when provider_vector_db_id is None.

When provider_vector_db_id is None or not provided, line 325 injects an empty string into the template, which results in a blank line in the YAML output. While this may be acceptable, consider explicitly handling this case for cleaner output:

-                provider_vector_db_id=provider_vector_db_id or "",
+                provider_vector_db_id=f"provider_vector_db_id: {index}" if provider_vector_db_id else "# provider_vector_db_id not configured",

Alternatively, verify that the empty line doesn't cause issues with YAML parsing.

Also applies to: 325-325

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00885ce and deb39c0.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • pyproject.toml (2 hunks)
  • scripts/query_rag.py (4 hunks)
  • src/lightspeed_rag_content/document_processor.py (6 hunks)
  • tests/test_document_processor_llama_stack.py (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_document_processor_llama_stack.py
⏰ 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: build-and-push-dev
🔇 Additional comments (9)
pyproject.toml (1)

23-25: LGTM! Mypy configuration is appropriate.

The added mypy options are standard best practices for src-layout projects and will improve type checking accuracy.

scripts/query_rag.py (4)

10-10: LGTM! Import additions support improved type safety.

The new imports enable stronger type checking for node handling throughout the script.

Also applies to: 15-15


161-161: LGTM! Client path updated for llama_stack 0.2.22 compatibility.

The migration from distribution.library_client to core.library_client aligns with the llama_stack release-0.2.22 restructuring mentioned in the PR objectives.


39-66: LGTM! Robust type checking and error handling for single-node queries.

The implementation correctly validates that retrieved nodes are TextNode instances and provides clear error messages in both JSON and non-JSON modes.


105-121: LGTM! NodeWithScore filtering adds defensive type checking.

The implementation correctly filters results to only include NodeWithScore instances, with appropriate debug logging for any skipped entries. The text extraction fallback using get_content() provides resilience against missing attributes.

src/lightspeed_rag_content/document_processor.py (4)

210-217: Verify the hard-coded /tmp/llama-stack-files path.

The files provider configuration uses a hard-coded temporary directory path. Consider whether this should be:

  • Configurable via parameter or environment variable
  • Created within the same temporary directory as the rest of the llama-stack config
  • Documented for users who may need to manage this directory

Can you confirm if this path needs to be configurable or if the hard-coded /tmp location is intentional for all deployment scenarios?


301-307: LGTM! Backward-compatible signature extension.

The addition of the optional provider_vector_db_id parameter maintains backward compatibility while enabling the new configuration flow required for llama_stack 0.2.22.


295-295: LGTM! Client path updated for llama_stack 0.2.22 compatibility.

The migration to core.library_client is consistent with the changes in scripts/query_rag.py and aligns with the llama_stack restructuring in release-0.2.22. The docstring has been appropriately updated as well.

Also applies to: 333-333


384-386: LGTM! provider_vector_db_id correctly propagated to YAML generation.

The save method now passes the provider_vector_db_id configuration through to write_yaml_config, enabling the new VectorDB provider integration mentioned in the PR objectives.

Copy link
Collaborator

@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

Copy link
Collaborator

@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 fb0d979 into lightspeed-core:main Oct 31, 2025
14 of 15 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.

2 participants