Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 5 additions & 59 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ bidi = [
"prompt_toolkit>=3.0.0,<4.0.0",
"pyaudio>=0.2.13,<1.0.0",
"smithy-aws-core>=0.0.1; python_version>='3.12'",
"strands-agents[gemini]",
"websockets>=15.0.0,<16.0.0",
]
bidi-gemini = ["google-genai>=1.32.0,<2.0.0"]
bidi-openai = ["websockets>=15.0.0,<16.0.0"]

all = ["strands-agents[a2a,anthropic,docs,gemini,litellm,llamaapi,mistral,ollama,openai,writer,sagemaker,otel]"]
bidi-all = ["strands-agents[a2a,bidi,bidi-gemini,bidi-openai,docs,otel]"]
all = ["strands-agents[a2a,anthropic,bidi,docs,gemini,litellm,llamaapi,mistral,ollama,openai,writer,sagemaker,otel]"]

dev = [
"commitizen>=4.4.0,<5.0.0",
Expand Down Expand Up @@ -130,7 +129,7 @@ format-fix = [
]
lint-check = [
"ruff check",
"mypy ./src"
"mypy -p src"
]
lint-fix = [
"ruff check --fix"
Expand Down Expand Up @@ -204,16 +203,10 @@ warn_no_return = true
warn_unreachable = true
follow_untyped_imports = true
ignore_missing_imports = false
exclude = ["src/strands/experimental/bidi"]

[[tool.mypy.overrides]]
module = ["strands.experimental.bidi.*"]
follow_imports = "skip"

[tool.ruff]
line-length = 120
include = ["examples/**/*.py", "src/**/*.py", "tests/**/*.py", "tests_integ/**/*.py"]
exclude = ["src/strands/experimental/bidi/**/*.py", "tests/strands/experimental/bidi/**/*.py", "tests_integ/bidi/**/*.py"]

[tool.ruff.lint]
select = [
Expand All @@ -236,16 +229,14 @@ convention = "google"
[tool.pytest.ini_options]
testpaths = ["tests"]
asyncio_default_fixture_loop_scope = "function"
addopts = "--ignore=tests/strands/experimental/bidi --ignore=tests_integ/bidi"

addopts = "--ignore=tests_integ/bidi" # TODO: install portaudio for github workflow

[tool.coverage.run]
branch = true
source = ["src"]
context = "thread"
parallel = true
concurrency = ["thread", "multiprocessing"]
omit = ["src/strands/experimental/bidi/*"]

[tool.coverage.report]
show_missing = true
Expand Down Expand Up @@ -275,48 +266,3 @@ style = [
["text", ""],
["disabled", "fg:#858585 italic"]
]

# =========================
# Bidi development configs
# =========================

[tool.hatch.envs.bidi]
dev-mode = true
features = ["dev", "bidi-all"]
installer = "uv"

[tool.hatch.envs.bidi.scripts]
prepare = [
"hatch run bidi-lint:format-fix",
"hatch run bidi-lint:quality-fix",
"hatch run bidi-lint:type-check",
"hatch run bidi-test:test-cov",
]

[tools.hatch.envs.bidi-lint]
template = "bidi"

[tool.hatch.envs.bidi-lint.scripts]
format-check = "format-fix --check"
format-fix = "ruff format {args} --target-version py312 ./src/strands/experimental/bidi/**/*.py"
quality-check = "ruff check {args} --target-version py312 ./src/strands/experimental/bidi/**/*.py"
quality-fix = "quality-check --fix"
type-check = "mypy {args} --python-version 3.12 ./src/strands/experimental/bidi/**/*.py"

[tool.hatch.envs.bidi-test]
template = "bidi"

[tool.hatch.envs.bidi-test.scripts]
test = "pytest {args} tests/strands/experimental/bidi"
test-cov = """
test \
--cov=strands.experimental.bidi \
--cov-config= \
--cov-branch \
--cov-report=term-missing \
--cov-report=xml:build/coverage/bidi-coverage.xml \
--cov-report=html:build/coverage/bidi-html
"""

[[tool.hatch.envs.bidi-test.matrix]]
python = ["3.13", "3.12"]
21 changes: 14 additions & 7 deletions src/strands/experimental/bidi/models/nova_sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,32 @@
if sys.version_info < (3, 12):
raise ImportError("BidiNovaSonicModel is only supported for Python 3.12+")

import asyncio
import asyncio # type: ignore[unreachable]
import base64
import json
import logging
import uuid
from typing import Any, AsyncGenerator, cast

import boto3
from aws_sdk_bedrock_runtime.client import BedrockRuntimeClient, InvokeModelWithBidirectionalStreamOperationInput
from aws_sdk_bedrock_runtime.config import Config, HTTPAuthSchemeResolver, SigV4AuthScheme
from aws_sdk_bedrock_runtime.models import (
from aws_sdk_bedrock_runtime.client import ( # type: ignore[import-not-found]
BedrockRuntimeClient,
InvokeModelWithBidirectionalStreamOperationInput,
)
from aws_sdk_bedrock_runtime.config import ( # type: ignore[import-not-found]
Config,
HTTPAuthSchemeResolver,
SigV4AuthScheme,
)
from aws_sdk_bedrock_runtime.models import ( # type: ignore[import-not-found]
BidirectionalInputPayloadPart,
InvokeModelWithBidirectionalStreamInputChunk,
ModelTimeoutException,
ValidationException,
)
from smithy_aws_core.identity.static import StaticCredentialsResolver
from smithy_core.aio.eventstream import DuplexEventStream
from smithy_core.shapes import ShapeID
from smithy_aws_core.identity.static import StaticCredentialsResolver # type: ignore[import-not-found]
from smithy_core.aio.eventstream import DuplexEventStream # type: ignore[import-not-found]
from smithy_core.shapes import ShapeID # type: ignore[import-not-found]
Comment on lines +31 to +48
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all 3.12+ libraries and thus must be ignored by mypy.


from ....types._events import ToolResultEvent, ToolUseStreamEvent
from ....types.content import Messages
Expand Down
Loading