- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2k
 
Add observability to Bedrock Titan Embedding model #3014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
            PSriVarshan
  wants to merge
  7
  commits into
  spring-projects:main
from
PSriVarshan:add-observability-to-bedrock-titan
  
      
      
   
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      105aac4
              
                Add observability to Bedrock Titan Embedding model
              
              
                PSriVarshan ed4ae45
              
                Fix formatting issues in BedrockTitanEmbeddingModel.java
              
              
                PSriVarshan 4dccbd1
              
                Fix formatting issues in BedrockTitanEmbeddingModel.java
              
              
                PSriVarshan 4696eb5
              
                Fixing issues in BedrockTitanEmbeddingModel.java
              
              
                PSriVarshan 1f4f61a
              
                Fix formatting issues in BedrockTitanEmbeddingModel.java
              
              
                PSriVarshan b127661
              
                Add observability to Bedrock Titan Embedding model
              
              
                PSriVarshan f35502b
              
                Merge branch 'spring-projects:main' into add-observability-to-bedrock…
              
              
                PSriVarshan File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -17,6 +17,8 @@ | |
| package org.springframework.ai.model.bedrock.titan.autoconfigure; | ||
| 
     | 
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 
     | 
||
| import io.micrometer.observation.ObservationRegistry; | ||
| import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
| import software.amazon.awssdk.regions.providers.AwsRegionProvider; | ||
| 
     | 
||
| 
          
            
          
           | 
    @@ -56,16 +58,35 @@ public class BedrockTitanEmbeddingAutoConfiguration { | |
| public TitanEmbeddingBedrockApi titanEmbeddingBedrockApi(AwsCredentialsProvider credentialsProvider, | ||
| AwsRegionProvider regionProvider, BedrockTitanEmbeddingProperties properties, | ||
| BedrockAwsConnectionProperties awsProperties, ObjectMapper objectMapper) { | ||
| 
     | 
||
| // Validate required properties | ||
| if (properties.getModel() == null || awsProperties.getTimeout() == null) { | ||
| throw new IllegalArgumentException("Required properties for TitanEmbeddingBedrockApi are missing."); | ||
| } | ||
| 
     | 
||
| return new TitanEmbeddingBedrockApi(properties.getModel(), credentialsProvider, regionProvider.getRegion(), | ||
| objectMapper, awsProperties.getTimeout()); | ||
| } | ||
| 
     | 
||
| @Bean | ||
| @ConditionalOnMissingBean | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to other auto configurations, we don't provide the default ObservationRegistry instead provide NOOP registry when none provided. Will update the PR when merging.  | 
||
| public ObservationRegistry observationRegistry() { | ||
| return ObservationRegistry.create(); | ||
| } | ||
| 
     | 
||
| @Bean | ||
| @ConditionalOnMissingBean | ||
| @ConditionalOnBean(TitanEmbeddingBedrockApi.class) | ||
| public BedrockTitanEmbeddingModel titanEmbeddingModel(TitanEmbeddingBedrockApi titanEmbeddingApi, | ||
| BedrockTitanEmbeddingProperties properties) { | ||
| return new BedrockTitanEmbeddingModel(titanEmbeddingApi).withInputType(properties.getInputType()); | ||
| BedrockTitanEmbeddingProperties properties, ObservationRegistry observationRegistry) { | ||
| 
     | 
||
| // Validate required properties | ||
| if (properties.getInputType() == null) { | ||
| throw new IllegalArgumentException("InputType property for BedrockTitanEmbeddingModel is missing."); | ||
| } | ||
| 
     | 
||
| return new BedrockTitanEmbeddingModel(titanEmbeddingApi, observationRegistry) | ||
| .withInputType(properties.getInputType()); | ||
| } | ||
| 
     | 
||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need an explicit version here.