lollms-client 0.33.0__py3-none-any.whl → 1.1.0__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.

Files changed (74) hide show
  1. lollms_client/__init__.py +1 -1
  2. lollms_client/llm_bindings/azure_openai/__init__.py +6 -10
  3. lollms_client/llm_bindings/claude/__init__.py +4 -7
  4. lollms_client/llm_bindings/gemini/__init__.py +3 -7
  5. lollms_client/llm_bindings/grok/__init__.py +3 -7
  6. lollms_client/llm_bindings/groq/__init__.py +4 -6
  7. lollms_client/llm_bindings/hugging_face_inference_api/__init__.py +4 -6
  8. lollms_client/llm_bindings/litellm/__init__.py +15 -6
  9. lollms_client/llm_bindings/llamacpp/__init__.py +27 -9
  10. lollms_client/llm_bindings/lollms/__init__.py +24 -14
  11. lollms_client/llm_bindings/lollms_webui/__init__.py +6 -12
  12. lollms_client/llm_bindings/mistral/__init__.py +3 -5
  13. lollms_client/llm_bindings/ollama/__init__.py +6 -11
  14. lollms_client/llm_bindings/open_router/__init__.py +4 -6
  15. lollms_client/llm_bindings/openai/__init__.py +7 -14
  16. lollms_client/llm_bindings/openllm/__init__.py +12 -12
  17. lollms_client/llm_bindings/pythonllamacpp/__init__.py +1 -1
  18. lollms_client/llm_bindings/tensor_rt/__init__.py +8 -13
  19. lollms_client/llm_bindings/transformers/__init__.py +14 -6
  20. lollms_client/llm_bindings/vllm/__init__.py +16 -12
  21. lollms_client/lollms_core.py +303 -490
  22. lollms_client/lollms_discussion.py +431 -78
  23. lollms_client/lollms_llm_binding.py +192 -381
  24. lollms_client/lollms_mcp_binding.py +33 -2
  25. lollms_client/lollms_tti_binding.py +107 -2
  26. lollms_client/mcp_bindings/local_mcp/__init__.py +3 -2
  27. lollms_client/mcp_bindings/remote_mcp/__init__.py +6 -5
  28. lollms_client/mcp_bindings/standard_mcp/__init__.py +3 -5
  29. lollms_client/stt_bindings/lollms/__init__.py +6 -8
  30. lollms_client/stt_bindings/whisper/__init__.py +2 -4
  31. lollms_client/stt_bindings/whispercpp/__init__.py +15 -16
  32. lollms_client/tti_bindings/dalle/__init__.py +50 -29
  33. lollms_client/tti_bindings/diffusers/__init__.py +227 -439
  34. lollms_client/tti_bindings/gemini/__init__.py +320 -0
  35. lollms_client/tti_bindings/lollms/__init__.py +8 -9
  36. lollms_client-1.1.0.dist-info/METADATA +1214 -0
  37. lollms_client-1.1.0.dist-info/RECORD +69 -0
  38. {lollms_client-0.33.0.dist-info → lollms_client-1.1.0.dist-info}/top_level.txt +0 -2
  39. examples/article_summary/article_summary.py +0 -58
  40. examples/console_discussion/console_app.py +0 -266
  41. examples/console_discussion.py +0 -448
  42. examples/deep_analyze/deep_analyse.py +0 -30
  43. examples/deep_analyze/deep_analyze_multiple_files.py +0 -32
  44. examples/function_calling_with_local_custom_mcp.py +0 -250
  45. examples/generate_a_benchmark_for_safe_store.py +0 -89
  46. examples/generate_and_speak/generate_and_speak.py +0 -251
  47. examples/generate_game_sfx/generate_game_fx.py +0 -240
  48. examples/generate_text_with_multihop_rag_example.py +0 -210
  49. examples/gradio_chat_app.py +0 -228
  50. examples/gradio_lollms_chat.py +0 -259
  51. examples/internet_search_with_rag.py +0 -226
  52. examples/lollms_chat/calculator.py +0 -59
  53. examples/lollms_chat/derivative.py +0 -48
  54. examples/lollms_chat/test_openai_compatible_with_lollms_chat.py +0 -12
  55. examples/lollms_discussions_test.py +0 -155
  56. examples/mcp_examples/external_mcp.py +0 -267
  57. examples/mcp_examples/local_mcp.py +0 -171
  58. examples/mcp_examples/openai_mcp.py +0 -203
  59. examples/mcp_examples/run_remote_mcp_example_v2.py +0 -290
  60. examples/mcp_examples/run_standard_mcp_example.py +0 -204
  61. examples/simple_text_gen_test.py +0 -173
  62. examples/simple_text_gen_with_image_test.py +0 -178
  63. examples/test_local_models/local_chat.py +0 -9
  64. examples/text_2_audio.py +0 -77
  65. examples/text_2_image.py +0 -144
  66. examples/text_2_image_diffusers.py +0 -274
  67. examples/text_and_image_2_audio.py +0 -59
  68. examples/text_gen.py +0 -30
  69. examples/text_gen_system_prompt.py +0 -29
  70. lollms_client-0.33.0.dist-info/METADATA +0 -854
  71. lollms_client-0.33.0.dist-info/RECORD +0 -101
  72. test/test_lollms_discussion.py +0 -368
  73. {lollms_client-0.33.0.dist-info → lollms_client-1.1.0.dist-info}/WHEEL +0 -0
  74. {lollms_client-0.33.0.dist-info → lollms_client-1.1.0.dist-info}/licenses/LICENSE +0 -0
