Skip to content

Commit

Permalink
feat: claude-3-haiku on Bedrock
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje authored and sh3pik committed Nov 20, 2024
1 parent cae0661 commit aa16d26
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 12 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ concurrency:
cancel-in-progress: true

env:
ALUMNIUM_MODEL: azure_openai
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
Expand All @@ -22,6 +23,14 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
ALUMNIUM_MODEL: ${{ matrix.model }}
strategy:
fail-fast: false
matrix:
model:
- aws_anthropic
- azure_openai
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -39,7 +48,7 @@ jobs:
- if: always()
uses: actions/upload-artifact@v4
with:
name: reports
name: reports-${{ matrix.model }}
path: reports/

release:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Select AI provider to use. Supported values are:

- `anthropic`
- `azure_openai`
- `aws_anthropic`
- `google`
- `openai`

Expand Down
9 changes: 9 additions & 0 deletions alumnium/alumni.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os import getenv

from langchain_anthropic import ChatAnthropic
from langchain_aws import ChatBedrock
from langchain_openai import AzureChatOpenAI, ChatOpenAI
from langchain_google_genai import ChatGoogleGenerativeAI

Expand Down Expand Up @@ -34,6 +35,14 @@ def __init__(
)
elif model == Model.ANTHROPIC:
llm = ChatAnthropic(model=model.value, temperature=0, max_retries=2)
elif model == Model.AWS_ANTHROPIC:
llm = ChatBedrock(
model_id=model.value,
model_kwargs={"temperature": 0},
aws_access_key_id=getenv("AWS_ACCESS_KEY", ""),
aws_secret_access_key=getenv("AWS_SECRET_KEY", ""),
region_name=getenv("AWS_REGION_NAME", "us-east-1"),
)
elif model == Model.GOOGLE:
llm = ChatGoogleGenerativeAI(model=model.value, temperature=0, max_retries=2)
elif model == Model.OPENAI:
Expand Down
1 change: 1 addition & 0 deletions alumnium/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Model(Enum):
AZURE_OPENAI = "gpt-4o-mini" # 2024-07-18
ANTHROPIC = "claude-3-haiku-20240307"
AWS_ANTHROPIC = "anthropic.claude-3-haiku-20240307-v1:0"
GOOGLE = "gemini-1.5-flash-002"
OPENAI = "gpt-4o-mini-2024-07-18"

Expand Down
6 changes: 4 additions & 2 deletions examples/pytest/calculator_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import pytest
from alumnium import Model
from pytest import mark, raises


@mark.xfail(Model.load() == Model.AWS_ANTHROPIC, reason="Bedrock version of Haiku is subpar")
def test_addition(al, driver):
driver.get("https://seleniumbase.io/apps/calculator")
al.do("1 + 1 =")
al.check("calculator result is 2")
with pytest.raises(AssertionError):
with raises(AssertionError):
al.check("calculator result is 3")
4 changes: 0 additions & 4 deletions examples/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from selenium.webdriver import Chrome
from pytest import fixture, hookimpl

# from langchain.globals import set_debug

# set_debug(True)


@fixture(scope="session", autouse=True)
def driver():
Expand Down
5 changes: 5 additions & 0 deletions examples/pytest/drag_and_drop_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from alumnium import Model
from pytest import mark


@mark.xfail(Model.load() == Model.AWS_ANTHROPIC, reason="Bedrock version of Haiku is subpar")
def test_drag_and_drop(al, driver):
driver.get("https://the-internet.herokuapp.com/drag_and_drop")
al.check("square A is positioned to the left of square B", vision=True)
Expand Down
5 changes: 5 additions & 0 deletions examples/pytest/select_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from alumnium import Model
from pytest import mark


@mark.xfail(Model.load() == Model.AWS_ANTHROPIC, reason="Bedrock version of Haiku is subpar")
def test_select_option(al, driver):
driver.get("https://the-internet.herokuapp.com/dropdown")
al.check("no option is selected")
Expand Down
108 changes: 104 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ langchain-google-genai = "^2.0"
langchain-openai = "^0.2"
retry2 = "^0.9"
selenium = "^4.0"
langchain-aws = "^0.2.7"

[tool.poetry.group.dev.dependencies]
behave = "^1.2.6"
Expand Down

0 comments on commit aa16d26

Please sign in to comment.