Class SkillsResponseHelper
java.lang.Object
org.springframework.ai.anthropic.SkillsResponseHelper
Helper utilities for working with Claude Skills responses and files. Provides methods
to extract file IDs, container IDs, and download files generated by Skills.
- Since:
- 2.0.0
- Author:
- Soby Chacko
-
Method Summary
Modifier and TypeMethodDescriptiondownloadAllFiles(ChatResponse response, AnthropicApi api, Path targetDir) Download all files from a Skills response to a target directory.static StringextractContainerId(ChatResponse response) Extract container ID from a chat response for multi-turn conversation reuse.extractFileIds(ChatResponse response) Extract all file IDs from a chat response.
-
Method Details
-
extractFileIds
Extract all file IDs from a chat response. Searches through all content blocks in the response, including those in the underlying AnthropicApi response metadata.- Parameters:
response- The chat response to search- Returns:
- List of file IDs found in the response (empty list if none found)
-
extractContainerId
Extract container ID from a chat response for multi-turn conversation reuse.- Parameters:
response- The chat response- Returns:
- Container ID if present, null otherwise
-
downloadAllFiles
public static List<Path> downloadAllFiles(ChatResponse response, AnthropicApi api, Path targetDir) throws IOException Download all files from a Skills response to a target directory.Note: Existing files with the same name will be overwritten. Check for file existence before calling if overwrite protection is needed.
- Parameters:
response- The chat response containing file IDsapi- The Anthropic API client to use for downloadingtargetDir- Directory to save files (must exist)- Returns:
- List of paths to saved files
- Throws:
IOException- if file download or saving fails
-