swarmauri_agent_texttospeech 0.11.0.dev5__tar.gz → 0.11.0.dev6__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: swarmauri_agent_texttospeech
3
- Version: 0.11.0.dev5
3
+ Version: 0.11.0.dev6
4
4
  Summary: Stateless Swarmauri agent for converting independent text prompts into audio through any TTSBase provider.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -133,3 +133,7 @@ should follow the repository contribution and style guides.
133
133
 
134
134
  Apache-2.0
135
135
 
136
+ Provider instances are validated against TTSBase at call-time construction, so
137
+ providers imported after the agent class remain usable. Serialized providers
138
+ retain their concrete fields; import that provider before deserialization.
139
+
@@ -106,3 +106,7 @@ should follow the repository contribution and style guides.
106
106
  ## License
107
107
 
108
108
  Apache-2.0
109
+
110
+ Provider instances are validated against TTSBase at call-time construction, so
111
+ providers imported after the agent class remain usable. Serialized providers
112
+ retain their concrete fields; import that provider before deserialization.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_agent_texttospeech"
3
- version = "0.11.0.dev5"
3
+ version = "0.11.0.dev6"
4
4
  description = "Stateless Swarmauri agent for converting independent text prompts into audio through any TTSBase provider."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -38,6 +38,7 @@ keywords = [
38
38
 
39
39
  [tool.uv.sources]
40
40
  swarmauri_core = { workspace = true }
41
+ swarmauri_tts_openai = { workspace = true }
41
42
  swarmauri_base = { workspace = true }
42
43
  swarmauri_tts_elevenlabs_dialogue = { workspace = true }
43
44
  swarmauri_tts_gemini_dialogue = { workspace = true }
@@ -56,6 +57,7 @@ build-backend = "poetry.core.masonry.api"
56
57
 
57
58
  [dependency-groups]
58
59
  dev = [
60
+ "swarmauri_tts_openai>=0.1.0a2,<0.2",
59
61
  "swarmauri_tts_elevenlabs_dialogue>=0.1.0a1,<0.2",
60
62
  "swarmauri_tts_gemini_dialogue>=0.1.0a1,<0.2",
61
63
  "pytest>=8.0",
@@ -7,9 +7,15 @@ from collections.abc import Sequence
7
7
  from pathlib import Path
8
8
  from typing import Any, Dict, List, Literal, Optional, Union
9
9
 
10
- from pydantic import BaseModel, ConfigDict, Field
11
-
12
- from swarmauri_base.ComponentBase import ComponentBase, SubclassUnion
10
+ from pydantic import (
11
+ BaseModel,
12
+ ConfigDict,
13
+ Field,
14
+ SerializeAsAny,
15
+ field_validator,
16
+ )
17
+
18
+ from swarmauri_base.ComponentBase import ComponentBase
13
19
  from swarmauri_base.agents.AgentBase import AgentBase
14
20
  from swarmauri_base.tts.TTSBase import TTSBase
15
21
  from swarmauri_core.messages.IMessage import IMessage
@@ -21,23 +27,28 @@ class TextToSpeechAgent(AgentBase):
21
27
 
22
28
  llm: None = Field(default=None, exclude=True)
23
29
  llm_kwargs: None = Field(default=None, exclude=True)
24
- tts: SubclassUnion[TTSBase]
30
+ tts: SerializeAsAny[TTSBase]
25
31
  output_path: str = "output.mp3"
26
32
  tts_kwargs: Dict[str, Any] = Field(default_factory=dict)
27
33
  model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
28
34
  type: Literal["TextToSpeechAgent"] = "TextToSpeechAgent"
29
35
 
30
- def model_post_init(self, __context: Any) -> None:
31
- """Rehydrate a serialized TTS component through its base registry."""
32
- if not isinstance(self.tts, dict):
33
- return
34
- type_name = self.tts.get("type")
36
+ @field_validator("tts", mode="before")
37
+ @classmethod
38
+ def _restore_tts(cls, value):
39
+ """Resolve serialized providers at validation time, after discovery."""
40
+ if not isinstance(value, dict):
41
+ return value
42
+ type_name = value.get("type")
35
43
  registry = TTSBase._registry.get("TTSBase", {})
36
44
  tts_class = registry.get("subtypes", {}).get(type_name)
37
45
  if tts_class is None and type_name == "TTSBase":
38
46
  tts_class = registry.get("model_cls", TTSBase)
39
- if tts_class is not None:
40
- self.tts = tts_class.model_validate(self.tts)
47
+ if tts_class is None:
48
+ raise ValueError(
49
+ "Import the serialized TTS provider before loading it."
50
+ )
51
+ return tts_class.model_validate(value)
41
52
 
42
53
  def exec(
43
54
  self,