Spaces:
Running
on
T4
Running
on
T4
import boto3 | |
import json | |
import os | |
import streamlit as st | |
# Initialize the Lambda client with AWS credentials and region | |
# Ensure that the AWS credentials are set in Streamlit secrets | |
lambda_client = boto3.client( | |
'lambda', | |
aws_access_key_id=st.secrets['user_access_key_us_west_2'], | |
aws_secret_access_key=st.secrets['user_secret_key_us_west_2'], region_name = 'us-west-2' | |
) | |
def send_to_lambda(index, document): | |
payload = { | |
"target_index": index, | |
"document": document | |
} | |
response = lambda_client.invoke( | |
FunctionName='proxy-observability-opensearch-ubi', | |
InvocationType='Event', # async! | |
Payload=json.dumps(payload) | |
) | |
return response['StatusCode'] # 202 if accepted |