@@ -12,11 +12,42 @@ from lollms_client.lollms_types import MSG_TYPE
12
12
  from lollms_client.lollms_discussion import LollmsDiscussion
13
13
  from lollms_client.lollms_utilities import ImageTokenizer
14
14
  import re
15
+ import yaml
16
+
17
+ from pathlib import Path
18
+ import json
19
+
20
+ def load_known_contexts():
21
+ """
22
+ Loads the known_contexts data from a JSON file.
23
+
24
+ Args:
25
+ file_path (str): The path to the JSON file.
26
+
27
+ Returns:
28
+ dict: A dictionary containing the known_contexts data, or None if an error occurs.
29
+ """
30
+ try:
31
+ file_path = Path(__file__).parent / "assets" / "models_ctx_sizes.json"
32
+ with open(file_path, "r") as f:
33
+ known_contexts = json.load(f)
34
+ return known_contexts
35
+ except FileNotFoundError:
36
+ print(f"Error: File not found at {file_path}")
37
+ return None
38
+ except json.JSONDecodeError:
39
+ print(f"Error: Could not decode JSON from {file_path}")
40
+ return None
41
+ except Exception as e:
42
+ print(f"An unexpected error occurred: {e}")
43
+ return None
44
+
15
45
  class LollmsLLMBinding(ABC):
16
46
  """Abstract base class for all LOLLMS LLM bindings"""
17
47
 
18
48
  def __init__(self,
19
- binding_name: Optional[str] ="unknown"
49
+ binding_name: Optional[str] ="unknown",
50
+ **kwargs
20
51
  ):
21
52
  """
22
53
  Initialize the LollmsLLMBinding base class.
@@ -26,6 +57,18 @@ class LollmsLLMBinding(ABC):
26
57
  """
27
58
  self.binding_name=binding_name
28
59
  self.model_name = None #Must be set by the instance
60
+ self.default_ctx_size = kwargs.get("ctx_size")
61
+ self.default_n_predict = kwargs.get("n_predict")
62
+ self.default_stream = kwargs.get("stream")
63
+ self.default_temperature = kwargs.get("temperature")
64
+ self.default_top_k = kwargs.get("top_k")
65
+ self.default_top_p = kwargs.get("top_p")
66
+ self.default_repeat_penalty = kwargs.get("repeat_penalty")
67
+ self.default_repeat_last_n = kwargs.get("repeat_last_n")
68
+ self.default_seed = kwargs.get("seed")
69
+ self.default_n_threads = kwargs.get("n_threads")
70
+ self.default_streaming_callback = kwargs.get("streaming_callback")
71
+
29
72
 
30
73
  @abstractmethod
