Skip to content

paws-v0.8.0

Latest
Compare
Choose a tag to compare
@DyfanJones DyfanJones released this 10 Feb 13:49
· 38 commits to main since this release
1f7e614

Paws 0.8.0 CRAN Release 🎊πŸ₯³πŸŽ‰

Features

  • Streaming Support 🎊πŸ₯³πŸŽ‰: Paws now returns PawsStreamHandler for streaming services. Learn more. This can be used in multiple ways:
    1. Passing a function to it similar to the apply functions.
    2. Returning the httr2::req_performance_connection and parsing with Paws built-in parser paws_stream_parser or using httr2::resp_stream_aws.

Example:

library(paws)

client <- bedrockruntime(region = "us-east-1")

model_id <- "amazon.titan-text-lite-v1:0"
conversation <- list(
  list(
    role = "user",
    content = list(list(text = "What's your name?"))
  )
)

resp <- client$converse_stream(
  modelId = model_id,
  messages = conversation
)

resp$stream(\(chunk) chunk$contentBlockDelta$delta$text)
# Note: stream will close connection after all chunks are read

resp <- client$converse_stream(
  modelId = model_id,
  messages = conversation
)

# Return httr2 req_performance_connection for full flexibility
con <- resp$stream(.connection = TRUE)

# Handle connection object using paws_stream_parser
while (!is.null(chunk <- paws_stream_parser(con))) {
  print(chunk$contentBlockDelta$delta$text)
}
# Note: paws_stream_parser will close connection after all chunks are read

# Or handle connection using httr2::resp_stream_aws
while (!is.null(chunk <- resp_stream_aws(con))) {
  str(chunk)
}
close(con)

Backend changes:

  • Paws has migrated from aws sdk js to aws sdk python botocore AWS JSONs, which has led to a change to the endpoint regex.

Services

New Support

  • bedrock-data-automation
  • bedrock-data-automation-runtime
  • codeconnections

Deprecated Services

  • nimblestudio: AWS no longer supports Nimble. Learn more
  • worklink: AWS no longer supports WorkLink.
  • cloudwatchevents: AWS CloudWatch Events have been move to EventBridge to align with AWS services.