From 041fd717c7974365a5e1ec08e340da811fdc59be Mon Sep 17 00:00:00 2001 From: Soheyl Date: Tue, 11 Jul 2023 19:26:57 +0200 Subject: [PATCH 1/2] fix(pydantic): allow `pydantic>=2` to be installed alongside `v1` --- assemblyai/types.py | 25 +++++++++++-------------- setup.py | 4 ++-- tox.ini | 7 ++++--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/assemblyai/types.py b/assemblyai/types.py index 8247773..f69a9c1 100644 --- a/assemblyai/types.py +++ b/assemblyai/types.py @@ -1,8 +1,12 @@ from datetime import datetime from enum import Enum -from typing import Any, Dict, List, Literal, Optional, Sequence, Tuple, Union +from typing import Any, Dict, List, Optional, Sequence, Tuple, Union + +try: + from pydantic import UUID4, BaseModel, BaseSettings, Extra, Field +except ImportError: + from pydantic.v1 import UUID4, BaseModel, BaseSettings, Extra, Field -from pydantic import UUID4, BaseModel, BaseSettings, Extra, Field from typing_extensions import Self @@ -1603,9 +1607,8 @@ class RealtimeSessionOpened(BaseModel): Once a real-time session is opened, the client will receive this message """ - message_type: Literal[ - RealtimeMessageTypes.session_begins - ] = RealtimeMessageTypes.session_begins + message_type: RealtimeMessageTypes = RealtimeMessageTypes.session_begins + session_id: UUID4 "Unique identifier for the established session." @@ -1637,9 +1640,7 @@ class RealtimeTranscript(BaseModel): Base class for real-time transcript messages. """ - message_type: Literal[ - RealtimeMessageTypes.partial_transcript, RealtimeMessageTypes.final_transcript - ] + message_type: RealtimeMessageTypes "Describes the type of message" audio_start: int @@ -1670,9 +1671,7 @@ class RealtimePartialTranscript(RealtimeTranscript): As you send audio data to the service, the service will immediately start responding with partial transcripts. """ - message_type: Literal[ - RealtimeMessageTypes.partial_transcript - ] = RealtimeMessageTypes.partial_transcript + message_type: RealtimeMessageTypes = RealtimeMessageTypes.partial_transcript class RealtimeFinalTranscript(RealtimeTranscript): @@ -1682,9 +1681,7 @@ class RealtimeFinalTranscript(RealtimeTranscript): sent to you so far with higher accuracy, as well as add punctuation and casing to the transcription text. """ - message_type: Literal[ - RealtimeMessageTypes.final_transcript - ] = RealtimeMessageTypes.final_transcript + message_type: RealtimeMessageTypes = RealtimeMessageTypes.final_transcript punctuated: bool "Whether the transcript has been punctuated and cased" diff --git a/setup.py b/setup.py index 7805e82..1a204ef 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,8 @@ packages=find_packages(), install_requires=[ "httpx>=0.19.0", - "pydantic>=1.7.0", - "typing-extensions>=3.7,<4.6", + "pydantic>=1.7.0,!=1.10.7", + "typing-extensions>=3.7", "websockets>=11.0", ], extras_require={ diff --git a/tox.ini b/tox.ini index b10d573..3bfddd2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38,39,310,311}-websockets{latest,11.0}-pyaudio{latest,0.2}-httpx{latest,0.24,0.23,0.22,0.21}-pydantic{latest,1.10,1.9,1.8,1.7}-typing-extensions +envlist = py{38,39,310,311}-websockets{latest,11.0}-pyaudio{latest,0.2}-httpx{latest,0.24,0.23,0.22,0.21}-pydantic{latest,2,1.10,1.9,1.8,1.7}-typing-extensions [testenv] deps = @@ -12,11 +12,12 @@ deps = httpx0.22: httpx>=0.22.0,<0.23.0 httpx0.21: httpx>=0.21.0,<0.22.0 pydanticlatest: pydantic - pydantic1.10: pydantic>=1.10.0,<1.11.0 + pydantic2: pydantic>=2 + pydantic1.10: pydantic>=1.10.0,<1.11.0,!=1.10.7 pydantic1.9: pydantic>=1.9.0,<1.10.0 pydantic1.8: pydantic>=1.8.0,<1.9.0 pydantic1.7: pydantic>=1.7.0,<1.8.0 - typing-extensions: typing-extensions>=3.7,<4.6 + typing-extensions: typing-extensions>=3.7 # extra dependencies pyaudiolatest: pyaudio pyaudio0.2: pyaudio>=0.2.13,<0.3.0 From 746d4e868caf4bbabc793693e26eb52a5942c2f3 Mon Sep 17 00:00:00 2001 From: Soheyl Date: Wed, 12 Jul 2023 10:48:57 +0200 Subject: [PATCH 2/2] build: bump version to `0.13.0` --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a204ef..ba68282 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="assemblyai", - version="0.12.0", + version="0.13.0", description="AssemblyAI Python SDK", author="AssemblyAI", author_email="engineering.sdk@assemblyai.com",