Added capability to customize read and connection timeout for bedrock models
Why are these changes needed?
With existing AutoGen implementation of Bedrock client class BedrockClient, the Amazon Bedrock inference request gets timed out when the input token size is large (>~10,000 tokens). This happens because the current implementation uses default read and connection timeout values (60 seconds) from boto3 while initializing the Config class. Due to this default value the create method in BedrockClient class raises RuntimeError even though bedrock model is still generating response (as monitored in AWS CloudWatch).
With increasing context window size of LLM in today's Generative AI era, it is important to introduce capability for user-defined read timeouts to support large input tokens for agents.
Related issue number
Closes #5505
Checks
- [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [x] I've made sure all auto checks have passed.
To quick fix the formatting error. Run pre-commit --all-files
Codecov Report
Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
Project coverage is 29.50%. Comparing base (
ad3bed3) to head (09486a3).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| autogen/oai/bedrock.py | 0.00% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## 0.2 #5529 +/- ##
==========================================
+ Coverage 29.26% 29.50% +0.23%
==========================================
Files 117 117
Lines 13038 13040 +2
Branches 2473 2473
==========================================
+ Hits 3816 3847 +31
+ Misses 8876 8846 -30
- Partials 346 347 +1
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 29.50% <0.00%> (+0.23%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
To quick fix the formatting error. Run
pre-commit --all-files
Thanks @ekzhu! Done with reformatting as per pre-commit configuration of the project.
Please agree to the contributor license
@akshay20t - please see above re: license
@akshay20t it looks like we should add these values to autogen/autogen/oai /client.py in function _configure_openai_config_for_bedrock optional_keys should looks like: optional_keys = ["aws_session_token", "aws_profile_name", "aws_read_timeout","aws_connect_timeout"]
If you would like to contribute this @akshay20t please read and accept the CLA
@akshay20t it looks like we should add these values to autogen/autogen/oai /client.py in function _configure_openai_config_for_bedrock optional_keys should looks like: optional_keys = ["aws_session_token", "aws_profile_name", "aws_read_timeout","aws_connect_timeout"]
Thanks @maxx-ukoo for your inputs! I have updated the same.
@akshay20t please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
@microsoft-github-policy-service agree [company="{your company}"]Options:
- (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
- (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"Contributor License Agreement
@microsoft-github-policy-service agree