lollms-client 0.11.0__py3-none-any.whl → 0.12.1__py3-none-any.whl

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.

Potentially problematic release.


This version of lollms-client might be problematic. Click here for more details.

@@ -13,6 +13,7 @@ class LollmsLLMBinding(ABC):
13
13
  """Abstract base class for all LOLLMS LLM bindings"""
14
14
 
15
15
  def __init__(self,
16
+ binding_name: Optional[str] ="unknown",
16
17
  host_address: Optional[str] = None,
17
18
  model_name: str = "",
18
19
  service_key: Optional[str] = None,
@@ -29,6 +30,7 @@ class LollmsLLMBinding(ABC):
29
30
  verify_ssl_certificate (bool): Whether to verify SSL certificates. Defaults to True.
30
31
  default_completion_format (ELF_COMPLETION_FORMAT): The completion format (Chat or Instruct)
31
32
  """
33
+ self.binding_name=binding_name
32
34
  if host_address is not None:
33
35
  self.host_address = host_address[:-1] if host_address.endswith("/") else host_address
34
36
  else:
@@ -0,0 +1,137 @@
1
+ # lollms_client/lollms_stt_binding.py
2
+ from abc import ABC, abstractmethod
3
+ import importlib
4
+ from pathlib import Path
5
+ from typing import Optional, List, Dict, Any, Union
6
+ from ascii_colors import trace_exception
7
+
8
+ class LollmsSTTBinding(ABC):
9
+ """Abstract base class for all LOLLMS Speech-to-Text bindings."""
10
+
11
+ def __init__(self,
12
+ host_address: Optional[str] = None,
13
+ model_name: Optional[str] = None, # Can represent a default model
14
+ service_key: Optional[str] = None,
15
+ verify_ssl_certificate: bool = True):
16
+ """
17
+ Initialize the LollmsSTTBinding base class.
18
+
19
+ Args:
20
+ host_address (Optional[str]): The host address for the STT service.
21
+ model_name (Optional[str]): A default identifier for the STT model.
22
+ service_key (Optional[str]): Authentication key for the service.
23
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
24
+ """
25
+ if host_address is not None:
26
+ self.host_address = host_address.rstrip('/')
27
+ else:
28
+ self.host_address = None
29
+ self.model_name = model_name
30
+ self.service_key = service_key
31
+ self.verify_ssl_certificate = verify_ssl_certificate
32
+
33
+ @abstractmethod
34
+ def transcribe_audio(self, audio_path: Union[str, Path], model: Optional[str] = None, **kwargs) -> str:
35
+ """
36
+ Transcribes the audio file at the given path into text.
37
+
38
+ Args:
39
+ audio_path (Union[str, Path]): The path to the audio file to transcribe.
40
+ model (Optional[str]): The specific STT model to use (if supported by the binding).
41
+ If None, a default model might be used.
42
+ **kwargs: Additional binding-specific parameters (e.g., language hint).
43
+
44
+ Returns:
45
+ str: The transcribed text.
46
+
47
+ Raises:
48
+ Exception: If audio transcription fails.
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def list_models(self, **kwargs) -> List[str]:
54
+ """
55
+ Lists the available STT models supported by the binding.
56
+
57
+ Args:
58
+ **kwargs: Additional binding-specific parameters.
59
+
60
+ Returns:
61
+ List[str]: A list of available STT model identifiers.
62
+ """
63
+ pass
64
+
65
+ class LollmsSTTBindingManager:
66
+ """Manages STT binding discovery and instantiation."""
67
+
68
+ def __init__(self, stt_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "stt_bindings"):
69
+ """
70
+ Initialize the LollmsSTTBindingManager.
71
+
72
+ Args:
73
+ stt_bindings_dir (Union[str, Path]): Directory containing STT binding implementations.
74
+ Defaults to the "stt_bindings" subdirectory.
75
+ """
76
+ self.stt_bindings_dir = Path(stt_bindings_dir)
77
+ self.available_bindings = {}
78
+
79
+ def _load_binding(self, binding_name: str):
80
+ """Dynamically load a specific STT binding implementation."""
81
+ binding_dir = self.stt_bindings_dir / binding_name
82
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
83
+ try:
84
+ module = importlib.import_module(f"lollms_client.stt_bindings.{binding_name}")
85
+ binding_class = getattr(module, module.BindingName) # Assumes BindingName is defined
86
+ self.available_bindings[binding_name] = binding_class
87
+ except Exception as e:
88
+ trace_exception(e)
89
+ print(f"Failed to load STT binding {binding_name}: {str(e)}")
90
+
91
+ def create_binding(self,
92
+ binding_name: str,
93
+ host_address: Optional[str] = None,
94
+ model_name: Optional[str] = None,
95
+ service_key: Optional[str] = None,
96
+ verify_ssl_certificate: bool = True,
97
+ **kwargs) -> Optional[LollmsSTTBinding]:
98
+ """
99
+ Create an instance of a specific STT binding.
100
+
101
+ Args:
102
+ binding_name (str): Name of the STT binding to create.
103
+ host_address (Optional[str]): Host address for the service.
104
+ model_name (Optional[str]): Default model identifier.
105
+ service_key (Optional[str]): Authentication key for the service.
106
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
107
+ **kwargs: Additional parameters specific to the binding's __init__.
108
+
109
+ Returns:
110
+ Optional[LollmsSTTBinding]: Binding instance or None if creation failed.
111
+ """
112
+ if binding_name not in self.available_bindings:
113
+ self._load_binding(binding_name)
114
+
115
+ binding_class = self.available_bindings.get(binding_name)
116
+ if binding_class:
117
+ try:
118
+ return binding_class(host_address=host_address,
119
+ model_name=model_name,
120
+ service_key=service_key,
121
+ verify_ssl_certificate=verify_ssl_certificate,
122
+ **kwargs)
123
+ except Exception as e:
124
+ trace_exception(e)
125
+ print(f"Failed to instantiate STT binding {binding_name}: {str(e)}")
126
+ return None
127
+ return None
128
+
129
+ def get_available_bindings(self) -> list[str]:
130
+ """
131
+ Return list of available STT binding names based on subdirectories.
132
+
133
+ Returns:
134
+ list[str]: List of binding names.
135
+ """
136
+ return [binding_dir.name for binding_dir in self.stt_bindings_dir.iterdir()
137
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
@@ -7,7 +7,6 @@ from functools import partial
7
7
  import json
8
8
  import sys
9
9
  from datetime import datetime
10
- from lollmsvectordb.text_chunker import TextChunker
11
10
 
12
11
  class TasksLibrary:
13
12
  def __init__(self, lollms:LollmsClient, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None) -> None:
@@ -422,7 +421,7 @@ class TasksLibrary:
422
421
  while len(tk)>max_summary_size and (document_chunks is None or len(document_chunks)>1):
423
422
  self.step_start(f"Comprerssing {doc_name}... [depth {depth+1}]")
424
423
  chunk_size = int(self.lollms.ctx_size*0.6)
425
- document_chunks = TextChunker.chunk_text(text, self.lollms, chunk_size, 0, True)
424
+ document_chunks = chunk_text(text, self.lollms, chunk_size, 0, True)
426
425
  text = self.summerize_chunks(
427
426
  document_chunks,
428
427
  summary_instruction,
@@ -0,0 +1,175 @@
1
+ # lollms_client/lollms_tti_binding.py
2
+ from abc import ABC, abstractmethod
3
+ import importlib
4
+ from pathlib import Path
5
+ from typing import Optional, List, Dict, Any, Union
6
+ from ascii_colors import trace_exception
7
+
8
+ class LollmsTTIBinding(ABC):
9
+ """Abstract base class for all LOLLMS Text-to-Image bindings."""
10
+
11
+ def __init__(self,
12
+ host_address: Optional[str] = None,
13
+ model_name: Optional[str] = None, # Can represent a default service/model
14
+ service_key: Optional[str] = None,
15
+ verify_ssl_certificate: bool = True):
16
+ """
17
+ Initialize the LollmsTTIBinding base class.
18
+
19
+ Args:
20
+ host_address (Optional[str]): The host address for the TTI service.
21
+ model_name (Optional[str]): A default identifier (e.g., service or model name).
22
+ service_key (Optional[str]): Authentication key for the service.
23
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
24
+ """
25
+ if host_address is not None:
26
+ self.host_address = host_address.rstrip('/')
27
+ else:
28
+ self.host_address = None
29
+ self.model_name = model_name
30
+ self.service_key = service_key
31
+ self.verify_ssl_certificate = verify_ssl_certificate
32
+
33
+ @abstractmethod
34
+ def generate_image(self,
35
+ prompt: str,
36
+ negative_prompt: Optional[str] = "",
37
+ width: int = 512,
38
+ height: int = 512,
39
+ **kwargs) -> bytes:
40
+ """
41
+ Generates image data from the provided text prompt.
42
+
43
+ Args:
44
+ prompt (str): The positive text prompt describing the desired image.
45
+ negative_prompt (Optional[str]): Text prompt describing elements to avoid.
46
+ width (int): The desired width of the image.
47
+ height (int): The desired height of the image.
48
+ **kwargs: Additional binding-specific parameters (e.g., seed, steps, cfg_scale).
49
+
50
+ Returns:
51
+ bytes: The generated image data (e.g., in PNG or JPEG format).
52
+
53
+ Raises:
54
+ Exception: If image generation fails.
55
+ """
56
+ pass
57
+
58
+ @abstractmethod
59
+ def list_services(self, **kwargs) -> List[Dict[str, str]]:
60
+ """
61
+ Lists the available TTI services or models supported by the binding.
62
+ This might require authentication depending on the implementation.
63
+
64
+ Args:
65
+ **kwargs: Additional binding-specific parameters (e.g., client_id).
66
+
67
+ Returns:
68
+ List[Dict[str, str]]: A list of dictionaries, each describing a service
69
+ (e.g., {"name": "...", "caption": "...", "help": "..."}).
70
+ """
71
+ pass
72
+
73
+ @abstractmethod
74
+ def get_settings(self, **kwargs) -> Optional[Dict[str, Any]]:
75
+ """
76
+ Retrieves the current settings for the active TTI service/model.
77
+ This might require authentication depending on the implementation.
78
+
79
+ Args:
80
+ **kwargs: Additional binding-specific parameters (e.g., client_id).
81
+
82
+ Returns:
83
+ Optional[Dict[str, Any]]: A dictionary representing the settings structure
84
+ (often a list matching ConfigTemplate format) or None if not supported/failed.
85
+ """
86
+ pass
87
+
88
+ @abstractmethod
89
+ def set_settings(self, settings: Dict[str, Any], **kwargs) -> bool:
90
+ """
91
+ Applies new settings to the active TTI service/model.
92
+ This might require authentication depending on the implementation.
93
+
94
+ Args:
95
+ settings (Dict[str, Any]): The new settings to apply (structure depends on the service).
96
+ **kwargs: Additional binding-specific parameters (e.g., client_id).
97
+
98
+ Returns:
99
+ bool: True if settings were applied successfully, False otherwise.
100
+ """
101
+ pass
102
+
103
+ class LollmsTTIBindingManager:
104
+ """Manages TTI binding discovery and instantiation."""
105
+
106
+ def __init__(self, tti_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "tti_bindings"):
107
+ """
108
+ Initialize the LollmsTTIBindingManager.
109
+
110
+ Args:
111
+ tti_bindings_dir (Union[str, Path]): Directory containing TTI binding implementations.
112
+ Defaults to the "tti_bindings" subdirectory.
113
+ """
114
+ self.tti_bindings_dir = Path(tti_bindings_dir)
115
+ self.available_bindings = {}
116
+
117
+ def _load_binding(self, binding_name: str):
118
+ """Dynamically load a specific TTI binding implementation."""
119
+ binding_dir = self.tti_bindings_dir / binding_name
120
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
121
+ try:
122
+ module = importlib.import_module(f"lollms_client.tti_bindings.{binding_name}")
123
+ binding_class = getattr(module, module.BindingName) # Assumes BindingName is defined
124
+ self.available_bindings[binding_name] = binding_class
125
+ except Exception as e:
126
+ trace_exception(e)
127
+ print(f"Failed to load TTI binding {binding_name}: {str(e)}")
128
+
129
+ def create_binding(self,
130
+ binding_name: str,
131
+ host_address: Optional[str] = None,
132
+ model_name: Optional[str] = None,
133
+ service_key: Optional[str] = None,
134
+ verify_ssl_certificate: bool = True,
135
+ **kwargs) -> Optional[LollmsTTIBinding]:
136
+ """
137
+ Create an instance of a specific TTI binding.
138
+
139
+ Args:
140
+ binding_name (str): Name of the TTI binding to create.
141
+ host_address (Optional[str]): Host address for the service.
142
+ model_name (Optional[str]): Default model/service identifier.
143
+ service_key (Optional[str]): Authentication key for the service.
144
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
145
+ **kwargs: Additional parameters specific to the binding's __init__.
146
+
147
+ Returns:
148
+ Optional[LollmsTTIBinding]: Binding instance or None if creation failed.
149
+ """
150
+ if binding_name not in self.available_bindings:
151
+ self._load_binding(binding_name)
152
+
153
+ binding_class = self.available_bindings.get(binding_name)
154
+ if binding_class:
155
+ try:
156
+ return binding_class(host_address=host_address,
157
+ model_name=model_name,
158
+ service_key=service_key,
159
+ verify_ssl_certificate=verify_ssl_certificate,
160
+ **kwargs)
161
+ except Exception as e:
162
+ trace_exception(e)
163
+ print(f"Failed to instantiate TTI binding {binding_name}: {str(e)}")
164
+ return None
165
+ return None
166
+
167
+ def get_available_bindings(self) -> list[str]:
168
+ """
169
+ Return list of available TTI binding names based on subdirectories.
170
+
171
+ Returns:
172
+ list[str]: List of binding names.
173
+ """
174
+ return [binding_dir.name for binding_dir in self.tti_bindings_dir.iterdir()
175
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
@@ -0,0 +1,135 @@
1
+ # lollms_client/lollms_ttm_binding.py
2
+ from abc import ABC, abstractmethod
3
+ import importlib
4
+ from pathlib import Path
5
+ from typing import Optional, List, Dict, Any, Union
6
+ from ascii_colors import trace_exception
7
+
8
+ class LollmsTTMBinding(ABC):
9
+ """Abstract base class for all LOLLMS Text-to-Music bindings."""
10
+
11
+ def __init__(self,
12
+ host_address: Optional[str] = None,
13
+ model_name: Optional[str] = None, # Can represent a default model/service
14
+ service_key: Optional[str] = None,
15
+ verify_ssl_certificate: bool = True):
16
+ """
17
+ Initialize the LollmsTTMBinding base class.
18
+
19
+ Args:
20
+ host_address (Optional[str]): The host address for the TTM service.
21
+ model_name (Optional[str]): A default identifier (e.g., service or model name).
22
+ service_key (Optional[str]): Authentication key for the service.
23
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
24
+ """
25
+ if host_address is not None:
26
+ self.host_address = host_address.rstrip('/')
27
+ else:
28
+ self.host_address = None
29
+ self.model_name = model_name
30
+ self.service_key = service_key
31
+ self.verify_ssl_certificate = verify_ssl_certificate
32
+
33
+ @abstractmethod
34
+ def generate_music(self, prompt: str, **kwargs) -> bytes:
35
+ """
36
+ Generates music data from the provided text prompt.
37
+
38
+ Args:
39
+ prompt (str): The text prompt describing the desired music (e.g., genre, mood, instruments).
40
+ **kwargs: Additional binding-specific parameters (e.g., duration, style, seed).
41
+
42
+ Returns:
43
+ bytes: The generated music data (e.g., in WAV, MP3, or MIDI format).
44
+
45
+ Raises:
46
+ Exception: If music generation fails.
47
+ """
48
+ pass
49
+
50
+ @abstractmethod
51
+ def list_models(self, **kwargs) -> List[str]:
52
+ """
53
+ Lists the available TTM models or services supported by the binding.
54
+
55
+ Args:
56
+ **kwargs: Additional binding-specific parameters.
57
+
58
+ Returns:
59
+ List[str]: A list of available model/service identifiers.
60
+ """
61
+ pass
62
+
63
+ class LollmsTTMBindingManager:
64
+ """Manages TTM binding discovery and instantiation."""
65
+
66
+ def __init__(self, ttm_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "ttm_bindings"):
67
+ """
68
+ Initialize the LollmsTTMBindingManager.
69
+
70
+ Args:
71
+ ttm_bindings_dir (Union[str, Path]): Directory containing TTM binding implementations.
72
+ Defaults to the "ttm_bindings" subdirectory.
73
+ """
74
+ self.ttm_bindings_dir = Path(ttm_bindings_dir)
75
+ self.available_bindings = {}
76
+
77
+ def _load_binding(self, binding_name: str):
78
+ """Dynamically load a specific TTM binding implementation."""
79
+ binding_dir = self.ttm_bindings_dir / binding_name
80
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
81
+ try:
82
+ module = importlib.import_module(f"lollms_client.ttm_bindings.{binding_name}")
83
+ binding_class = getattr(module, module.BindingName) # Assumes BindingName is defined
84
+ self.available_bindings[binding_name] = binding_class
85
+ except Exception as e:
86
+ trace_exception(e)
87
+ print(f"Failed to load TTM binding {binding_name}: {str(e)}")
88
+
89
+ def create_binding(self,
90
+ binding_name: str,
91
+ host_address: Optional[str] = None,
92
+ model_name: Optional[str] = None,
93
+ service_key: Optional[str] = None,
94
+ verify_ssl_certificate: bool = True,
95
+ **kwargs) -> Optional[LollmsTTMBinding]:
96
+ """
97
+ Create an instance of a specific TTM binding.
98
+
99
+ Args:
100
+ binding_name (str): Name of the TTM binding to create.
101
+ host_address (Optional[str]): Host address for the service.
102
+ model_name (Optional[str]): Default model/service identifier.
103
+ service_key (Optional[str]): Authentication key for the service.
104
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
105
+ **kwargs: Additional parameters specific to the binding's __init__.
106
+
107
+ Returns:
108
+ Optional[LollmsTTMBinding]: Binding instance or None if creation failed.
109
+ """
110
+ if binding_name not in self.available_bindings:
111
+ self._load_binding(binding_name)
112
+
113
+ binding_class = self.available_bindings.get(binding_name)
114
+ if binding_class:
115
+ try:
116
+ return binding_class(host_address=host_address,
117
+ model_name=model_name,
118
+ service_key=service_key,
119
+ verify_ssl_certificate=verify_ssl_certificate,
120
+ **kwargs)
121
+ except Exception as e:
122
+ trace_exception(e)
123
+ print(f"Failed to instantiate TTM binding {binding_name}: {str(e)}")
124
+ return None
125
+ return None
126
+
127
+ def get_available_bindings(self) -> list[str]:
128
+ """
129
+ Return list of available TTM binding names based on subdirectories.
130
+
131
+ Returns:
132
+ list[str]: List of binding names.
133
+ """
134
+ return [binding_dir.name for binding_dir in self.ttm_bindings_dir.iterdir()
135
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
@@ -0,0 +1,138 @@
1
+ # lollms_client/lollms_tts_binding.py
2
+ from abc import ABC, abstractmethod
3
+ import importlib
4
+ from pathlib import Path
5
+ from typing import Optional, List, Dict, Any, Union, Callable
6
+ from ascii_colors import trace_exception
7
+
8
+ class LollmsTTSBinding(ABC):
9
+ """Abstract base class for all LOLLMS Text-to-Speech bindings."""
10
+
11
+ def __init__(self,
12
+ host_address: Optional[str] = None,
13
+ model_name: Optional[str] = None, # Can represent a default voice or model
14
+ service_key: Optional[str] = None,
15
+ verify_ssl_certificate: bool = True):
16
+ """
17
+ Initialize the LollmsTTSBinding base class.
18
+
19
+ Args:
20
+ host_address (Optional[str]): The host address for the TTS service.
21
+ model_name (Optional[str]): A default identifier (e.g., voice or model name).
22
+ service_key (Optional[str]): Authentication key for the service.
23
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
24
+ """
25
+ if host_address is not None:
26
+ self.host_address = host_address.rstrip('/')
27
+ else:
28
+ self.host_address = None
29
+ self.model_name = model_name
30
+ self.service_key = service_key
31
+ self.verify_ssl_certificate = verify_ssl_certificate
32
+
33
+ @abstractmethod
34
+ def generate_audio(self, text: str, voice: Optional[str] = None, **kwargs) -> bytes:
35
+ """
36
+ Generates audio data from the provided text.
37
+
38
+ Args:
39
+ text (str): The text content to synthesize.
40
+ voice (Optional[str]): The specific voice or model to use (if supported by the binding).
41
+ If None, a default voice might be used.
42
+ **kwargs: Additional binding-specific parameters.
43
+
44
+ Returns:
45
+ bytes: The generated audio data (e.g., in WAV or MP3 format).
46
+
47
+ Raises:
48
+ Exception: If audio generation fails.
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def list_voices(self, **kwargs) -> List[str]:
54
+ """
55
+ Lists the available voices or TTS models supported by the binding.
56
+
57
+ Args:
58
+ **kwargs: Additional binding-specific parameters.
59
+
60
+ Returns:
61
+ List[str]: A list of available voice/model identifiers.
62
+ """
63
+ pass
64
+
65
+ class LollmsTTSBindingManager:
66
+ """Manages TTS binding discovery and instantiation."""
67
+
68
+ def __init__(self, tts_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "tts_bindings"):
69
+ """
70
+ Initialize the LollmsTTSBindingManager.
71
+
72
+ Args:
73
+ tts_bindings_dir (Union[str, Path]): Directory containing TTS binding implementations.
74
+ Defaults to the "tts_bindings" subdirectory.
75
+ """
76
+ self.tts_bindings_dir = Path(tts_bindings_dir)
77
+ self.available_bindings = {}
78
+
79
+ def _load_binding(self, binding_name: str):
80
+ """Dynamically load a specific TTS binding implementation."""
81
+ binding_dir = self.tts_bindings_dir / binding_name
82
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
83
+ try:
84
+ # Adjust module path for dynamic loading
85
+ module = importlib.import_module(f"lollms_client.tts_bindings.{binding_name}")
86
+ binding_class = getattr(module, module.BindingName) # Assumes BindingName is defined
87
+ self.available_bindings[binding_name] = binding_class
88
+ except Exception as e:
89
+ trace_exception(e)
90
+ print(f"Failed to load TTS binding {binding_name}: {str(e)}")
91
+
92
+ def create_binding(self,
93
+ binding_name: str,
94
+ host_address: Optional[str] = None,
95
+ model_name: Optional[str] = None,
96
+ service_key: Optional[str] = None,
97
+ verify_ssl_certificate: bool = True,
98
+ **kwargs) -> Optional[LollmsTTSBinding]:
99
+ """
100
+ Create an instance of a specific TTS binding.
101
+
102
+ Args:
103
+ binding_name (str): Name of the TTS binding to create.
104
+ host_address (Optional[str]): Host address for the service.
105
+ model_name (Optional[str]): Default model/voice identifier.
106
+ service_key (Optional[str]): Authentication key for the service.
107
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
108
+ **kwargs: Additional parameters specific to the binding's __init__.
109
+
110
+ Returns:
111
+ Optional[LollmsTTSBinding]: Binding instance or None if creation failed.
112
+ """
113
+ if binding_name not in self.available_bindings:
114
+ self._load_binding(binding_name)
115
+
116
+ binding_class = self.available_bindings.get(binding_name)
117
+ if binding_class:
118
+ try:
119
+ return binding_class(host_address=host_address,
120
+ model_name=model_name,
121
+ service_key=service_key,
122
+ verify_ssl_certificate=verify_ssl_certificate,
123
+ **kwargs)
124
+ except Exception as e:
125
+ trace_exception(e)
126
+ print(f"Failed to instantiate TTS binding {binding_name}: {str(e)}")
127
+ return None
128
+ return None
129
+
130
+ def get_available_bindings(self) -> list[str]:
131
+ """
132
+ Return list of available TTS binding names based on subdirectories.
133
+
134
+ Returns:
135
+ list[str]: List of binding names.
136
+ """
137
+ return [binding_dir.name for binding_dir in self.tts_bindings_dir.iterdir()
138
+ if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]