Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api args to Bedrock provider #295

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

billsanto
Copy link

Added api_args to the Bedrock provider. api_args is a list for parameters such as temperature, top_p, top_k, max_tokens, and stop_sequences. Added validation for each of these parameters. Updated the Roxygen documentation. (Removed the verbose parameter and relevant code/doc comments).

William Santo and others added 4 commits February 2, 2025 07:39
…ved verbose printing. Compacted request body. Updated Roxygen documentation.
Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! A few comments below.


check_installed("paws.common", "AWS authentication")
cache <- aws_creds_cache(profile)
credentials <- paws_credentials(profile, cache = cache)

# Validate api_args if present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please omit this for now? As I mentioned, we're going to do something for all providers in the next release.

@@ -123,13 +232,57 @@ method(chat_request, ProviderBedrock) <- function(provider,
}

# https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html
req <- req_body_json(req, list(
# Build request body
body <- compact(list(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please copy the generic api_args interface used by the other providers?

Comment on lines 79 to 96
#' # The echo argument, "none", "text", and "all" determines whether
#' # input and/or output is echoed to the console. Also of note, "none" uses a
#' # non-streaming endpoint, whereas "text", "all", or TRUE uses a streaming endpoint.
#' chat <- chat_bedrock()
#' chat$chat("What is 1 + 1?") # Streaming response
#' resp <- chat$chat("What is 1 + 1?", echo = "none") # Non-streaming response
#' resp # View response
#'
#' # Use echo = "none" in the client constructor to suppress streaming response
#' chat <- chat_bedrock(echo = "none")
#' resp <- chat$chat("What is 1 + 1?") # Non-streaming response
#' resp # View response
#' chat$chat("What is 1 + 1?", echo=TRUE) # Overrides client echo arg, uses streaming
#'
#' # $stream returns a generator, requiring concatentation of the streamed responses.
#' resp <- chat$stream("What is the capital of France?") # resp is a generator object
#' chunks <- coro::collect(resp) # returns list of partial text responses
#' complete_response <- paste(chunks, collapse="") # Full text response, no echo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to document this all generically, so can you please omit for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants