lollms-client 1.5.6__py3-none-any.whl → 1.7.13__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.
- lollms_client/__init__.py +1 -1
- lollms_client/llm_bindings/azure_openai/__init__.py +2 -2
- lollms_client/llm_bindings/claude/__init__.py +125 -35
- lollms_client/llm_bindings/gemini/__init__.py +261 -159
- lollms_client/llm_bindings/grok/__init__.py +52 -15
- lollms_client/llm_bindings/groq/__init__.py +2 -2
- lollms_client/llm_bindings/hugging_face_inference_api/__init__.py +2 -2
- lollms_client/llm_bindings/litellm/__init__.py +1 -1
- lollms_client/llm_bindings/llama_cpp_server/__init__.py +605 -0
- lollms_client/llm_bindings/llamacpp/__init__.py +18 -11
- lollms_client/llm_bindings/lollms/__init__.py +76 -21
- lollms_client/llm_bindings/lollms_webui/__init__.py +1 -1
- lollms_client/llm_bindings/mistral/__init__.py +2 -2
- lollms_client/llm_bindings/novita_ai/__init__.py +142 -6
- lollms_client/llm_bindings/ollama/__init__.py +345 -89
- lollms_client/llm_bindings/open_router/__init__.py +2 -2
- lollms_client/llm_bindings/openai/__init__.py +81 -20
- lollms_client/llm_bindings/openllm/__init__.py +362 -506
- lollms_client/llm_bindings/openwebui/__init__.py +333 -171
- lollms_client/llm_bindings/perplexity/__init__.py +2 -2
- lollms_client/llm_bindings/pythonllamacpp/__init__.py +3 -3
- lollms_client/llm_bindings/tensor_rt/__init__.py +1 -1
- lollms_client/llm_bindings/transformers/__init__.py +428 -632
- lollms_client/llm_bindings/vllm/__init__.py +1 -1
- lollms_client/lollms_agentic.py +4 -2
- lollms_client/lollms_base_binding.py +61 -0
- lollms_client/lollms_core.py +512 -1890
- lollms_client/lollms_discussion.py +65 -39
- lollms_client/lollms_llm_binding.py +126 -261
- lollms_client/lollms_mcp_binding.py +49 -77
- lollms_client/lollms_stt_binding.py +99 -52
- lollms_client/lollms_tti_binding.py +38 -38
- lollms_client/lollms_ttm_binding.py +38 -42
- lollms_client/lollms_tts_binding.py +43 -18
- lollms_client/lollms_ttv_binding.py +38 -42
- lollms_client/lollms_types.py +4 -2
- lollms_client/stt_bindings/whisper/__init__.py +108 -23
- lollms_client/stt_bindings/whispercpp/__init__.py +7 -1
- lollms_client/tti_bindings/diffusers/__init__.py +464 -803
- lollms_client/tti_bindings/diffusers/server/main.py +1062 -0
- lollms_client/tti_bindings/gemini/__init__.py +182 -239
- lollms_client/tti_bindings/leonardo_ai/__init__.py +6 -3
- lollms_client/tti_bindings/lollms/__init__.py +4 -1
- lollms_client/tti_bindings/novita_ai/__init__.py +5 -2
- lollms_client/tti_bindings/openai/__init__.py +10 -11
- lollms_client/tti_bindings/stability_ai/__init__.py +5 -3
- lollms_client/ttm_bindings/audiocraft/__init__.py +7 -12
- lollms_client/ttm_bindings/beatoven_ai/__init__.py +7 -3
- lollms_client/ttm_bindings/lollms/__init__.py +4 -17
- lollms_client/ttm_bindings/replicate/__init__.py +7 -4
- lollms_client/ttm_bindings/stability_ai/__init__.py +7 -4
- lollms_client/ttm_bindings/topmediai/__init__.py +6 -3
- lollms_client/tts_bindings/bark/__init__.py +7 -10
- lollms_client/tts_bindings/lollms/__init__.py +6 -1
- lollms_client/tts_bindings/piper_tts/__init__.py +8 -11
- lollms_client/tts_bindings/xtts/__init__.py +157 -74
- lollms_client/tts_bindings/xtts/server/main.py +241 -280
- {lollms_client-1.5.6.dist-info → lollms_client-1.7.13.dist-info}/METADATA +113 -5
- lollms_client-1.7.13.dist-info/RECORD +90 -0
- lollms_client-1.5.6.dist-info/RECORD +0 -87
- {lollms_client-1.5.6.dist-info → lollms_client-1.7.13.dist-info}/WHEEL +0 -0
- {lollms_client-1.5.6.dist-info → lollms_client-1.7.13.dist-info}/licenses/LICENSE +0 -0
- {lollms_client-1.5.6.dist-info → lollms_client-1.7.13.dist-info}/top_level.txt +0 -0
|
@@ -26,9 +26,11 @@ GROK_API_BASE_URL = "https://api.x.ai/v1"
|
|
|
26
26
|
|
|
27
27
|
# A hardcoded list to be used as a fallback if the API call fails
|
|
28
28
|
_FALLBACK_MODELS = [
|
|
29
|
-
{'model_name': 'grok-
|
|
30
|
-
{'model_name': 'grok-
|
|
31
|
-
{'model_name': 'grok-
|
|
29
|
+
{'model_name': 'grok-2-latest', 'display_name': 'Grok 2 Latest', 'description': 'The latest conversational model from xAI.', 'owned_by': 'xAI'},
|
|
30
|
+
{'model_name': 'grok-2', 'display_name': 'Grok 2', 'description': 'Grok 2 model.', 'owned_by': 'xAI'},
|
|
31
|
+
{'model_name': 'grok-2-vision-latest', 'display_name': 'Grok 2 Vision Latest', 'description': 'Latest multimodal model from xAI.', 'owned_by': 'xAI'},
|
|
32
|
+
{'model_name': 'grok-beta', 'display_name': 'Grok Beta', 'description': 'Beta model.', 'owned_by': 'xAI'},
|
|
33
|
+
{'model_name': 'grok-vision-beta', 'display_name': 'Grok Vision Beta', 'description': 'Beta vision model.', 'owned_by': 'xAI'},
|
|
32
34
|
]
|
|
33
35
|
|
|
34
36
|
# Helper to check if a string is a valid path to an image
|
|
@@ -70,7 +72,7 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
70
72
|
service_key (str): xAI API key.
|
|
71
73
|
"""
|
|
72
74
|
super().__init__(BindingName, **kwargs)
|
|
73
|
-
self.model_name = kwargs.get("model_name", "grok-
|
|
75
|
+
self.model_name = kwargs.get("model_name", "grok-2-latest")
|
|
74
76
|
self.service_key = kwargs.get("service_key")
|
|
75
77
|
self.base_url = kwargs.get("base_url", GROK_API_BASE_URL)
|
|
76
78
|
self._cached_models: Optional[List[Dict[str, str]]] = None
|
|
@@ -101,7 +103,8 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
101
103
|
def _process_and_handle_stream(self,
|
|
102
104
|
response: requests.Response,
|
|
103
105
|
stream: bool,
|
|
104
|
-
streaming_callback: Optional[Callable[[str, MSG_TYPE], None]]
|
|
106
|
+
streaming_callback: Optional[Callable[[str, MSG_TYPE], None]],
|
|
107
|
+
think: bool = False
|
|
105
108
|
) -> Union[str, dict]:
|
|
106
109
|
"""Helper to process streaming responses from the API."""
|
|
107
110
|
full_response_text = ""
|
|
@@ -119,6 +122,21 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
119
122
|
if chunk['choices']:
|
|
120
123
|
delta = chunk['choices'][0].get('delta', {})
|
|
121
124
|
content = delta.get('content', '')
|
|
125
|
+
# Check for reasoning content (DeepSeek-style) if Grok adopts it or if proxied
|
|
126
|
+
reasoning = delta.get('reasoning_content', '')
|
|
127
|
+
|
|
128
|
+
if reasoning:
|
|
129
|
+
# If thinking is requested and we get reasoning tokens
|
|
130
|
+
if think:
|
|
131
|
+
if streaming_callback:
|
|
132
|
+
# We just stream the reasoning as is, user UI typically handles tagging or we could inject <think>
|
|
133
|
+
# Here we assume just passing the text is safer unless we track state
|
|
134
|
+
streaming_callback(reasoning, MSG_TYPE.MSG_TYPE_CHUNK)
|
|
135
|
+
# We don't append reasoning to full_response_text usually if it's separate,
|
|
136
|
+
# unless we want to return it in the final string wrapped.
|
|
137
|
+
# Let's wrap it for the final return string.
|
|
138
|
+
full_response_text += f"<think>{reasoning}</think>" # Naive wrapping for stream accumulation
|
|
139
|
+
|
|
122
140
|
if content:
|
|
123
141
|
full_response_text += content
|
|
124
142
|
if stream and streaming_callback:
|
|
@@ -154,6 +172,9 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
154
172
|
n_threads: Optional[int] = None, # Not applicable
|
|
155
173
|
ctx_size: int | None = None, # Determined by model
|
|
156
174
|
streaming_callback: Optional[Callable[[str, MSG_TYPE], None]] = None,
|
|
175
|
+
think: Optional[bool] = False,
|
|
176
|
+
reasoning_effort: Optional[str] = "low", # low, medium, high
|
|
177
|
+
reasoning_summary: Optional[bool] = False, # auto
|
|
157
178
|
**kwargs
|
|
158
179
|
) -> Union[str, dict]:
|
|
159
180
|
"""
|
|
@@ -181,7 +202,9 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
181
202
|
b64_data = base64.b64encode(image_file.read()).decode('utf-8')
|
|
182
203
|
else: # Assume it's a base64 string
|
|
183
204
|
b64_data = image_data
|
|
184
|
-
|
|
205
|
+
if b64_data.startswith("data:image"):
|
|
206
|
+
b64_data = b64_data.split(",")[1]
|
|
207
|
+
media_type = "image/png" # Default assumption
|
|
185
208
|
|
|
186
209
|
user_content.append({
|
|
187
210
|
"type": "image_url",
|
|
@@ -214,7 +237,7 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
214
237
|
)
|
|
215
238
|
response.raise_for_status()
|
|
216
239
|
|
|
217
|
-
return self._process_and_handle_stream(response, stream, streaming_callback)
|
|
240
|
+
return self._process_and_handle_stream(response, stream, streaming_callback, think=think)
|
|
218
241
|
|
|
219
242
|
except requests.exceptions.RequestException as ex:
|
|
220
243
|
error_message = f"Grok API request failed: {str(ex)}"
|
|
@@ -238,6 +261,9 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
238
261
|
temperature: float = 0.7,
|
|
239
262
|
top_p: float = 0.9,
|
|
240
263
|
streaming_callback: Optional[Callable[[str, MSG_TYPE], None]] = None,
|
|
264
|
+
think: Optional[bool] = False,
|
|
265
|
+
reasoning_effort: Optional[str] = "low", # low, medium, high
|
|
266
|
+
reasoning_summary: Optional[bool] = False, # auto
|
|
241
267
|
**kwargs
|
|
242
268
|
) -> Union[str, dict]:
|
|
243
269
|
"""
|
|
@@ -273,6 +299,18 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
273
299
|
})
|
|
274
300
|
except Exception as e:
|
|
275
301
|
ASCIIColors.warning(f"Could not load image {file_path}: {e}")
|
|
302
|
+
else:
|
|
303
|
+
# Attempt to handle base64
|
|
304
|
+
try:
|
|
305
|
+
b64_data = file_path
|
|
306
|
+
if b64_data.startswith("data:image"):
|
|
307
|
+
b64_data = b64_data.split(",")[1]
|
|
308
|
+
content_parts.append({
|
|
309
|
+
"type": "image_url",
|
|
310
|
+
"image_url": {"url": f"data:image/png;base64,{b64_data}"}
|
|
311
|
+
})
|
|
312
|
+
except:
|
|
313
|
+
pass
|
|
276
314
|
|
|
277
315
|
# Grok API expects content to be a string for assistant, or list for user.
|
|
278
316
|
if role == 'user':
|
|
@@ -303,7 +341,7 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
303
341
|
)
|
|
304
342
|
response.raise_for_status()
|
|
305
343
|
|
|
306
|
-
return self._process_and_handle_stream(response, stream, streaming_callback)
|
|
344
|
+
return self._process_and_handle_stream(response, stream, streaming_callback, think=think)
|
|
307
345
|
|
|
308
346
|
except requests.exceptions.RequestException as ex:
|
|
309
347
|
error_message = f"Grok API request failed: {str(ex)}"
|
|
@@ -362,10 +400,10 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
362
400
|
"host_address": self.base_url,
|
|
363
401
|
"model_name": self.model_name,
|
|
364
402
|
"supports_structured_output": False,
|
|
365
|
-
"supports_vision": "vision" in self.model_name or "grok-1.5"
|
|
403
|
+
"supports_vision": "vision" in self.model_name or "grok-1.5" in self.model_name or "grok-2" in self.model_name,
|
|
366
404
|
}
|
|
367
405
|
|
|
368
|
-
def
|
|
406
|
+
def list_models(self) -> List[Dict[str, str]]:
|
|
369
407
|
"""
|
|
370
408
|
Lists available models from the xAI API.
|
|
371
409
|
Caches the result to avoid repeated API calls.
|
|
@@ -380,7 +418,6 @@ class GrokBinding(LollmsLLMBinding):
|
|
|
380
418
|
return self._cached_models
|
|
381
419
|
|
|
382
420
|
try:
|
|
383
|
-
ASCIIColors.info("Fetching available models from xAI API...")
|
|
384
421
|
response = requests.get(f"{self.base_url}/models", headers=self.headers, timeout=15)
|
|
385
422
|
response.raise_for_status()
|
|
386
423
|
|
|
@@ -433,8 +470,8 @@ if __name__ == '__main__':
|
|
|
433
470
|
ASCIIColors.yellow("--- Testing GrokBinding ---")
|
|
434
471
|
|
|
435
472
|
# --- Configuration ---
|
|
436
|
-
test_model_name = "grok-
|
|
437
|
-
test_vision_model_name = "grok-
|
|
473
|
+
test_model_name = "grok-2-latest"
|
|
474
|
+
test_vision_model_name = "grok-2-vision-latest"
|
|
438
475
|
|
|
439
476
|
try:
|
|
440
477
|
# --- Initialization ---
|
|
@@ -444,7 +481,7 @@ if __name__ == '__main__':
|
|
|
444
481
|
|
|
445
482
|
# --- List Models ---
|
|
446
483
|
ASCIIColors.cyan("\n--- Listing Models (dynamic) ---")
|
|
447
|
-
models = binding.
|
|
484
|
+
models = binding.list_models()
|
|
448
485
|
if models:
|
|
449
486
|
ASCIIColors.green(f"Found {len(models)} models.")
|
|
450
487
|
for m in models:
|
|
@@ -462,7 +499,7 @@ if __name__ == '__main__':
|
|
|
462
499
|
ASCIIColors.cyan("\n--- Text Generation (Non-Streaming) ---")
|
|
463
500
|
prompt_text = "Explain who Elon Musk is in one sentence."
|
|
464
501
|
ASCIIColors.info(f"Prompt: {prompt_text}")
|
|
465
|
-
generated_text = binding.generate_text(prompt_text, n_predict=100, stream=False, system_prompt="Be very concise.")
|
|
502
|
+
generated_text = binding.generate_text(prompt_text, n_predict=100, stream=False, system_prompt="Be very concise.", think=True)
|
|
466
503
|
if isinstance(generated_text, str):
|
|
467
504
|
ASCIIColors.green(f"Generated text:\n{generated_text}")
|
|
468
505
|
else:
|
|
@@ -179,7 +179,7 @@ class GroqBinding(LollmsLLMBinding):
|
|
|
179
179
|
"supports_vision": False, # Groq models do not currently support vision
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
def
|
|
182
|
+
def list_models(self) -> List[Dict[str, str]]:
|
|
183
183
|
"""Lists available models from the Groq service."""
|
|
184
184
|
if not self.client:
|
|
185
185
|
ASCIIColors.error("Groq client not initialized. Cannot list models.")
|
|
@@ -229,7 +229,7 @@ if __name__ == '__main__':
|
|
|
229
229
|
|
|
230
230
|
# --- List Models ---
|
|
231
231
|
ASCIIColors.cyan("\n--- Listing Models ---")
|
|
232
|
-
models = binding.
|
|
232
|
+
models = binding.list_models()
|
|
233
233
|
if models:
|
|
234
234
|
ASCIIColors.green(f"Found {len(models)} models on Groq. Available models:")
|
|
235
235
|
for m in models:
|
|
@@ -196,7 +196,7 @@ class HuggingFaceInferenceAPIBinding(LollmsLLMBinding):
|
|
|
196
196
|
"supports_vision": False, # Vision models use a different API call
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
def
|
|
199
|
+
def list_models(self) -> List[Dict[str, str]]:
|
|
200
200
|
"""Lists text-generation models from the Hugging Face Hub."""
|
|
201
201
|
if not self.hf_api:
|
|
202
202
|
ASCIIColors.error("HF API client not initialized. Cannot list models.")
|
|
@@ -252,7 +252,7 @@ if __name__ == '__main__':
|
|
|
252
252
|
|
|
253
253
|
# --- List Models ---
|
|
254
254
|
ASCIIColors.cyan("\n--- Listing Models ---")
|
|
255
|
-
models = binding.
|
|
255
|
+
models = binding.list_models()
|
|
256
256
|
if models:
|
|
257
257
|
ASCIIColors.green(f"Successfully fetched {len(models)} text-generation models.")
|
|
258
258
|
ASCIIColors.info("Top 5 most downloaded models:")
|
|
@@ -185,7 +185,7 @@ class LiteLLMBinding(LollmsLLMBinding):
|
|
|
185
185
|
ASCIIColors.error(f"--- [LiteLLM Binding] Fallback method failed: {e}")
|
|
186
186
|
return entries
|
|
187
187
|
|
|
188
|
-
def
|
|
188
|
+
def list_models(self) -> List[Dict]:
|
|
189
189
|
url = f'{self.host_address}/model/info'
|
|
190
190
|
headers = {'Authorization': f'Bearer {self.service_key}'}
|
|
191
191
|
entries = []
|