import boto3 import json from prompts import * bedrock = boto3.client(service_name="bedrock-runtime", region_name="us-east-1") CLAUDE_MODEL_ID = "us.anthropic.claude-3-5-haiku-20241022-v1:0" def analyze_with_claude(stt_data, content_type="국민의힘"): """ Use Claude to summarize AI based on STT data. Select the appropriate prompt according to the content_type. """ if content_type == "Agents for Amazon Bedrock": prompt_template = BEDROCK_CLAUDE_PROMPT elif content_type == "Bundesliga Fan Experience": prompt_template = BUNDESLIGA_CLAUDE_PROMPT elif content_type == "AWS_2024_recap": prompt_template = AWS_CLAUDE_PROMPT formatted_prompt = prompt_template.format(stt_data=stt_data) body = json.dumps({ "anthropic_version": "bedrock-2023-05-31", "max_tokens": 1000, "messages": [ { "role": "user", "content": formatted_prompt } ] }) response = bedrock.invoke_model( modelId=CLAUDE_MODEL_ID, body=body ) response_body = json.loads(response.get('body').read()) return response_body['content'][0]['text']