livellm 1.3.0__tar.gz → 1.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livellm
3
- Version: 1.3.0
3
+ Version: 1.3.5
4
4
  Summary: Python client for the LiveLLM Server
5
5
  Project-URL: Homepage, https://github.com/qalby-tech/livellm-client-py
6
6
  Project-URL: Repository, https://github.com/qalby-tech/livellm-client-py
@@ -493,7 +493,8 @@ class LivellmWsClient(BaseLivellmClient):
493
493
  def __init__(
494
494
  self,
495
495
  base_url: str,
496
- timeout: Optional[float] = None
496
+ timeout: Optional[float] = None,
497
+ max_size: Optional[int] = None
497
498
  ):
498
499
  # Convert HTTP(S) URL to WS(S) URL
499
500
  base_url = base_url.rstrip("/")
@@ -511,6 +512,7 @@ class LivellmWsClient(BaseLivellmClient):
511
512
  self.websocket = None
512
513
  # Lazily-created clients
513
514
  self._transcription = None
515
+ self.max_size = max_size or 1024 * 1024 * 10 # 10MB is default max size
514
516
 
515
517
  async def connect(self):
516
518
  """Establish WebSocket connection."""
@@ -520,7 +522,8 @@ class LivellmWsClient(BaseLivellmClient):
520
522
  self.websocket = await websockets.connect(
521
523
  self.base_url,
522
524
  open_timeout=self.timeout,
523
- close_timeout=self.timeout
525
+ close_timeout=self.timeout,
526
+ max_size=self.max_size
524
527
  )
525
528
 
526
529
  return self.websocket
@@ -28,9 +28,17 @@ class EncodedSpeakResponse(BaseModel):
28
28
  content_type: SpeakMimeType = Field(..., description="The content type of the audio")
29
29
  sample_rate: int = Field(..., description="The sample rate of the audio")
30
30
 
31
- @field_validator('audio', mode='after')
31
+ @field_validator("audio", mode="after")
32
32
  @classmethod
33
33
  def validate_audio(cls, v: bytes | str) -> bytes:
34
- if isinstance(v, bytes):
35
- return base64.b64decode(v) # decode from base64 string to bytes
36
- return v # if bytes, assume it's already a base64 decoded bytes
34
+ """
35
+ Ensure that `audio` is always returned as raw bytes.
36
+
37
+ - If the server returns a base64-encoded *string*, decode it.
38
+ - If the server already returned raw bytes, pass them through.
39
+ """
40
+ if isinstance(v, str):
41
+ # Server sent base64-encoded string → decode to raw bytes
42
+ return base64.b64decode(v)
43
+ # Already bytes → assume it's raw audio
44
+ return v
@@ -10,11 +10,12 @@ import json
10
10
 
11
11
 
12
12
  class TranscriptionWsClient:
13
- def __init__(self, base_url: str, timeout: Optional[float] = None):
13
+ def __init__(self, base_url: str, timeout: Optional[float] = None, max_size: Optional[int] = None):
14
14
  self.base_url = base_url.rstrip("/")
15
15
  self.url = f"{base_url}/livellm/ws/transcription"
16
16
  self.timeout = timeout
17
17
  self.websocket = None
18
+ self.max_size = max_size or 1024 * 1024 * 10 # 10MB is default max size
18
19
 
19
20
  async def connect(self):
20
21
  """
@@ -23,7 +24,8 @@ class TranscriptionWsClient:
23
24
  self.websocket = await websockets.connect(
24
25
  self.url,
25
26
  open_timeout=self.timeout,
26
- close_timeout=self.timeout
27
+ close_timeout=self.timeout,
28
+ max_size=self.max_size
27
29
  )
28
30
 
29
31
  async def disconnect(self):
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "livellm"
3
- version = "1.3.0"
3
+ version = "1.3.5"
4
4
  description = "Python client for the LiveLLM Server"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes