- Newest
- Most votes
- Most comments
Update your Kotlin code to include the user's input in the JSON payload:
val userPromptvc = inputFieldvc.text.toString() val jsonPayload = "{\"prompt\":\"$userPromptvc\"}" val requestBody = jsonPayload.toRequestBody("application/json".toMediaType()) val request = Request.Builder() .url(url) .post(requestBody) .build()
This change will send the user's input as part of the JSON payload to your Lambda function.
- In your AWS Lambda function:
Modify your Lambda function to extract the prompt from the event:
def lambda_handler(event, context): # Extract the prompt from the event user_prompt = json.loads(event['body'])['prompt'] model_input = { "taskType": "TEXT_VIDEO", "textToVideoParams": { "text": user_prompt # Use the user's prompt here }, "videoGenerationConfig": { "durationSeconds": 6, "fps": 24, "dimension": "1280x720", "seed": 33, }, } # Rest of your Lambda function code...
These changes will allow you to pass the user's input from your Android app to your Lambda function and use it as the prompt for Amazon Bedrock. The Lambda function now extracts the prompt from the event body instead of using an environment variable.
Remember to handle potential errors, such as missing prompt in the event, and ensure your Lambda function has the necessary permissions to access Amazon Bedrock and S3.
Sources
Task 3: Build a Serverless Backend
Configure Lambda functions to send information that an Amazon Bedrock agent elicits from the user - Amazon Bedrock
How to build a multilingual document summarization application using Amazon Bedrock | AWS Public Sector Blog
Relevant content
asked a year ago
asked a year ago
- AWS OFFICIALUpdated 2 months ago
