feat(client): add optional override default cache ttl capability for prompt caching #1249
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the Langfuse Python SDK’s prompt caching mechanism by enabling runtime overrides of the default 60-second TTL (default_cache_ttl_seconds). It allows developers to optionally specify a custom TTL—or disable caching entirely—during the initialization of the Langfuse client.
Goal
Important
Add capability to override default cache TTL for prompt caching in Langfuse Python SDK, with tests for custom TTL and caching behavior.
default_cache_ttl_seconds
parameter toLangfuse
class inclient.py
to allow overriding the default cache TTL for prompts.PromptCache
inprompt_cache.py
to usedefault_cache_ttl_seconds
if provided.PromptCacheItem
to respect the new TTL setting.test_prompt.py
to verify custom TTL functionality, including overriding default TTL and disabling caching.This description was created by
for ab08393. You can customize this summary. It will automatically update as commits are pushed.
Greptile Summary
Disclaimer: Experimental PR review
Adds capability to override default prompt cache TTL (60 seconds) during Langfuse client initialization, allowing global configuration of prompt caching behavior.
default_cache_ttl_seconds
parameter tolangfuse/_client/client.py
for configuring cache duration at client levellangfuse/_utils/prompt_cache.py
to support custom TTL configuration with backward compatibilitylangfuse/_client/resource_manager.py
to propagate TTL settings through the initialization chaintests/test_prompt.py
verifying custom TTL behavior and cache expiration