-
Notifications
You must be signed in to change notification settings - Fork 42
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
base: main
Are you sure you want to change the base?
Conversation
…eter for debugging requests/responses.
… and more context. Minor comment changes
…ved verbose printing. Compacted request body. Updated Roxygen documentation.
There was a problem hiding this 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.
R/provider-bedrock.R
Outdated
|
||
check_installed("paws.common", "AWS authentication") | ||
cache <- aws_creds_cache(profile) | ||
credentials <- paws_credentials(profile, cache = cache) | ||
|
||
# Validate api_args if present |
There was a problem hiding this comment.
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.
R/provider-bedrock.R
Outdated
@@ -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( |
There was a problem hiding this comment.
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?
R/provider-bedrock.R
Outdated
#' # 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 |
There was a problem hiding this comment.
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?
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).