Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created January 8, 2024 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamarmarshall/ffa76e4e72812f15d0bf88c7c5025814 to your computer and use it in GitHub Desktop.
Save lamarmarshall/ffa76e4e72812f15d0bf88c7c5025814 to your computer and use it in GitHub Desktop.
python, aws, bedrock, llama2 model
import boto3
import json
bedrock_runtime = boto3.client(region_name='us-east-1', service_name="bedrock-runtime")
prompt = "What are some unique cultural things about romanians"
body = json.dumps({"prompt": prompt,
"temperature": 0.9,
"top_p": 1,
"max_gen_len": 1024})
response = bedrock_runtime.invoke_model(body=body,
contentType="application/json",
modelId="meta.llama2-70b-chat-v1")
content = json.loads(response['body'].read().decode('utf-8'))
print(content['generation'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment