lollms-client 1.1.3__py3-none-any.whl → 1.3.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.
- lollms_client/__init__.py +1 -1
- lollms_client/llm_bindings/lollms/__init__.py +2 -2
- lollms_client/llm_bindings/ollama/__init__.py +80 -23
- lollms_client/llm_bindings/openai/__init__.py +3 -3
- lollms_client/lollms_core.py +286 -132
- lollms_client/lollms_discussion.py +419 -147
- lollms_client/lollms_tti_binding.py +32 -82
- lollms_client/tti_bindings/diffusers/__init__.py +372 -315
- lollms_client/tti_bindings/openai/__init__.py +124 -0
- {lollms_client-1.1.3.dist-info → lollms_client-1.3.1.dist-info}/METADATA +1 -1
- {lollms_client-1.1.3.dist-info → lollms_client-1.3.1.dist-info}/RECORD +14 -14
- lollms_client/tti_bindings/dalle/__init__.py +0 -454
- {lollms_client-1.1.3.dist-info → lollms_client-1.3.1.dist-info}/WHEEL +0 -0
- {lollms_client-1.1.3.dist-info → lollms_client-1.3.1.dist-info}/licenses/LICENSE +0 -0
- {lollms_client-1.1.3.dist-info → lollms_client-1.3.1.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# lollms_client/lollms_tti_binding.py
|
|
2
1
|
from abc import ABC, abstractmethod
|
|
3
2
|
import importlib
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from typing import Optional, List, Dict, Any, Union
|
|
6
5
|
from ascii_colors import trace_exception
|
|
7
6
|
import yaml
|
|
7
|
+
|
|
8
8
|
class LollmsTTIBinding(ABC):
|
|
9
9
|
"""Abstract base class for all LOLLMS Text-to-Image bindings."""
|
|
10
10
|
|
|
@@ -44,34 +44,42 @@ class LollmsTTIBinding(ABC):
|
|
|
44
44
|
pass
|
|
45
45
|
|
|
46
46
|
@abstractmethod
|
|
47
|
-
def
|
|
47
|
+
def edit_image(self,
|
|
48
|
+
images: Union[str, List[str]],
|
|
49
|
+
prompt: str,
|
|
50
|
+
negative_prompt: Optional[str] = "",
|
|
51
|
+
mask: Optional[str] = None,
|
|
52
|
+
width: Optional[int] = None,
|
|
53
|
+
height: Optional[int] = None,
|
|
54
|
+
**kwargs) -> bytes:
|
|
48
55
|
"""
|
|
49
|
-
|
|
50
|
-
This might require authentication depending on the implementation.
|
|
56
|
+
Edits an image or a set of images based on the provided prompts.
|
|
51
57
|
|
|
52
58
|
Args:
|
|
53
|
-
|
|
59
|
+
images (Union[str, List[str]]): One or multiple images in URL or base64 format.
|
|
60
|
+
prompt (str): Positive prompt describing desired modifications.
|
|
61
|
+
negative_prompt (Optional[str]): Prompt describing elements to avoid.
|
|
62
|
+
mask (Optional[str]): A mask image (URL or base64). Only valid if a single image is provided.
|
|
63
|
+
width (Optional[int]): Desired width of the output. If None, binding decides.
|
|
64
|
+
height (Optional[int]): Desired height of the output. If None, binding decides.
|
|
65
|
+
**kwargs: Additional binding-specific parameters (e.g., seed, steps, cfg_scale).
|
|
54
66
|
|
|
55
67
|
Returns:
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
bytes: The edited/generated image data (e.g., in PNG or JPEG format).
|
|
69
|
+
|
|
70
|
+
Raises:
|
|
71
|
+
Exception: If image editing fails.
|
|
58
72
|
"""
|
|
59
73
|
pass
|
|
60
74
|
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def list_services(self, **kwargs) -> List[Dict[str, str]]:
|
|
77
|
+
"""Lists the available TTI services or models supported by the binding."""
|
|
78
|
+
pass
|
|
61
79
|
|
|
62
80
|
@abstractmethod
|
|
63
81
|
def get_settings(self, **kwargs) -> Optional[Dict[str, Any]]:
|
|
64
|
-
"""
|
|
65
|
-
Retrieves the current settings for the active TTI service/model.
|
|
66
|
-
This might require authentication depending on the implementation.
|
|
67
|
-
|
|
68
|
-
Args:
|
|
69
|
-
**kwargs: Additional binding-specific parameters (e.g., client_id).
|
|
70
|
-
|
|
71
|
-
Returns:
|
|
72
|
-
Optional[Dict[str, Any]]: A dictionary representing the settings structure
|
|
73
|
-
(often a list matching ConfigTemplate format) or None if not supported/failed.
|
|
74
|
-
"""
|
|
82
|
+
"""Retrieves the current settings for the active TTI service/model."""
|
|
75
83
|
pass
|
|
76
84
|
|
|
77
85
|
@abstractmethod
|
|
@@ -81,35 +89,18 @@ class LollmsTTIBinding(ABC):
|
|
|
81
89
|
|
|
82
90
|
@abstractmethod
|
|
83
91
|
def set_settings(self, settings: Dict[str, Any], **kwargs) -> bool:
|
|
84
|
-
"""
|
|
85
|
-
Applies new settings to the active TTI service/model.
|
|
86
|
-
This might require authentication depending on the implementation.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
settings (Dict[str, Any]): The new settings to apply (structure depends on the service).
|
|
90
|
-
**kwargs: Additional binding-specific parameters (e.g., client_id).
|
|
91
|
-
|
|
92
|
-
Returns:
|
|
93
|
-
bool: True if settings were applied successfully, False otherwise.
|
|
94
|
-
"""
|
|
92
|
+
"""Applies new settings to the active TTI service/model."""
|
|
95
93
|
pass
|
|
96
94
|
|
|
95
|
+
|
|
97
96
|
class LollmsTTIBindingManager:
|
|
98
97
|
"""Manages TTI binding discovery and instantiation."""
|
|
99
98
|
|
|
100
99
|
def __init__(self, tti_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "tti_bindings"):
|
|
101
|
-
"""
|
|
102
|
-
Initialize the LollmsTTIBindingManager.
|
|
103
|
-
|
|
104
|
-
Args:
|
|
105
|
-
tti_bindings_dir (Union[str, Path]): Directory containing TTI binding implementations.
|
|
106
|
-
Defaults to the "tti_bindings" subdirectory.
|
|
107
|
-
"""
|
|
108
100
|
self.tti_bindings_dir = Path(tti_bindings_dir)
|
|
109
101
|
self.available_bindings = {}
|
|
110
102
|
|
|
111
103
|
def _load_binding(self, binding_name: str):
|
|
112
|
-
"""Dynamically load a specific TTI binding implementation."""
|
|
113
104
|
binding_dir = self.tti_bindings_dir / binding_name
|
|
114
105
|
if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
|
|
115
106
|
try:
|
|
@@ -123,16 +114,6 @@ class LollmsTTIBindingManager:
|
|
|
123
114
|
def create_binding(self,
|
|
124
115
|
binding_name: str,
|
|
125
116
|
**kwargs) -> Optional[LollmsTTIBinding]:
|
|
126
|
-
"""
|
|
127
|
-
Create an instance of a specific TTI binding.
|
|
128
|
-
|
|
129
|
-
Args:
|
|
130
|
-
binding_name (str): Name of the TTI binding to create.
|
|
131
|
-
**kwargs: Additional parameters specific to the binding's __init__.
|
|
132
|
-
|
|
133
|
-
Returns:
|
|
134
|
-
Optional[LollmsTTIBinding]: Binding instance or None if creation failed.
|
|
135
|
-
"""
|
|
136
117
|
if binding_name not in self.available_bindings:
|
|
137
118
|
self._load_binding(binding_name)
|
|
138
119
|
|
|
@@ -145,10 +126,8 @@ class LollmsTTIBindingManager:
|
|
|
145
126
|
print(f"Failed to instantiate TTI binding {binding_name}: {str(e)}")
|
|
146
127
|
return None
|
|
147
128
|
return None
|
|
129
|
+
|
|
148
130
|
def _get_fallback_description(binding_name: str) -> Dict:
|
|
149
|
-
"""
|
|
150
|
-
Generates a default description dictionary for a binding without a description.yaml file.
|
|
151
|
-
"""
|
|
152
131
|
return {
|
|
153
132
|
"binding_name": binding_name,
|
|
154
133
|
"title": binding_name.replace("_", " ").title(),
|
|
@@ -190,16 +169,6 @@ class LollmsTTIBindingManager:
|
|
|
190
169
|
|
|
191
170
|
@staticmethod
|
|
192
171
|
def get_bindings_list(llm_bindings_dir: Union[str, Path]) -> List[Dict]:
|
|
193
|
-
"""
|
|
194
|
-
Lists all available LLM bindings by scanning a directory, loading their
|
|
195
|
-
description.yaml file if present, or providing a default description.
|
|
196
|
-
|
|
197
|
-
Args:
|
|
198
|
-
llm_bindings_dir (Union[str, Path]): The path to the directory containing LLM binding folders.
|
|
199
|
-
|
|
200
|
-
Returns:
|
|
201
|
-
List[Dict]: A list of dictionaries, each describing a binding.
|
|
202
|
-
"""
|
|
203
172
|
bindings_dir = Path(llm_bindings_dir)
|
|
204
173
|
if not bindings_dir.is_dir():
|
|
205
174
|
return []
|
|
@@ -225,32 +194,13 @@ class LollmsTTIBindingManager:
|
|
|
225
194
|
bindings_list.append(binding_info)
|
|
226
195
|
|
|
227
196
|
return sorted(bindings_list, key=lambda b: b.get('title', b['binding_name']))
|
|
228
|
-
def get_available_bindings(self) -> list[str]:
|
|
229
|
-
"""
|
|
230
|
-
Return list of available TTI binding names based on subdirectories.
|
|
231
197
|
|
|
232
|
-
|
|
233
|
-
list[str]: List of binding names.
|
|
234
|
-
"""
|
|
198
|
+
def get_available_bindings(self) -> list[str]:
|
|
235
199
|
return [binding_dir.name for binding_dir in self.tti_bindings_dir.iterdir()
|
|
236
200
|
if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
|
|
237
201
|
|
|
238
|
-
def get_available_bindings(tti_bindings_dir: Union[str, Path] = None) -> List[Dict]:
|
|
239
|
-
"""
|
|
240
|
-
Lists all available LLM bindings with their detailed descriptions.
|
|
241
|
-
|
|
242
|
-
This function serves as a primary entry point for discovering what bindings
|
|
243
|
-
are available and how to configure them.
|
|
244
|
-
|
|
245
|
-
Args:
|
|
246
|
-
llm_bindings_dir (Union[str, Path], optional):
|
|
247
|
-
The path to the LLM bindings directory. If None, it defaults to the
|
|
248
|
-
'llm_bindings' subdirectory relative to this file.
|
|
249
|
-
Defaults to None.
|
|
250
202
|
|
|
251
|
-
|
|
252
|
-
List[Dict]: A list of dictionaries, each describing a binding.
|
|
253
|
-
"""
|
|
203
|
+
def get_available_bindings(tti_bindings_dir: Union[str, Path] = None) -> List[Dict]:
|
|
254
204
|
if tti_bindings_dir is None:
|
|
255
205
|
tti_bindings_dir = Path(__file__).parent / "tti_bindings"
|
|
256
|
-
return LollmsTTIBindingManager.get_bindings_list(tti_bindings_dir)
|
|
206
|
+
return LollmsTTIBindingManager.get_bindings_list(tti_bindings_dir)
|