mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
**Description:** Adds support for prompt caching usage metadata in ChatGroq. The integration now captures cached token information from the Groq API response and includes it in the `input_token_details` field of the `usage_metadata`. Changes: - Created new `_create_usage_metadata()` helper function to centralize usage metadata creation logic - Extracts `cached_tokens` from `prompt_tokens_details` in API responses and maps to `input_token_details.cache_read` - Integrated the helper function in both streaming (`_convert_chunk_to_message_chunk`) and non-streaming (`_create_chat_result`) code paths - Added comprehensive unit tests to verify caching metadata handling and backward compatibility This enables users to monitor prompt caching effectiveness when using Groq models with prompt caching enabled. **Issue:** N/A **Dependencies:** None --------- Co-authored-by: Mason Daugherty <github@mdrxy.com> Co-authored-by: Mason Daugherty <mason@langchain.dev>