Class AnthropicSkillsResponseHelper
java.lang.Object
org.springframework.ai.anthropic.AnthropicSkillsResponseHelper
Helper utilities for working with Anthropic Claude Skills responses and files. Provides
methods to extract file IDs, container IDs, and download files generated by Skills.
Unlike the RestClient module's helper which requires recursive Map/List crawling to
find file IDs in untyped response structures, this SDK-based helper uses the SDK's
typed ContentBlock variants with direct accessor methods.
- Since:
- 2.0.0
- Author:
- Soby Chacko
-
Method Summary
Modifier and TypeMethodDescriptiondownloadAllFiles(org.springframework.ai.chat.model.ChatResponse response, com.anthropic.client.AnthropicClient client, Path targetDir) Download all files from a Skills response to a target directory.static @Nullable StringextractContainerId(@Nullable org.springframework.ai.chat.model.ChatResponse response) Extract container ID from a chat response for multi-turn conversation reuse.extractFileIds(@Nullable org.springframework.ai.chat.model.ChatResponse response) Extract all file IDs from a chat response.
-
Method Details
-
extractFileIds
public static List<String> extractFileIds(@Nullable org.springframework.ai.chat.model.ChatResponse response) Extract all file IDs from a chat response. Searches through all content blocks in the underlying SDKMessagestored in response metadata.- Parameters:
response- the chat response to search- Returns:
- list of file IDs found in the response (empty list if none found)
-
extractContainerId
public static @Nullable String extractContainerId(@Nullable org.springframework.ai.chat.model.ChatResponse response) 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(org.springframework.ai.chat.model.ChatResponse response, com.anthropic.client.AnthropicClient client, Path targetDir) throws IOException Download all files from a Skills response to a target directory.- Parameters:
response- the chat response containing file IDsclient- the Anthropic client to use for downloading (beta files API)targetDir- directory to save files (must exist)- Returns:
- list of paths to saved files
- Throws:
IOException- if file download or saving fails
-