Skip to content

Commit 4505630

Browse files
committed
add test script for aws bedrock access
1 parent 136e178 commit 4505630

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bin/aws_llama_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
import boto3
4+
import json
5+
bedrock = boto3.client(service_name='bedrock-runtime')
6+
7+
body = json.dumps({
8+
"prompt": "\n\nHuman:explain black holes to 8th graders\n\nAssistant:",
9+
"max_gen_len": 128,
10+
"temperature": 0.1,
11+
"top_p": 0.9,
12+
})
13+
14+
modelId = 'meta.llama2-13b-chat-v1'
15+
accept = 'application/json'
16+
contentType = 'application/json'
17+
18+
response = bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType)
19+
20+
response_body = json.loads(response.get('body').read())
21+
22+
print(response_body.get('generation'))

0 commit comments

Comments
 (0)