Skip to content

Commit 34b34d0

Browse files
Hk669marklyszethinkall
authored
Amazon Bedrock Client for AutoGen (microsoft#3232)
* intial commit for aws-bedrock * format * converse setup for model req-response * Renamed to bedrock.py, updated parameter parsing, system message extraction, client class incorporation * Established Bedrock class based on @astroalek and @ChristianT's code, added ability to disable system prompt separation * Image parsing and removing access credential checks * Added tests, added additional parameter support * Amazon Bedrock documentation * Moved client parameters to init, align parameter names with Anthropic, spelling fix, remove unnecessary imports, use base and additional parameters, update documentation * Tidy up comments * Minor typo fix * Correct comment re aws_region --------- Co-authored-by: Mark Sze <[email protected]> Co-authored-by: Mark Sze <[email protected]> Co-authored-by: Li Jiang <[email protected]>
1 parent 30b79ae commit 34b34d0

File tree

11 files changed

+2270
-6
lines changed

11 files changed

+2270
-6
lines changed

.github/workflows/contrib-tests.yml

+40
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,43 @@ jobs:
612612
with:
613613
file: ./coverage.xml
614614
flags: unittests
615+
616+
BedrockTest:
617+
runs-on: ${{ matrix.os }}
618+
strategy:
619+
fail-fast: false
620+
matrix:
621+
os: [ubuntu-latest, macos-latest, windows-2019]
622+
python-version: ["3.9", "3.10", "3.11", "3.12"]
623+
exclude:
624+
- os: macos-latest
625+
python-version: "3.9"
626+
steps:
627+
- uses: actions/checkout@v4
628+
with:
629+
lfs: true
630+
- name: Set up Python ${{ matrix.python-version }}
631+
uses: actions/setup-python@v5
632+
with:
633+
python-version: ${{ matrix.python-version }}
634+
- name: Install packages and dependencies for all tests
635+
run: |
636+
python -m pip install --upgrade pip wheel
637+
pip install pytest-cov>=5
638+
- name: Install packages and dependencies for Amazon Bedrock
639+
run: |
640+
pip install -e .[boto3,test]
641+
- name: Set AUTOGEN_USE_DOCKER based on OS
642+
shell: bash
643+
run: |
644+
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
645+
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
646+
fi
647+
- name: Coverage
648+
run: |
649+
pytest test/oai/test_bedrock.py --skip-openai
650+
- name: Upload coverage to Codecov
651+
uses: codecov/codecov-action@v3
652+
with:
653+
file: ./coverage.xml
654+
flags: unittests

autogen/logger/file_logger.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
if TYPE_CHECKING:
1919
from autogen import Agent, ConversableAgent, OpenAIWrapper
2020
from autogen.oai.anthropic import AnthropicClient
21+
from autogen.oai.bedrock import BedrockClient
2122
from autogen.oai.cohere import CohereClient
2223
from autogen.oai.gemini import GeminiClient
2324
from autogen.oai.groq import GroqClient
@@ -215,6 +216,7 @@ def log_new_client(
215216
| TogetherClient
216217
| GroqClient
217218
| CohereClient
219+
| BedrockClient
218220
),
219221
wrapper: OpenAIWrapper,
220222
init_args: Dict[str, Any],

autogen/logger/sqlite_logger.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
if TYPE_CHECKING:
2020
from autogen import Agent, ConversableAgent, OpenAIWrapper
2121
from autogen.oai.anthropic import AnthropicClient
22+
from autogen.oai.bedrock import BedrockClient
2223
from autogen.oai.cohere import CohereClient
2324
from autogen.oai.gemini import GeminiClient
2425
from autogen.oai.groq import GroqClient
@@ -402,6 +403,7 @@ def log_new_client(
402403
TogetherClient,
403404
GroqClient,
404405
CohereClient,
406+
BedrockClient,
405407
],
406408
wrapper: OpenAIWrapper,
407409
init_args: Dict[str, Any],

0 commit comments

Comments
 (0)