glchat-plugin 0.3.4__py3-none-any.whl → 0.3.6__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.
@@ -83,6 +83,8 @@ class PipelineHandler(PluginHandler):
83
83
  _pipeline_cache (dict[tuple[str, str], Pipeline]):
84
84
  Cache mapping (chatbot_id, model_id) to Pipeline instances.
85
85
  _chatbot_pipeline_keys (dict[str, set[tuple[str, str]]]): Mapping of chatbot IDs to their pipeline keys.
86
+ _pipeline_build_errors (dict[tuple[str, str], str]):
87
+ Cache mapping (chatbot_id, model_id) to error messages from failed pipeline builds.
86
88
  """
87
89
 
88
90
  app_config: AppConfig
@@ -92,6 +94,7 @@ class PipelineHandler(PluginHandler):
92
94
  _plugins: dict[str, Plugin] = {}
93
95
  _pipeline_cache: dict[tuple[str, str], Pipeline] = {}
94
96
  _chatbot_pipeline_keys: dict[str, set[tuple[str, str]]] = {}
97
+ _pipeline_build_errors: dict[tuple[str, str], str] = {}
95
98
 
96
99
  def __init__(self, app_config: AppConfig, chat_history_storage: BaseChatHistoryStorage):
97
100
  """Initialize the pipeline handler.
@@ -202,11 +205,18 @@ class PipelineHandler(PluginHandler):
202
205
  pipeline_key = (chatbot_id, f"__{pipeline_type}__")
203
206
  instance._chatbot_pipeline_keys.setdefault(chatbot_id, set()).add(pipeline_key)
204
207
  instance._pipeline_cache[pipeline_key] = pipeline
208
+
209
+ # Clear any previous error for this internal pipeline if build succeeded
210
+ instance._pipeline_build_errors.pop(pipeline_key, None)
205
211
  except Exception as e:
