Skip to content

Commit

Permalink
Amazon Bedrock Client for AutoGen (#3232)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Aug 26, 2024
1 parent 30b79ae commit 34b34d0
Show file tree
Hide file tree
Showing 11 changed files with 2,270 additions and 6 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/contrib-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,43 @@ jobs:
with:
file: ./coverage.xml
flags: unittests

BedrockTest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.9"
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install packages and dependencies for all tests
run: |
python -m pip install --upgrade pip wheel
pip install pytest-cov>=5
- name: Install packages and dependencies for Amazon Bedrock
run: |
pip install -e .[boto3,test]
- name: Set AUTOGEN_USE_DOCKER based on OS
shell: bash
run: |
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
fi
- name: Coverage
run: |
pytest test/oai/test_bedrock.py --skip-openai
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
2 changes: 2 additions & 0 deletions autogen/logger/file_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
if TYPE_CHECKING:
from autogen import Agent, ConversableAgent, OpenAIWrapper
from autogen.oai.anthropic import AnthropicClient
from autogen.oai.bedrock import BedrockClient
from autogen.oai.cohere import CohereClient
from autogen.oai.gemini import GeminiClient
from autogen.oai.groq import GroqClient
Expand Down Expand Up @@ -215,6 +216,7 @@ def log_new_client(
| TogetherClient
| GroqClient
| CohereClient
| BedrockClient
),
wrapper: OpenAIWrapper,
init_args: Dict[str, Any],
Expand Down
2 changes: 2 additions & 0 deletions autogen/logger/sqlite_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
if TYPE_CHECKING:
from autogen import Agent, ConversableAgent, OpenAIWrapper
from autogen.oai.anthropic import AnthropicClient
from autogen.oai.bedrock import BedrockClient
from autogen.oai.cohere import CohereClient
from autogen.oai.gemini import GeminiClient
from autogen.oai.groq import GroqClient
Expand Down Expand Up @@ -402,6 +403,7 @@ def log_new_client(
TogetherClient,
GroqClient,
CohereClient,
BedrockClient,
],
wrapper: OpenAIWrapper,
init_args: Dict[str, Any],
Expand Down
Loading

0 comments on commit 34b34d0

Please sign in to comment.