Skip to content

Add support for caching - #30

Merged
krypticmouse merged 3 commits into
mainfrom
cache-implement
Oct 10, 2025
Merged

Add support for caching#30
krypticmouse merged 3 commits into
mainfrom
cache-implement

Conversation

@krypticmouse

Copy link
Copy Markdown
Owner

This pull request introduces a new caching mechanism for predictions, refactors some utility imports, and enhances the Prediction data structure for better interoperability. The most important changes are grouped below:

Caching Infrastructure:

  • Added a new ResponseCache implementation in crates/dspy-rs/src/utils/cache.rs using the foyer and tempfile crates, providing an async hybrid in-memory and disk-backed cache for predictions. This includes a generic Cache trait for extensibility.
  • Updated dependencies in crates/dspy-rs/Cargo.toml to include foyer (for caching) and tempfile (for temporary directory management).

Data Structure Improvements:

  • Enhanced the Prediction struct in crates/dspy-rs/src/data/prediction.rs to support conversion from a vector of key-value pairs and iteration over its data, improving flexibility and compatibility with the caching layer.
  • Added serde_json::Value import to support the new data handling in Prediction.

Utility Refactoring:

  • Refactored imports in crates/dspy-rs/src/adapter/chat.rs to use serde_utils::get_iter_from_value instead of the previous location, supporting the new module structure.
  • Created new utility modules cache and serde_utils in crates/dspy-rs/src/utils/mod.rs, and re-exported their contents for easier access throughout the codebase.

Closes #21

@krypticmouse
krypticmouse merged commit c143189 into main Oct 10, 2025
10 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.

Add support for Caching

1 participant