31
74
  def generate_text(self,
@@ -168,378 +211,7 @@ class LollmsLLMBinding(ABC):
168
211
 
169
212
  # Hardcoded context sizes for popular models. More specific names (e.g., 'llama3.1')
170
213
  # should appear, as they will be checked first due to the sorting logic below.
171
- known_contexts = {
172
- 'agentica-org/deepcoder-14b-preview': 8192,
173
- 'agentica-org/deepcoder-14b-preview:free': 8192,
174
- 'ai21/jamba-large-1.7': 256000,
175
- 'ai21/jamba-mini-1.7': 256000,
176
- 'aion-labs/aion-1.0': 8192,
177
- 'aion-labs/aion-1.0-mini': 8192,
178
- 'aion-labs/aion-rp-llama-3.1-8b': 131072,
179
- 'alfredpros/codellama-7b-instruct-solidity': 16384,
180
- 'alpindale/goliath-120b': 4096,
181
- 'amazon/nova-lite-v1': 32768,
182
- 'amazon/nova-micro-v1': 32768,
183
- 'amazon/nova-pro-v1': 32768,
184
- 'anthracite-org/magnum-v2-72b': 131072,
185
- 'anthracite-org/magnum-v4-72b': 131072,
186
- 'anthropic/claude-3-haiku': 200000,
187
- 'anthropic/claude-3-haiku:beta': 200000,
188
- 'anthropic/claude-3-opus': 200000,
189
- 'anthropic/claude-3-opus:beta': 200000,
190
- 'anthropic/claude-3.5-haiku': 200000,
191
- 'anthropic/claude-3.5-haiku-20241022': 200000,
192
- 'anthropic/claude-3.5-haiku:beta': 200000,
193
- 'anthropic/claude-3.5-sonnet': 200000,
194
- 'anthropic/claude-3.5-sonnet-20240620': 200000,
195
- 'anthropic/claude-3.5-sonnet-20240620:beta': 200000,
196
- 'anthropic/claude-3.5-sonnet:beta': 200000,
197
- 'anthropic/claude-3.7-sonnet': 200000,
198
- 'anthropic/claude-3.7-sonnet:beta': 200000,
199
- 'anthropic/claude-3.7-sonnet:thinking': 200000,
200
- 'anthropic/claude-opus-4': 200000,
201
- 'anthropic/claude-opus-4.1': 200000,
202
- 'anthropic/claude-sonnet-4': 200000,
203
- 'arcee-ai/coder-large': 32768,
204
- 'arcee-ai/maestro-reasoning': 32768,
205
- 'arcee-ai/spotlight': 32768,
206
- 'arcee-ai/virtuoso-large': 32768,
207
- 'arliai/qwq-32b-arliai-rpr-v1': 8192,
208
- 'arliai/qwq-32b-arliai-rpr-v1:free': 8192,
209
- 'baidu/ernie-4.5-300b-a47b': 128000,
210
- 'bytedance/ui-tars-1.5-7b': 8192,
211
- 'cognitivecomputations/dolphin-mistral-24b-venice-edition:free': 32768,
212
- 'cognitivecomputations/dolphin-mixtral-8x22b': 65536,
213
- 'cognitivecomputations/dolphin3.0-mistral-24b': 32768,
214
- 'cognitivecomputations/dolphin3.0-mistral-24b:free': 32768,
215
- 'cognitivecomputations/dolphin3.0-r1-mistral-24b': 32768,
216
- 'cognitivecomputations/dolphin3.0-r1-mistral-24b:free': 32768,
217
- 'cohere/command': 8192,
218
- 'cohere/command-a': 8192,
219
- 'cohere/command-r': 128000,
220
- 'cohere/command-r-03-2024': 128000,
221
- 'cohere/command-r-08-2024': 128000,
222
- 'cohere/command-r-plus': 128000,
223
- 'cohere/command-r-plus-04-2024': 128000,
224
- 'cohere/command-r-plus-08-2024': 128000,
225
- 'cohere/command-r7b-12-2024': 128000,
226
- 'deepseek/deepseek-chat': 32768,
227
- 'deepseek/deepseek-chat-v3-0324': 32768,
228
- 'deepseek/deepseek-chat-v3-0324:free': 32768,
229
- 'deepseek/deepseek-prover-v2': 131072,
230
- 'deepseek/deepseek-r1': 32768,
231
- 'deepseek/deepseek-r1-0528': 32768,
232
- 'deepseek/deepseek-r1-0528-qwen3-8b': 32768,
233
- 'deepseek/deepseek-r1-0528-qwen3-8b:free': 32768,
234
- 'deepseek/deepseek-r1-0528:free': 32768,
235
- 'deepseek/deepseek-r1-distill-llama-70b': 131072,
236
- 'deepseek/deepseek-r1-distill-llama-70b:free': 131072,
237
- 'deepseek/deepseek-r1-distill-llama-8b': 131072,
238
- 'deepseek/deepseek-r1-distill-qwen-1.5b': 32768,
239
- 'deepseek/deepseek-r1-distill-qwen-14b': 32768,
240
- 'deepseek/deepseek-r1-distill-qwen-14b:free': 32768,
241
- 'deepseek/deepseek-r1-distill-qwen-32b': 32768,
242
- 'deepseek/deepseek-r1-distill-qwen-7b': 32768,
243
- 'deepseek/deepseek-r1:free': 32768,
244
- 'deepseek/deepseek-v3-base': 32768,
245
- 'eleutherai/llemma_7b': 8192,
246
- 'featherless/qwerky-72b:free': 8192,
247
- 'google/gemini-2.0-flash-001': 1000000,
248
- 'google/gemini-2.0-flash-exp:free': 1000000,
249
- 'google/gemini-2.0-flash-lite-001': 1000000,
250
- 'google/gemini-2.5-flash': 1000000,
251
- 'google/gemini-2.5-flash-lite': 1000000,
252
- 'google/gemini-2.5-flash-lite-preview-06-17': 1000000,
253
- 'google/gemini-2.5-pro': 2000000,
254
- 'google/gemini-2.5-pro-exp-03-25': 2000000,
255
- 'google/gemini-2.5-pro-preview': 2000000,
256
- 'google/gemini-2.5-pro-preview-05-06': 2000000,
257
- 'google/gemini-flash-1.5': 1000000,
258
- 'google/gemini-flash-1.5-8b': 1000000,
259
- 'google/gemini-pro-1.5': 2000000,
260
- 'google/gemma-2-27b-it': 8192,
261
- 'google/gemma-2-9b-it': 8192,
262
- 'google/gemma-2-9b-it:free': 8192,
263
- 'google/gemma-3-12b-it': 131072,
264
- 'google/gemma-3-12b-it:free': 131072,
265
- 'google/gemma-3-27b-it': 131072,
266
- 'google/gemma-3-27b-it:free': 131072,
267
- 'google/gemma-3-4b-it': 131072,
268
- 'google/gemma-3-4b-it:free': 131072,
269
- 'google/gemma-3n-e2b-it:free': 131072,
270
- 'google/gemma-3n-e4b-it': 131072,
271
- 'google/gemma-3n-e4b-it:free': 131072,
272
- 'gryphe/mythomax-l2-13b': 4096,
273
- 'inception/mercury': 32768,
274
- 'inception/mercury-coder': 32768,
275
- 'infermatic/mn-inferor-12b': 8192,
276
- 'inflection/inflection-3-pi': 128000,
277
- 'inflection/inflection-3-productivity': 128000,
278
- 'liquid/lfm-3b': 8192,
279
- 'liquid/lfm-40b': 8192,
280
- 'liquid/lfm-7b': 8192,
281
- 'mancer/weaver': 8192,
282
- 'meta-llama/llama-3-70b-instruct': 8192,
283
- 'meta-llama/llama-3-8b-instruct': 8192,
284
- 'meta-llama/llama-3.1-405b': 131072,
285
- 'meta-llama/llama-3.1-405b-instruct': 131072,
286
- 'meta-llama/llama-3.1-405b-instruct:free': 131072,
287
- 'meta-llama/llama-3.1-70b-instruct': 131072,
288
- 'meta-llama/llama-3.1-8b-instruct': 131072,
289
- 'meta-llama/llama-3.2-11b-vision-instruct': 131072,
290
- 'meta-llama/llama-3.2-11b-vision-instruct:free': 131072,
291
- 'meta-llama/llama-3.2-1b-instruct': 131072,
292
- 'meta-llama/llama-3.2-3b-instruct': 131072,
293
- 'meta-llama/llama-3.2-3b-instruct:free': 131072,
294
- 'meta-llama/llama-3.2-90b-vision-instruct': 131072,
295
- 'meta-llama/llama-3.3-70b-instruct': 131072,
296
- 'meta-llama/llama-3.3-70b-instruct:free': 131072,
297
- 'meta-llama/llama-4-maverick': 131072,
298
- 'meta-llama/llama-4-scout': 131072,
299
- 'meta-llama/llama-guard-2-8b': 8192,
300
- 'meta-llama/llama-guard-3-8b': 131072,
301
- 'meta-llama/llama-guard-4-12b': 131072,
302
- 'microsoft/mai-ds-r1': 32768,
303
- 'microsoft/mai-ds-r1:free': 32768,
304
- 'microsoft/phi-3-medium-128k-instruct': 131072,
305
- 'microsoft/phi-3-mini-128k-instruct': 131072,
306
- 'microsoft/phi-3.5-mini-128k-instruct': 131072,
307
- 'microsoft/phi-4': 131072,
308
- 'microsoft/phi-4-multimodal-instruct': 131072,
309
- 'microsoft/phi-4-reasoning-plus': 131072,
310
- 'microsoft/wizardlm-2-8x22b': 65536,
311
- 'minimax/minimax-01': 200000,
312
- 'minimax/minimax-m1': 200000,
313
- 'mistralai/codestral-2501': 32768,
314
- 'mistralai/codestral-2508': 32768,
315
- 'mistralai/devstral-medium': 32768,
316
- 'mistralai/devstral-small': 32768,
317
- 'mistralai/devstral-small-2505': 32768,
318
- 'mistralai/devstral-small-2505:free': 32768,
319
- 'mistralai/magistral-medium-2506': 32768,
320
- 'mistralai/magistral-medium-2506:thinking': 32768,
321
- 'mistralai/magistral-small-2506': 32768,
322
- 'mistralai/ministral-3b': 32768,
323
- 'mistralai/ministral-8b': 32768,
324
- 'mistralai/mistral-7b-instruct': 32768,
325
- 'mistralai/mistral-7b-instruct-v0.1': 8192,
326
- 'mistralai/mistral-7b-instruct-v0.2': 32768,
327
- 'mistralai/mistral-7b-instruct-v0.3': 32768,
328
- 'mistralai/mistral-7b-instruct:free': 32768,
329
- 'mistralai/mistral-large': 32768,
330
- 'mistralai/mistral-large-2407': 128000,
331
- 'mistralai/mistral-large-2411': 128000,
332
- 'mistralai/mistral-medium-3': 32768,
333
- 'mistralai/mistral-nemo': 128000,
334
- 'mistralai/mistral-nemo:free': 128000,
335
- 'mistralai/mistral-saba': 32768,
336
- 'mistralai/mistral-small': 32768,
337
- 'mistralai/mistral-small-24b-instruct-2501': 32768,
338
- 'mistralai/mistral-small-24b-instruct-2501:free': 32768,
339
- 'mistralai/mistral-small-3.1-24b-instruct': 32768,
340
- 'mistralai/mistral-small-3.1-24b-instruct:free': 32768,
341
- 'mistralai/mistral-small-3.2-24b-instruct': 32768,
342
- 'mistralai/mistral-small-3.2-24b-instruct:free': 32768,
343
- 'mistralai/mistral-tiny': 32768,
344
- 'mistralai/mixtral-8x22b-instruct': 65536,
345
- 'mistralai/mixtral-8x7b-instruct': 32768,
346
- 'mistralai/pixtral-12b': 128000,
347
- 'mistralai/pixtral-large-2411': 128000,
348
- 'moonshotai/kimi-dev-72b:free': 200000,
349
- 'moonshotai/kimi-k2': 200000,
350
- 'moonshotai/kimi-k2:free': 200000,
351
- 'moonshotai/kimi-vl-a3b-thinking': 200000,
352
- 'moonshotai/kimi-vl-a3b-thinking:free': 200000,
353
- 'morph/morph-v3-fast': 8192,
354
- 'morph/morph-v3-large': 8192,
355
- 'neversleep/llama-3-lumimaid-70b': 8192,
356
- 'neversleep/llama-3.1-lumimaid-8b': 131072,
357
- 'neversleep/noromaid-20b': 32768,
358
- 'nousresearch/deephermes-3-llama-3-8b-preview:free': 8192,
359
- 'nousresearch/deephermes-3-mistral-24b-preview': 32768,
360
- 'nousresearch/hermes-2-pro-llama-3-8b': 8192,
361
- 'nousresearch/hermes-3-llama-3.1-405b': 131072,
362
- 'nousresearch/hermes-3-llama-3.1-70b': 131072,
363
- 'nousresearch/nous-hermes-2-mixtral-8x7b-dpo': 32768,
364
- 'nvidia/llama-3.1-nemotron-70b-instruct': 131072,
365
- 'nvidia/llama-3.1-nemotron-ultra-253b-v1': 131072,
366
- 'nvidia/llama-3.1-nemotron-ultra-253b-v1:free': 131072,
367
- 'nvidia/llama-3.3-nemotron-super-49b-v1': 131072,
368
- 'openai/chatgpt-4o-latest': 128000,
369
- 'openai/codex-mini': 2048,
370
- 'openai/gpt-3.5-turbo': 4096,
371
- 'openai/gpt-3.5-turbo-0613': 4096,
372
- 'openai/gpt-3.5-turbo-16k': 16384,
373
- 'openai/gpt-3.5-turbo-instruct': 4096,
374
- 'openai/gpt-4': 8192,
375
- 'openai/gpt-4-0314': 8192,
376
- 'openai/gpt-4-1106-preview': 128000,
377
- 'openai/gpt-4-turbo': 128000,
378
- 'openai/gpt-4-turbo-preview': 128000,
379
- 'openai/gpt-4.1': 128000,
380
- 'openai/gpt-4.1-mini': 128000,
381
- 'openai/gpt-4.1-nano': 128000,
382
- 'openai/gpt-4o': 128000,
383
- 'openai/gpt-4o-2024-05-13': 128000,
384
- 'openai/gpt-4o-2024-08-06': 128000,
385
- 'openai/gpt-4o-2024-11-20': 128000,
386
- 'openai/gpt-4o-mini': 128000,
387
- 'openai/gpt-4o-mini-2024-07-18': 128000,
388
- 'openai/gpt-4o-mini-search-preview': 128000,
389
- 'openai/gpt-4o-search-preview': 128000,
390
- 'openai/gpt-4o:extended': 128000,
391
- 'openai/gpt-5': 200000,
392
- 'openai/gpt-5-chat': 200000,
393
- 'openai/gpt-5-mini': 200000,
394
- 'openai/gpt-5-nano': 200000,
395
- 'openai/gpt-oss-120b': 128000,
396
- 'openai/gpt-oss-20b': 128000,
397
- 'openai/gpt-oss-20b:free': 128000,
398
- 'openai/o1': 128000,
399
- 'openai/o1-mini': 128000,
400
- 'openai/o1-mini-2024-09-12': 128000,
401
- 'openai/o1-pro': 128000,
402
- 'openai/o3': 200000,
403
- 'openai/o3-mini': 200000,
404
- 'openai/o3-mini-high': 200000,
405
- 'openai/o3-pro': 200000,
406
- 'openai/o4-mini': 128000,
407
- 'openai/o4-mini-high': 128000,
408
- 'opengvlab/internvl3-14b': 8192,
409
- 'openrouter/auto': 8192,
410
- 'perplexity/r1-1776': 32768,
411
- 'perplexity/sonar': 32768,
412
- 'perplexity/sonar-deep-research': 32768,
413
- 'perplexity/sonar-pro': 32768,
414
- 'perplexity/sonar-reasoning': 32768,
415
- 'perplexity/sonar-reasoning-pro': 32768,
416
- 'pygmalionai/mythalion-13b': 4096,
417
- 'qwen/qwen-2-72b-instruct': 32768,
418
- 'qwen/qwen-2.5-72b-instruct': 131072,
419
- 'qwen/qwen-2.5-72b-instruct:free': 131072,
420
- 'qwen/qwen-2.5-7b-instruct': 131072,
421
- 'qwen/qwen-2.5-coder-32b-instruct': 131072,
422
- 'qwen/qwen-2.5-coder-32b-instruct:free': 131072,
423
- 'qwen/qwen-2.5-vl-7b-instruct': 131072,
424
- 'qwen/qwen-max': 32768,
425
- 'qwen/qwen-plus': 32768,
426
- 'qwen/qwen-turbo': 8192,
427
- 'qwen/qwen-vl-max': 32768,
428
- 'qwen/qwen-vl-plus': 32768,
429
- 'qwen/qwen2.5-vl-32b-instruct': 131072,
430
- 'qwen/qwen2.5-vl-32b-instruct:free': 131072,
431
- 'qwen/qwen2.5-vl-72b-instruct': 131072,
432
- 'qwen/qwen2.5-vl-72b-instruct:free': 131072,
433
- 'qwen/qwen3-14b': 32768,
434
- 'qwen/qwen3-14b:free': 32768,
435
- 'qwen/qwen3-235b-a22b': 32768,
436
- 'qwen/qwen3-235b-a22b-2507': 32768,
437
- 'qwen/qwen3-235b-a22b-thinking-2507': 32768,
438
- 'qwen/qwen3-235b-a22b:free': 32768,
439
- 'qwen/qwen3-30b-a3b': 32768,
440
- 'qwen/qwen3-30b-a3b-instruct-2507': 32768,
441
- 'qwen/qwen3-30b-a3b:free': 32768,
442
- 'qwen/qwen3-32b': 32768,
443
- 'qwen/qwen3-4b:free': 32768,
444
- 'qwen/qwen3-8b': 32768,
445
- 'qwen/qwen3-8b:free': 32768,
446
- 'qwen/qwen3-coder': 32768,
447
- 'qwen/qwen3-coder:free': 32768,
448
- 'qwen/qwq-32b': 32768,
449
- 'qwen/qwq-32b-preview': 32768,
450
- 'qwen/qwq-32b:free': 32768,
451
- 'raifle/sorcererlm-8x22b': 65536,
452
- 'rekaai/reka-flash-3:free': 128000,
453
- 'sao10k/l3-euryale-70b': 8192,
454
- 'sao10k/l3-lunaris-8b': 8192,
455
- 'sao10k/l3.1-euryale-70b': 131072,
456
- 'sao10k/l3.3-euryale-70b': 131072,
457
- 'sarvamai/sarvam-m:free': 8192,
458
- 'scb10x/llama3.1-typhoon2-70b-instruct': 131072,
459
- 'shisa-ai/shisa-v2-llama3.3-70b': 131072,
460
- 'shisa-ai/shisa-v2-llama3.3-70b:free': 131072,
461
- 'sophosympatheia/midnight-rose-70b': 4096,
462
- 'switchpoint/router': 8192,
463
- 'tencent/hunyuan-a13b-instruct': 8192,
464
- 'tencent/hunyuan-a13b-instruct:free': 8192,
465
- 'thedrummer/anubis-70b-v1.1': 8192,
466
- 'thedrummer/anubis-pro-105b-v1': 8192,
467
- 'thedrummer/rocinante-12b': 8192,
468
- 'thedrummer/skyfall-36b-v2': 8192,
469
- 'thedrummer/unslopnemo-12b': 128000,
470
- 'thedrummer/valkyrie-49b-v1': 8192,
471
- 'thudm/glm-4-32b': 2000000,
472
- 'thudm/glm-4.1v-9b-thinking': 2000000,
473
- 'thudm/glm-z1-32b:free': 2000000,
474
- 'tngtech/deepseek-r1t-chimera': 32768,
475
- 'tngtech/deepseek-r1t-chimera:free': 32768,
476
- 'tngtech/deepseek-r1t2-chimera:free': 32768,
477
- 'undi95/remm-slerp-l2-13b': 4096,
478
- 'x-ai/grok-2-1212': 128000,
479
- 'x-ai/grok-2-vision-1212': 128000,
480
- 'x-ai/grok-3': 128000,
481
- 'x-ai/grok-3-beta': 128000,
482
- 'x-ai/grok-3-mini': 128000,
483
- 'x-ai/grok-3-mini-beta': 128000,
484
- 'x-ai/grok-4': 128000,
485
- 'x-ai/grok-vision-beta': 128000,
486
- 'z-ai/glm-4-32b': 2000000,
487
- 'z-ai/glm-4.5': 2000000,
488
- 'z-ai/glm-4.5-air': 2000000,
489
- 'z-ai/glm-4.5-air:free': 2000000,
490
- 'llama3.1': 131072, # Llama 3.1 extended context
491
- 'llama3.2': 131072, # Llama 3.2 extended context
492
- 'llama3.3': 131072, # Assuming similar to 3.1/3.2
493
- 'llama3': 8192, # Llama 3 default
494
- 'llama2': 4096, # Llama 2 default
495
- 'mixtral8x22b': 65536, # Mixtral 8x22B default
496
- 'mixtral': 32768, # Mixtral 8x7B default
497
- 'mistral': 32768, # Mistral 7B v0.2+ default
498
- 'gemma3': 131072, # Gemma 3 with 128K context
499
- 'gemma2': 8192, # Gemma 2 default
500
- 'gemma': 8192, # Gemma default
501
- 'phi3': 131072, # Phi-3 variants often use 128K (mini/medium extended)
502
- 'phi2': 2048, # Phi-2 default
503
- 'phi': 2048, # Phi default (older)
504
- 'qwen2.5': 131072, # Qwen2.5 with 128K
505
- 'qwen2': 32768, # Qwen2 default for 7B
506
- 'qwen': 8192, # Qwen default
507
- 'codellama': 16384, # CodeLlama extended
508
- 'codegemma': 8192, # CodeGemma default
509
- 'deepseek-coder-v2': 131072, # DeepSeek-Coder V2 with 128K
510
- 'deepseek-coder': 16384, # DeepSeek-Coder V1 default
511
- 'deepseek-v2': 131072, # DeepSeek-V2 with 128K
512
- 'deepseek-llm': 4096, # DeepSeek-LLM default
513
- 'yi1.5': 32768, # Yi-1.5 with 32K
514
- 'yi': 4096, # Yi base default
515
- 'command-r': 131072, # Command-R with 128K
516
- 'wizardlm2': 32768, # WizardLM2 (Mistral-based)
517
- 'wizardlm': 16384, # WizardLM default
518
- 'zephyr': 65536, # Zephyr beta (Mistral-based extended)
519
- 'vicuna': 2048, # Vicuna default (up to 16K in some variants)
520
- 'falcon': 2048, # Falcon default
521
- 'starcoder': 8192, # StarCoder default
522
- 'stablelm': 4096, # StableLM default
523
- 'orca2': 4096, # Orca 2 default
524
- 'orca': 4096, # Orca default
525
- 'dolphin': 32768, # Dolphin (often Mistral-based)
526
- 'openhermes': 8192, # OpenHermes default
527
- 'gpt-oss': 128000, # GPT-OSS with 128K context
528
- 'gpt-3.5-turbo': 4096, # GPT-3.5 Turbo default
529
- 'gpt-4': 8192, # GPT-4 default
530
- 'grok-2': 128000,
531
- 'grok-2-1212': 128000,
532
- 'grok-2-vision-1212': 128000,
533
- 'grok-3': 128000,
534
- 'grok-3-fast': 128000,
535
- 'grok-3-beta': 128000,
536
- 'grok-3-mini': 128000,
537
- 'grok-3-mini-beta': 128000,
538
- 'grok-3-mini-fast': 128000,
539
- 'grok-4-0709': 128000,
540
- 'grok-4': 128000,
541
- 'grok-vision-beta': 128000,
542
- }
214
+ known_contexts = load_known_contexts()
543
215
 
544
216
  normalized_model_name = model_name.lower().strip()
545
217
 
@@ -708,7 +380,7 @@ class LollmsLLMBinding(ABC):
708
380
  class LollmsLLMBindingManager:
709
381
  """Manages binding discovery and instantiation"""
710
382
 
711
- def __init__(self, llm_bindings_dir: str = "llm_bindings"):
383
+ def __init__(self, llm_bindings_dir: Union[str, Path] = Path(__file__).parent.parent / "llm_bindings"):
712
384
  """
713
385
  Initialize the LollmsLLMBindingManager.
714
386
 
@@ -750,16 +422,155 @@ class LollmsLLMBindingManager:
750
422
  if binding_class:
751
423
  return binding_class(**kwargs)
752
424
  return None
425
+ @staticmethod
426
+ def _get_fallback_description(binding_name: str) -> Dict:
427
+ """
428
+ Generates a default description dictionary for a binding without a description.yaml file.
429
+ """
430
+ return {
431
+ "binding_name": binding_name,
432
+ "title": binding_name.replace("_", " ").title(),
433
+ "author": "Unknown",
434
+ "creation_date": "N/A",
435
+ "last_update_date": "N/A",
436
+ "description": f"A binding for {binding_name}. No description.yaml file was found, so common parameters are shown as a fallback.",
437
+ "input_parameters": [
438
+ {
439
+ "name": "model_name",
440
+ "type": "str",
441
+ "description": "The model name, ID, or filename to be used.",
442
+ "mandatory": False,
443
+ "default": ""
444
+ },
445
+ {
446
+ "name": "host_address",
447
+ "type": "str",
448
+ "description": "The host address of the service (for API-based bindings).",
449
+ "mandatory": False,
450
+ "default": ""
451
+ },
452
+ {
453
+ "name": "models_path",
454
+ "type": "str",
455
+ "description": "The path to the models directory (for local bindings).",
456
+ "mandatory": False,
457
+ "default": ""
458
+ },
459
+ {
460
+ "name": "service_key",
461
+ "type": "str",
462
+ "description": "The API key or service key for authentication (if applicable).",
463
+ "mandatory": False,
464
+ "default": ""
465
+ }
466
+ ]
467
+ }
753
468
 
754
- def get_available_bindings(self) -> list[str]:
469
+ @staticmethod
470
+ def get_bindings_list(llm_bindings_dir: Union[str, Path]) -> List[Dict]:
755
471
  """
756
- Return list of available binding names.
472
+ Lists all available LLM bindings by scanning a directory, loading their
473
+ description.yaml file if present, or providing a default description.
474
+
475
+ Args:
476
+ llm_bindings_dir (Union[str, Path]): The path to the directory containing LLM binding folders.
757
477
 
758
478
  Returns:
759
- list[str]: List of binding names.
479
+ List[Dict]: A list of dictionaries, each describing a binding.
480
+ """
481
+ bindings_dir = Path(llm_bindings_dir)
482
+ if not bindings_dir.is_dir():
483
+ return []
484
+
485
+ bindings_list = []
486
+ for binding_folder in bindings_dir.iterdir():
487
+ if binding_folder.is_dir() and (binding_folder / "__init__.py").exists():
488
+ binding_name = binding_folder.name
489
+ description_file = binding_folder / "description.yaml"
490
+
491
+ binding_info = {}
492
+ if description_file.exists():
493
+ try:
494
+ with open(description_file, 'r', encoding='utf-8') as f:
495
+ binding_info = yaml.safe_load(f)
496
+ binding_info['binding_name'] = binding_name
497
+ except Exception as e:
498
+ print(f"Error loading description.yaml for {binding_name}: {e}")
499
+ binding_info = LollmsLLMBindingManager._get_fallback_description(binding_name)
500
+ else:
501
+ binding_info = LollmsLLMBindingManager._get_fallback_description(binding_name)
502
+
503
+ bindings_list.append(binding_info)
504
+
505
+ return sorted(bindings_list, key=lambda b: b.get('title', b['binding_name']))
506
+
507
+ def get_available_bindings(self) -> List[Dict]:
760
508
  """
761
- return [binding_dir.name for binding_dir in self.llm_bindings_dir.iterdir() if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
509
+ Retrieves a list of all available LLM bindings with their full descriptions.
510
+
511
+ This method scans the configured `llm_bindings_dir`, parsing the `description.yaml`
512
+ file for each valid binding. If a `description.yaml` is missing, a fallback
513
+ description with common parameters is generated. This is the primary method
514
+ for discovering available bindings and their configuration requirements.
762
515
 
763
- def get_available_bindings():
764
- bindings_dir = Path(__file__).parent/"llm_bindings"
765
- return [binding_dir.name for binding_dir in bindings_dir.iterdir() if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
516
+ Returns:
517
+ List[Dict]:
518
+ A list of dictionaries, where each dictionary represents the
519
+ full description of an available binding.
520
+
521
+ Each dictionary contains the following keys:
522
+ - ``binding_name`` (str): The programmatic name of the binding (its folder name).
523
+ - ``title`` (str): A user-friendly title for the binding.
524
+ - ``author`` (str): The creator of the binding.
525
+ - ``creation_date`` (str): The date the binding was created.
526
+ - ``last_update_date`` (str): The date of the last major update.
527
+ - ``description`` (str): A detailed explanation of the binding's purpose.
528
+ - ``input_parameters`` (List[Dict]): A list of parameters required to
529
+ configure the binding. Each parameter is a dictionary with:
530
+ - ``name`` (str): The parameter's name (e.g., 'model_name').
531
+ - ``type`` (str): The expected data type ('str', 'int', 'float', 'bool').
532
+ - ``description`` (str): A user-friendly description of the parameter.
533
+ - ``mandatory`` (bool): True if the parameter must be provided.
534
+ - ``default``: The default value for the parameter.
535
+
536
+ Example of a returned dictionary in the list:
537
+ .. code-block:: python
538
+
539
+ {
540
+ "binding_name": "ollama",
541
+ "title": "Ollama",
542
+ "author": "ParisNeo",
543
+ ...
544
+ "input_parameters": [
545
+ {
546
+ "name": "host_address",
547
+ "type": "str",
548
+ "description": "The URL of the Ollama server.",
549
+ "mandatory": True,
550
+ "default": "http://localhost:11434"
551
+ },
552
+ ...
553
+ ]
554
+ }
555
+ """
556
+ return LollmsLLMBindingManager.get_bindings_list(self.llm_bindings_dir)
557
+
558
+ def get_available_bindings(llm_bindings_dir: Union[str, Path] = None) -> List[Dict]:
559
+ """
560
+ Lists all available LLM bindings with their detailed descriptions.
561
+
562
+ This function serves as a primary entry point for discovering what bindings
563
+ are available and how to configure them.
564
+
565
+ Args:
566
+ llm_bindings_dir (Union[str, Path], optional):
567
+ The path to the LLM bindings directory. If None, it defaults to the
568
+ 'llm_bindings' subdirectory relative to this file.
569
+ Defaults to None.
570
+
571
+ Returns:
572
+ List[Dict]: A list of dictionaries, each describing a binding.
573
+ """
574
+ if llm_bindings_dir is None:
575
+ llm_bindings_dir = Path(__file__).parent / "llm_bindings"
576
+ return LollmsLLMBindingManager.get_bindings_list(llm_bindings_dir)
@@ -4,7 +4,7 @@ import importlib
4
4
  from pathlib import Path
5
5
  from typing import Optional, List, Dict, Any, Union
6
6
  from ascii_colors import trace_exception, ASCIIColors
7
-
7
+ import yaml
8
8
  class LollmsMCPBinding(ABC):
9
9
  """
10
10
  Abstract Base Class for LOLLMS Model Context Protocol (MCP) Bindings.
@@ -185,6 +185,7 @@ class LollmsMCPBindingManager:
185
185
  return None
186
186
  return None
187
187
 
188
+
188
189
  def get_available_bindings(self) -> List[str]:
189
190
  """
190
191
  Return list of available MCP binding names based on subdirectories.
@@ -195,4 +196,34 @@ class LollmsMCPBindingManager:
195
196
  for item in self.mcp_bindings_dir.iterdir():
196
197
  if item.is_dir() and (item / "__init__.py").exists():
197
198
  available.append(item.name)
198
- return available
199
+ return available
200
+
201
+ def get_binding_description(self, binding_name: str) -> Optional[Dict[str, Any]]:
202
+ """
203
+ Loads and returns the content of the description.yaml file for a given binding.
204
+
205
+ Args:
206
+ binding_name (str): The name of the binding.
207
+
208
+ Returns:
209
+ Optional[Dict[str, Any]]: A dictionary with the parsed YAML content, or None if the file doesn't exist or is invalid.
210
+ """
211
+ binding_dir = self.mcp_bindings_dir / binding_name
212
+ description_file = binding_dir / "description.yaml"
213
+
214
+ if not description_file.exists():
215
+ ASCIIColors.warning(f"No description.yaml found for MCP binding '{binding_name}'.")
216
+ return None
217
+
218
+ try:
219
+ with open(description_file, 'r', encoding='utf-8') as f:
220
+ description = yaml.safe_load(f)
221
+ return description
222
+ except yaml.YAMLError as e:
223
+ ASCIIColors.error(f"Error parsing description.yaml for MCP binding '{binding_name}': {e}")
224
+ trace_exception(e)
225
+ return None
226
+ except Exception as e:
227
+ ASCIIColors.error(f"Error reading description.yaml for MCP binding '{binding_name}': {e}")
228
+ trace_exception(e)
229
+ return None