glchat-plugin 0.3.3__py3-none-any.whl → 0.3.5__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.
- glchat_plugin/config/constant.py +2 -0
- glchat_plugin/pipeline/pipeline_handler.py +75 -7
- {glchat_plugin-0.3.3.dist-info → glchat_plugin-0.3.5.dist-info}/METADATA +1 -1
- {glchat_plugin-0.3.3.dist-info → glchat_plugin-0.3.5.dist-info}/RECORD +6 -6
- {glchat_plugin-0.3.3.dist-info → glchat_plugin-0.3.5.dist-info}/WHEEL +0 -0
- {glchat_plugin-0.3.3.dist-info → glchat_plugin-0.3.5.dist-info}/top_level.txt +0 -0
glchat_plugin/config/constant.py
CHANGED
|
@@ -17,6 +17,7 @@ class SearchType(StrEnum):
|
|
|
17
17
|
Attributes:
|
|
18
18
|
NORMAL: Get answer from chatbot knowledge.
|
|
19
19
|
SEARCH: Get answer from various connectors.
|
|
20
|
+
SQL_SEARCH: Get answer from SQL-based database.
|
|
20
21
|
WEB: Get more relevant information from the web. (DEPRECATED)
|
|
21
22
|
Web Search uses real-time data. Agent selection isn't available in this mode.
|
|
22
23
|
DEEP_RESEARCH: Get answer from Deep Research Agent.
|
|
@@ -31,6 +32,7 @@ class SearchType(StrEnum):
|
|
|
31
32
|
|
|
32
33
|
NORMAL = "normal"
|
|
33
34
|
SEARCH = "search"
|
|
35
|
+
SQL_SEARCH = "sql_search"
|
|
34
36
|
_WEB = "web" # Underscore to hide it from normal use
|
|
35
37
|
_DEEP_RESEARCH = "deep_research"
|
|
36
38
|
ESSENTIALS_DEEP_RESEARCH = "essentials_deep_research"
|
|
@@ -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.
|
|
@@ -227,9 +230,16 @@ class PipelineHandler(PluginHandler):
|
|
|
227
230
|
pipeline_key = (chatbot_id, str(model_id))
|
|
228
231
|
instance._chatbot_pipeline_keys.setdefault(chatbot_id, set()).add(pipeline_key)
|
|
229
232
|
instance._pipeline_cache[pipeline_key] = pipeline
|
|
233
|
+
|
|
234
|
+
# Clear any previous error for this pipeline if build succeeded
|
|
235
|
+
instance._pipeline_build_errors.pop(pipeline_key, None)
|
|
230
236
|
except Exception as e:
|
|
237
|
+
error_message = f"Error building pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}"
|
|
231
238
|
logger.warning(f"Failed when ainit plugin {traceback.format_exc()}")
|
|
232
|
-
logger.warning(
|
|
239
|
+
logger.warning(error_message)
|
|
240
|
+
|
|
241
|
+
# Store the error message for later retrieval
|
|
242
|
+
instance._store_pipeline_build_error(chatbot_id, str(model_id), error_message)
|
|
233
243
|
|
|
234
244
|
def get_pipeline_builder(self, chatbot_id: str) -> Plugin:
|
|
235
245
|
"""Get a pipeline builder instance for the given chatbot.
|
|
@@ -338,7 +348,11 @@ class PipelineHandler(PluginHandler):
|
|
|
338
348
|
logger.info(f"Successfully rebuilt pipeline for chatbot `{chatbot_id}` model `{model_id}`")
|
|
339
349
|
|
|
340
350
|
except Exception as e:
|
|
341
|
-
|
|
351
|
+
error_message = f"Error rebuilding pipeline for chatbot `{chatbot_id}` model `{model_id}`: {e}"
|
|
352
|
+
logger.warning(error_message)
|
|
353
|
+
|
|
354
|
+
# Store the error message for later retrieval
|
|
355
|
+
self._store_pipeline_build_error(chatbot_id, model_id, error_message)
|
|
342
356
|
|
|
343
357
|
async def aget_pipeline(self, chatbot_id: str, model_id: str) -> Pipeline:
|
|
344
358
|
"""Get a pipeline instance for the given chatbot and model ID (async version).
|
|
@@ -363,9 +377,17 @@ class PipelineHandler(PluginHandler):
|
|
|
363
377
|
await self._async_rebuild_pipeline(chatbot_id, str(model_id))
|
|
364
378
|
|
|
365
379
|
if pipeline_key not in self._pipeline_cache:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
380
|
+
# Check if there's a stored error message for this pipeline
|
|
381
|
+
stored_error = self.get_pipeline_build_error(chatbot_id, str(model_id))
|
|
382
|
+
if stored_error:
|
|
383
|
+
raise ValueError(
|
|
384
|
+
f"Pipeline for chatbot `{chatbot_id}` model `{model_id}` not found and could not be rebuilt. "
|
|
385
|
+
f"Previous build error: {stored_error}"
|
|
386
|
+
)
|
|
387
|
+
else:
|
|
388
|
+
raise ValueError(
|
|
389
|
+
f"Pipeline for chatbot `{chatbot_id}` model `{model_id}` not found and could not be rebuilt"
|
|
390
|
+
)
|
|
369
391
|
|
|
370
392
|
return self._pipeline_cache[pipeline_key]
|
|
371
393
|
|
|
@@ -464,6 +486,11 @@ class PipelineHandler(PluginHandler):
|
|
|
464
486
|
for pipeline_key in self._chatbot_pipeline_keys.get(chatbot_id, set()):
|
|
465
487
|
self._pipeline_cache.pop(pipeline_key, None)
|
|
466
488
|
|
|
489
|
+
# Clear stored error messages for this chatbot
|
|
490
|
+
error_keys_to_remove = [key for key in self._pipeline_build_errors.keys() if key[0] == chatbot_id]
|
|
491
|
+
for key in error_keys_to_remove:
|
|
492
|
+
self._pipeline_build_errors.pop(key, None)
|
|
493
|
+
|
|
467
494
|
self._chatbot_pipeline_keys.pop(chatbot_id, None)
|
|
468
495
|
self._chatbot_configs.pop(chatbot_id, None)
|
|
469
496
|
self._builders.pop(chatbot_id, None)
|
|
@@ -564,6 +591,30 @@ class PipelineHandler(PluginHandler):
|
|
|
564
591
|
if chatbot_id not in self._chatbot_configs:
|
|
565
592
|
raise ValueError(f"Pipeline configuration for chatbot `{chatbot_id}` not found")
|
|
566
593
|
|
|
594
|
+
def _store_pipeline_build_error(self, chatbot_id: str, model_id: str, error_message: str) -> None:
|
|
595
|
+
"""Store error message for failed pipeline build.
|
|
596
|
+
|
|
597
|
+
Args:
|
|
598
|
+
chatbot_id (str): The chatbot ID.
|
|
599
|
+
model_id (str): The model ID.
|
|
600
|
+
error_message (str): The error message to store.
|
|
601
|
+
"""
|
|
602
|
+
pipeline_key = (chatbot_id, str(model_id))
|
|
603
|
+
self._pipeline_build_errors[pipeline_key] = error_message
|
|
604
|
+
|
|
605
|
+
def get_pipeline_build_error(self, chatbot_id: str, model_id: str) -> str | None:
|
|
606
|
+
"""Get stored error message for failed pipeline build.
|
|
607
|
+
|
|
608
|
+
Args:
|
|
609
|
+
chatbot_id (str): The chatbot ID.
|
|
610
|
+
model_id (str): The model ID.
|
|
611
|
+
|
|
612
|
+
Returns:
|
|
613
|
+
str | None: The stored error message if available, None otherwise.
|
|
614
|
+
"""
|
|
615
|
+
pipeline_key = (chatbot_id, str(model_id))
|
|
616
|
+
return self._pipeline_build_errors.get(pipeline_key)
|
|
617
|
+
|
|
567
618
|
async def aget_pipeline_builder(self, chatbot_id: str) -> Plugin:
|
|
568
619
|
"""Get a pipeline builder instance for the given chatbot (async version).
|
|
569
620
|
|
|
@@ -582,7 +633,20 @@ class PipelineHandler(PluginHandler):
|
|
|
582
633
|
await self._async_rebuild_plugin(chatbot_id)
|
|
583
634
|
|
|
584
635
|
if chatbot_id not in self._builders:
|
|
585
|
-
|
|
636
|
+
# Check if there are any stored error messages for this chatbot
|
|
637
|
+
chatbot_errors = []
|
|
638
|
+
for (c_id, m_id), error_msg in self._pipeline_build_errors.items():
|
|
639
|
+
if c_id == chatbot_id:
|
|
640
|
+
chatbot_errors.append(f"Model `{m_id}`: {error_msg}")
|
|
641
|
+
|
|
642
|
+
if chatbot_errors:
|
|
643
|
+
error_details = "; ".join(chatbot_errors)
|
|
644
|
+
raise ValueError(
|
|
645
|
+
f"Pipeline builder for chatbot `{chatbot_id}` not found and could not be rebuilt. "
|
|
646
|
+
f"Previous build errors: {error_details}"
|
|
647
|
+
)
|
|
648
|
+
else:
|
|
649
|
+
raise ValueError(f"Pipeline builder for chatbot `{chatbot_id}` not found and could not be rebuilt")
|
|
586
650
|
|
|
587
651
|
return self._builders[chatbot_id]
|
|
588
652
|
|
|
@@ -621,4 +685,8 @@ class PipelineHandler(PluginHandler):
|
|
|
621
685
|
logger.info(f"Successfully rebuilt pipeline builder for chatbot `{chatbot_id}`")
|
|
622
686
|
|
|
623
687
|
except Exception as e:
|
|
624
|
-
|
|
688
|
+
error_message = f"Error rebuilding plugin for chatbot `{chatbot_id}`: {e}"
|
|
689
|
+
logger.warning(error_message)
|
|
690
|
+
|
|
691
|
+
# Store the error message for later retrieval (using a generic model_id for plugin-level errors)
|
|
692
|
+
self._store_pipeline_build_error(chatbot_id, "__plugin__", error_message)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
glchat_plugin/__init__.py,sha256=SHSBMz7JDU6MecyIrhHu5-3NVs89JkXhyvD3ZGOkWOE,37
|
|
2
2
|
glchat_plugin/config/__init__.py,sha256=DNnX8B_TvAN89oyMgq32zG1DeaezODrihiAXTwOPT5o,39
|
|
3
3
|
glchat_plugin/config/app_config.py,sha256=9_ShYtaQ7Rp14sSkrIFLoOAMlbwVlm13EuCxzOn4NCI,426
|
|
4
|
-
glchat_plugin/config/constant.py,sha256=
|
|
4
|
+
glchat_plugin/config/constant.py,sha256=DB6-XlINqhRU6qGrDbOA7OSMk9uiq4l2nYYMVjEnDTY,3590
|
|
5
5
|
glchat_plugin/context/__init__.py,sha256=3Wx_apMIS6z-m6eRs6hoyOsJFLJfKmMFOkrPDkPQfJI,40
|
|
6
6
|
glchat_plugin/context/context_manager.py,sha256=0lhO0w_hd5dUdIEJQ2LOJFZsgpzitQU_aPZfTfQK3vw,1302
|
|
7
7
|
glchat_plugin/handler/__init__.py,sha256=H5DJaAfwwtRsvMcOaEzHfGMQk25H7la0E7uPfksWtoQ,40
|
|
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=
|
|
11
|
+
glchat_plugin/pipeline/pipeline_handler.py,sha256=m4FQ3rljVhlQWJWaKomuAQXHRZwWXPGEJbjuXf0_lpQ,28876
|
|
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.
|
|
23
|
-
glchat_plugin-0.3.
|
|
24
|
-
glchat_plugin-0.3.
|
|
25
|
-
glchat_plugin-0.3.
|
|
22
|
+
glchat_plugin-0.3.5.dist-info/METADATA,sha256=xurHTPZ1nF4Vewu9iAsqIH5R6YEjROL6wURIwMWoleE,2063
|
|
23
|
+
glchat_plugin-0.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
24
|
+
glchat_plugin-0.3.5.dist-info/top_level.txt,sha256=fzKSXmct5dY4CAKku4-mkdHX-QPAyQVvo8vpQj8qizY,14
|
|
25
|
+
glchat_plugin-0.3.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|