Last active
September 17, 2024 13:33
-
-
Save JGalego/8d21694f4415763aad3d9bcf24df1fe0 to your computer and use it in GitHub Desktop.
Titan Love π±π
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
| """ | |
| Sends love to Amazon Titan for Embeddings π | |
| and gets a bunch of numbers in return π’ | |
| """ | |
| import json | |
| import boto3 | |
| # Initialize Bedrock Runtime client | |
| # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html | |
| bedrock = boto3.client("bedrock-runtime") | |
| # Call Amazon Titan for Embeddings model on "love" | |
| # https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html | |
| response = bedrock.invoke_model( | |
| modelId="amazon.titan-embed-text-v1", | |
| body="{\"inputText\": \"love\"}" | |
| ) | |
| # Process the model response and print the final result | |
| body = json.loads(response.get('body').read()) | |
| print(body['embedding']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment