Repository navigation
Add api args to Bedrock provider - #295
Merged
Merged
Conversation
…eter for debugging requests/responses.
… and more context. Minor comment changes
…ved verbose printing. Compacted request body. Updated Roxygen documentation.
hadley
reviewed
Feb 4, 2025
hadley
left a comment
Member
There was a problem hiding this comment.
Thanks for working on this! A few comments below.
| cache <- aws_creds_cache(profile) | ||
| credentials <- paws_credentials(profile, cache = cache) | ||
|
|
||
| # Validate api_args if present |
Member
There was a problem hiding this comment.
Can you please omit this for now? As I mentioned, we're going to do something for all providers in the next release.
| # https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html | ||
| req <- req_body_json(req, list( | ||
| # Build request body | ||
| body <- compact(list( |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
I'd prefer to document this all generically, so can you please omit for now?
And fix test issues
Member
|
Thanks @billsanto, I simplified this a bit more in the light of the fact that we'll invest more in cross-provider parameters in the future. |
Contributor
Author
|
I see--that is a bit simpler. Thanks for adding it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).