206
- logger.warning(f"Failed when ainit plugin {traceback.format_exc()}")
207
- logger.warning(
212
+ error_message = (
208
213
  f"Error building internal pipeline `{pipeline_type}` for chatbot `{chatbot_id}`: {e}"
209
214
  )
215
+ logger.warning(f"Failed when ainit plugin {traceback.format_exc()}")
216
+ logger.warning(error_message)
217
+
218
+ # Store the error message for later retrieval
219
+ instance._store_pipeline_build_error(chatbot_id, f"__{pipeline_type}__", error_message)
210
220
 
211
221
  for model in supported_models:
212
222
  try:
@@ -227,9 +237,16 @@ class PipelineHandler(PluginHandler):
227
237
  pipeline_key = (chatbot_id, str(model_id))
228
238
  instance._chatbot_pipeline_keys.setdefault(chatbot_id, set()).add(pipeline_key)
229
239
  instance._pipeline_cache[pipeline_key] = pipeline
240
+
241
+ # Clear any previous error for this pipeline if build succeeded
242
+ instance._pipeline_build_errors.pop(pipeline_key, None)
230
243
  except Exception as e:
244
+ error_message = f"Error building pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}"
231
245
  logger.warning(f"Failed when ainit plugin {traceback.format_exc()}")
232
- logger.warning(f"Error building pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}")
246
+ logger.warning(error_message)
247
+
248
+ # Store the error message for later retrieval
249
+ instance._store_pipeline_build_error(chatbot_id, str(model_id), error_message)
233
250
 
234
251
  def get_pipeline_builder(self, chatbot_id: str) -> Plugin:
235
252
  """Get a pipeline builder instance for the given chatbot.
@@ -338,7 +355,11 @@ class PipelineHandler(PluginHandler):
338
355
  logger.info(f"Successfully rebuilt pipeline for chatbot `{chatbot_id}` model `{model_id}`")
339
356
 
340
357
  except Exception as e:
341
- logger.warning(f"Error rebuilding pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}")
358
+ error_message = f"Error rebuilding pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}"
359
+ logger.warning(error_message)
360
+
361
+ # Store the error message for later retrieval
362
+ self._store_pipeline_build_error(chatbot_id, model_id, error_message)
342
363
 
343
364
  async def aget_pipeline(self, chatbot_id: str, model_id: str) -> Pipeline:
344
365
  """Get a pipeline instance for the given chatbot and model ID (async version).
@@ -363,9 +384,17 @@ class PipelineHandler(PluginHandler):
363
384
  await self._async_rebuild_pipeline(chatbot_id, str(model_id))
364
385
 
365
386
  if pipeline_key not in self._pipeline_cache:
366
- raise ValueError(
367
- f"Pipeline for chatbot `{chatbot_id}` model `{model_id}` not found and could not be rebuilt"
368
- )
387
+ # Check if there's a stored error message for this pipeline
388
+ stored_error = self.get_pipeline_build_error(chatbot_id, str(model_id))
389
+ if stored_error:
390
+ raise ValueError(
391
+ f"Pipeline for chatbot `{chatbot_id}` model `{model_id}` not found and could not be rebuilt. "
392
+ f"Previous build error: {stored_error}"
393
+ )
394
+ else:
395
+ raise ValueError(
396
+ f"Pipeline for chatbot `{chatbot_id}` model `{model_id}` not found and could not be rebuilt"
397
+ )
369
398
 
370
399
  return self._pipeline_cache[pipeline_key]
371
400
 
@@ -464,6 +493,11 @@ class PipelineHandler(PluginHandler):
464
493
  for pipeline_key in self._chatbot_pipeline_keys.get(chatbot_id, set()):
465
494
  self._pipeline_cache.pop(pipeline_key, None)
466
495
 
496
+ # Clear stored error messages for this chatbot
497
+ error_keys_to_remove = [key for key in self._pipeline_build_errors.keys() if key[0] == chatbot_id]
498
+ for key in error_keys_to_remove:
499
+ self._pipeline_build_errors.pop(key, None)
500
+
467
501
  self._chatbot_pipeline_keys.pop(chatbot_id, None)
468
502
  self._chatbot_configs.pop(chatbot_id, None)
469
503
  self._builders.pop(chatbot_id, None)
@@ -564,6 +598,30 @@ class PipelineHandler(PluginHandler):
564
598
  if chatbot_id not in self._chatbot_configs:
565
599
  raise ValueError(f"Pipeline configuration for chatbot `{chatbot_id}` not found")
566
600
 
601
+ def _store_pipeline_build_error(self, chatbot_id: str, model_id: str, error_message: str) -> None:
602
+ """Store error message for failed pipeline build.
603
+
604
+ Args:
605
+ chatbot_id (str): The chatbot ID.
606
+ model_id (str): The model ID.
607
+ error_message (str): The error message to store.
608
+ """
609
+ pipeline_key = (chatbot_id, str(model_id))
610
+ self._pipeline_build_errors[pipeline_key] = error_message
611
+
612
+ def get_pipeline_build_error(self, chatbot_id: str, model_id: str) -> str | None:
613
+ """Get stored error message for failed pipeline build.
614
+
615
+ Args:
616
+ chatbot_id (str): The chatbot ID.
617
+ model_id (str): The model ID.
618
+
619
+ Returns:
620
+ str | None: The stored error message if available, None otherwise.
621
+ """
622
+ pipeline_key = (chatbot_id, str(model_id))
623
+ return self._pipeline_build_errors.get(pipeline_key)
624
+
567
625
  async def aget_pipeline_builder(self, chatbot_id: str) -> Plugin:
568
626
  """Get a pipeline builder instance for the given chatbot (async version).
569
627
 
@@ -582,7 +640,20 @@ class PipelineHandler(PluginHandler):
582
640
  await self._async_rebuild_plugin(chatbot_id)
583
641
 
584
642
  if chatbot_id not in self._builders:
585
- raise ValueError(f"Pipeline builder for chatbot `{chatbot_id}` not found and could not be rebuilt")
643
+ # Check if there are any stored error messages for this chatbot
644
+ chatbot_errors = []
645
+ for (c_id, m_id), error_msg in self._pipeline_build_errors.items():
646
+ if c_id == chatbot_id:
647
+ chatbot_errors.append(f"Model `{m_id}`: {error_msg}")
648
+
649
+ if chatbot_errors:
650
+ error_details = "; ".join(chatbot_errors)
651
+ raise ValueError(
652
+ f"Pipeline builder for chatbot `{chatbot_id}` not found and could not be rebuilt. "
653
+ f"Previous build errors: {error_details}"
654
+ )
655
+ else:
656
+ raise ValueError(f"Pipeline builder for chatbot `{chatbot_id}` not found and could not be rebuilt")
586
657
 
587
658
  return self._builders[chatbot_id]
588
659
 
@@ -621,4 +692,8 @@ class PipelineHandler(PluginHandler):
621
692
  logger.info(f"Successfully rebuilt pipeline builder for chatbot `{chatbot_id}`")
622
693
 
623
694
  except Exception as e:
624
- logger.warning(f"Error rebuilding plugin for chatbot `{chatbot_id}`: {e}")
695
+ error_message = f"Error rebuilding plugin for chatbot `{chatbot_id}`: {e}"
696
+ logger.warning(error_message)
697
+
698
+ # Store the error message for later retrieval (using a generic model_id for plugin-level errors)
699
+ self._store_pipeline_build_error(chatbot_id, "__plugin__", error_message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: glchat-plugin
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Author-email: GenAI SDK Team <gat-sdk@gdplabs.id>
5
5
  Requires-Python: <3.13,>=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,7 +8,7 @@ glchat_plugin/handler/__init__.py,sha256=H5DJaAfwwtRsvMcOaEzHfGMQk25H7la0E7uPfks
8
8
  glchat_plugin/handler/base_post_login_handler.py,sha256=48xSbe_LwTCjRY-lCuzWXqbnEr1ql8bAhQih1Xeh8f8,2835
9
9
  glchat_plugin/pipeline/__init__.py,sha256=Sk-NfIGyA9VKIg0Bt5OHatNUYyWVPh9i5xhE5DFAfbo,41
10
10
  glchat_plugin/pipeline/base_pipeline_preset_config.py,sha256=vr453A2Nx09LqBYbsAVsMutD952wKh3udE1L4vXKyEI,2852
11
- glchat_plugin/pipeline/pipeline_handler.py,sha256=aCRvhS6Dkhmqsx_Ya-2t2PbMseacw1VI6PUEOQq0RsM,25620
11
+ glchat_plugin/pipeline/pipeline_handler.py,sha256=CrC4PU5nLU-7QkebUMUsK4M3R55MwvXiX4tNiyb9_HE,29273
12
12
  glchat_plugin/pipeline/pipeline_plugin.py,sha256=fozvxVrOphgwLIF7uPrEkF8ZQcu8xgifYAQyuxj9628,4393
13
13
  glchat_plugin/service/__init__.py,sha256=9T4qzyYL052qLqva5el1F575OTRNaaf9tb9UvW-leTc,47
14
14
  glchat_plugin/service/base_rate_limiter_service.py,sha256=tgKwdr4EqnGo5iDRVJPnlg8W9q0hiUzfeewAtdW4IjU,1232
@@ -19,7 +19,7 @@ glchat_plugin/storage/base_anonymizer_storage.py,sha256=oFwovWrsjM7v1YjeN-4p-M3O
19
19
  glchat_plugin/storage/base_chat_history_storage.py,sha256=JvUUFMu_9jRBQ9yug_x7S4rQjZEA1vM5ombDvz-7zCE,11095
20
20
  glchat_plugin/tools/__init__.py,sha256=OFotHbgQ8mZEbdlvlv5aVMdxfubPvkVWAcTwhIPdIqQ,542
21
21
  glchat_plugin/tools/decorators.py,sha256=AvQBV18wzXWdC483RSSmpfh92zsqTyp8SzDLIkreIGU,3925
22
- glchat_plugin-0.3.4.dist-info/METADATA,sha256=ZBhIffx9SQYiLZ-DF6wJbULmrDxRK-3sUFchFtEeSHg,2063
23
- glchat_plugin-0.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- glchat_plugin-0.3.4.dist-info/top_level.txt,sha256=fzKSXmct5dY4CAKku4-mkdHX-QPAyQVvo8vpQj8qizY,14
25
- glchat_plugin-0.3.4.dist-info/RECORD,,
22
+ glchat_plugin-0.3.6.dist-info/METADATA,sha256=ZzCdsR3yhtD5ltXw_42w76_RJYaRpvvU1JgLDFFLsEc,2063
23
+ glchat_plugin-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ glchat_plugin-0.3.6.dist-info/top_level.txt,sha256=fzKSXmct5dY4CAKku4-mkdHX-QPAyQVvo8vpQj8qizY,14
25
+ glchat_plugin-0.3.6.dist-info/RECORD,,