File size: 1,202 Bytes
920dfd0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
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']
|