
ABAP SDK for Google Cloud’s latest release version V1.11 now supports Anthropic Models on Vertex AI. For SAP customers, the ABAP SDK for Google Cloud has been a game-changer, seamlessly integrating Google Cloud services directly into their SAP landscapes. Now, with exciting new support for Anthropic’s Claude & Opus models within Vertex AI, the possibilities for enhanced business processes are expanding even further!
The addition of Anthropic’s Claude models provides SAP developers and users with more choice and flexibility in their AI strategy. Claude, known for its strong reasoning capabilities, nuanced understanding, and longer context windows, is an excellent addition for tasks requiring sophisticated analysis and evaluation.
In this blog we will explore how we can combine the image generation capabilities of Google’s Imagen models and evaluate them using Anthropic Claude Sonnet 4. The use case we will consider is: Generating missing product catalog images using Imagen models and then intelligently evaluating them with Anthropic’s Claude Sonnet. This powerful combination showcases the ABAP SDK for Google Cloud versatility and the significant value that large language models (LLMs) can bring to your SAP environment.
For businesses dealing with vast product catalogs, managing images can be a significant challenge. Missing or low-quality images can directly impact sales and customer experience. This is where the power of generative AI like Imagen comes into play. Imagen is Google’s text-to-image diffusion model, meaning it generates images from text descriptions. It’s a state-of-the-art AI that can create photorealistic images based on textual prompts. However, simply generating images isn’t enough; they need to be evaluated for suitability. This is where Anthropic Claude Sonnet steps in, providing intelligent, automated assessment to ensure quality and relevance.
The Use Case: From Image Generation to Intelligent Evaluation
Imagine you have a product catalog with thousands of items, but some entries are missing images. Manually sourcing or creating these can be time-consuming and expensive. This is where our solution shines:
- Automated Image Generation with Imagen: We’ll use Google’s Imagen model via Vertex AI to generate high-quality, professional product images based on textual descriptions from your SAP material master data and additional set of programmed instructions.
- Intelligent Image Evaluation with Anthropic Claude Sonnet: Once images are generated, Claude Sonnet will act as your “professional product catalog analyst.” It will evaluate the generated images against predefined criteria like commercial viability, technical accuracy, and professional presentation standards, providing a rating and detailed feedback.
This automated workflow significantly accelerates the process of enriching your product catalog, ensuring consistency and quality with minimal manual intervention. You can then build the workflow to update the product catalog images into your DMS (Document Management System).
ABAP Code in Action: A Sneak Peek
Below is the ABAP code snippet that orchestrates this entire process. It demonstrates how to interact with Vertex AI’s Imagen for image generation and then with Anthropic Claude for evaluation, all within your SAP system.
High-Level Algorithm: What’s Happening Behind the Scenes?
The ABAP code snippet provide above follows the below described logical flow:
- Initialization:
The program sets up necessary data structures and variables, including API client keys, model IDs (for Imagen and Claude), Google Cloud Storage (GCS) bucket URIs, and the number of images to generate. These are marked as TODO
for developers to set their specific values.
2. Imagen Model Invocation (Image Generation):
- An instance of the AI Platform V1 service (
/goog/cl_aiplatform_v1
) is created using your client key. - A prompt for image generation (e.g., “Generate an image of Spark Plug…”) is defined.
- Input parameters for the Imagen model are prepared, specifying the number of images to generate (
sample_count
) and the GCS bucket where generated images will be stored (storage_uri
). - The
predict_models
method is called to send the image generation request to Vertex AI’s Imagen model. - The response from Imagen, containing the GCS URIs and MIME types of the generated images, is processed and stored.
3. Image Retrieval from GCS:
- An instance of the Google Cloud Storage V1 service (
/goog/cl_storage_v1
) is created. - For each generated image’s GCS URI, the code downloads the image data from the specified bucket and object.
- The downloaded binary image data is then encoded into Base64 format. This is crucial because LLMs like Claude expect image data in Base64 for multi-modal input.
4. Anthropic Claude Model Invocation (Image Evaluation):
- An instance of the Anthropic Claude model service (
/goog/cl_model_claude
) is created, specifying the Claude Sonnet model key. - For each downloaded and Base64-encoded image, the
set_inline_data
method is used to attach the image data and its MIME type to the Claude request. - System instructions are defined for Claude, setting its persona as a “professional product catalog analyst” and providing a clear rating scale. This guides Claude’s behavior and ensures relevant output.
- A user prompt is constructed, providing Claude with context (SAP Material Master, Automotive Spark Plug), the original Imagen prompt, the task (analyze and assess images), and image names for reference.
- The
generate_content
method is called to send the evaluation request to Claude. - The textual response from Claude, containing the individual analysis, comparative ranking, and final recommendations for the images, is retrieved and displayed.
5. Error Handling:
- The entire process is wrapped in a
TRY...CATCH
block to gracefully handle any exceptions that might occur during API calls to Google Cloud.
Generate Images and Program Output
Image 1
Image 2
Progam Output:
Source Credit: https://medium.com/google-cloud/leveraging-imagen-anthropic-claude-with-abap-sdk-for-google-cloud-for-product-imagery-2bbc3ea98495?source=rss—-e52cf94d98af—4