Skip to content

chore: sync sdk code with DeepLearning repo #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 24, 2025
Merged
2 changes: 1 addition & 1 deletion assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.39.1"
__version__ = "0.40.0"
31 changes: 27 additions & 4 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

try:
# pydantic v2 import
from pydantic import UUID4, BaseModel, ConfigDict, Field
from pydantic import UUID4, BaseModel, ConfigDict, Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict

pydantic_v2 = True
except ImportError:
# pydantic v1 import
from pydantic.v1 import UUID4, BaseModel, BaseSettings, ConfigDict, Field
from pydantic.v1 import UUID4, BaseModel, BaseSettings, ConfigDict, Field, validator

pydantic_v2 = False

Expand Down Expand Up @@ -1468,6 +1468,19 @@ class Word(BaseModel):
speaker: Optional[str] = None
channel: Optional[str] = None

# This is a workaround to address an issue where sentiment_analysis_results
# may return contains sentiments where `start` is null.
if pydantic_v2:

@field_validator("start", mode="before")
def set_start_default(cls, v):
return 0 if v is None else v
else:

@validator("start", pre=True)
def set_start_default(cls, v):
return 0 if v is None else v


class UtteranceWord(Word):
channel: Optional[str] = None
Expand Down Expand Up @@ -2031,19 +2044,29 @@ class LemurModel(str, Enum):
LeMUR features different model modes that allow you to configure your request to suit your needs.
"""

claude3_7_sonnet_20250219 = "anthropic/claude-3-7-sonnet"
"""
Claude 3.7 Sonnet is the most intelligent model to date, providing the highest level of intelligence and capability with toggleable extended thinking.
"""

claude3_5_sonnet = "anthropic/claude-3-5-sonnet"
"""
Claude 3.5 Sonnet is the most intelligent model to date, outperforming Claude 3 Opus on a wide range of evaluations, with the speed and cost of Claude 3 Sonnet.
Claude 3.5 Sonnet is the previous most intelligent model to date, providing high level of intelligence and capability.
"""

claude3_opus = "anthropic/claude-3-opus"
"""
Claude 3 Opus is good at handling complex analysis, longer tasks with many steps, and higher-order math and coding tasks.
"""

claude3_5_haiku_20241022 = "anthropic/claude-3-5-haiku"
"""
Claude 3.5 Haiku is the fastest model, providing intelligence at blazing speeds.
"""

claude3_haiku = "anthropic/claude-3-haiku"
"""
Claude 3 Haiku is the fastest model that can execute lightweight actions.
Claude 3 Haiku is the fastest and most compact model for near-instant responsiveness.
"""

claude3_sonnet = "anthropic/claude-3-sonnet"
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/test_sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,33 @@ def test_sentiment_analysis_enabled(httpx_mock: HTTPXMock):
assert (
transcript_sentiment_result.speaker == response_sentiment_result["speaker"]
)


def test_sentiment_analysis_null_start(httpx_mock: HTTPXMock):
"""
Tests that `start` converts null values to 0.
"""
mock_response = {
"audio_url": "https://example/audio.mp3",
"status": "completed",
"sentiment_analysis_results": [
{
"text": "hi",
"start": None,
"end": 100,
"confidence": 0.99,
"sentiment": "POSITIVE",
}
],
}
request_body, transcript = unit_test_utils.submit_mock_transcription_request(
httpx_mock,
mock_response=mock_response,
config=aai.TranscriptionConfig(sentiment_analysis=True),
)

for response_sentiment_result, transcript_sentiment_result in zip(
mock_response["sentiment_analysis_results"],
transcript.sentiment_analysis,
):
assert transcript_sentiment_result.start == 0