amazon web services – How can you use invoke a model in AWS Bedrock using Ruby?

Add this gem: gem "aws-sdk-bedrockruntime"

Invoke models using the BedrockRuntime client.

client = Aws::BedrockRuntime::Client.new
resp = client.invoke_model(
  body: { texts: ["data"], input_type: "search_document" }.to_json,
  model_id: "cohere.embed-english-v3",
  content_type: "application/json",
  accept: "*/*"
)

embeddings = JSON.parse(resp.body)["embeddings"]

The specific structure of the params to invoke_model can be found in the ‘Providers’ tab of the Bedrock section in AWS, under the specific model you’re interested in.

Read more here: Source link