An error occurred (ModelErrorException)
jenny5587 opened this issue · comments
Minheejung commented
def func_1(text, bedrock_client, model_id):
prompt_template = f"""
<documents>
<documents index="1">
{text}
</document_content>
</documents>
당신은 AI 비서입니다.
다른말은 하지 않아야 합니다.
"""
payload = {
"modelId": "anthropic.claude-3-sonnet-20240229-v1:0",
"contentType": "application/json",
"accept": "application/json",
"body": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": prompt_template,
},
],
}
],
},
}
body_bytes = json.dumps(payload["body"]).encode("utf-8")
response = bedrock_client.invoke_model(
body=body_bytes,
contentType=payload["contentType"],
accept=payload["accept"],
modelId=payload["modelId"],
)
response_body = response["body"].read().decode("utf-8")
data = json.loads(response_body)
response_b = data["content"][0]["text"]
result = split_sentences(response_b)
return result
Hello, while using sonnet, I was referring to "python/example_code/bedrock-runtime/models/anthropic/claude3_chatbot_demo/0_try_claude3.py." However, there is a part where the model error is intermittent, has this error ever occurred? I don't know if it's right to leave it here, but I'd appreciate it if you could let me know if there's anything wrong with my code.