glchat-plugin 0.4.4__py3-none-any.whl → 0.4.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.
@@ -7,6 +7,7 @@ Authors:
7
7
  Hermes Vincentius Gani (hermes.v.gani@gdplabs.id)
8
8
  """
9
9
 
10
+ import inspect
10
11
  import traceback
11
12
  from typing import Any, Type
12
13
 
@@ -272,8 +273,13 @@ class PipelineHandler(PluginHandler):
272
273
  organization_id (str): The organization ID.
273
274
  """
274
275
  chatbot_organization_id = (chatbot_id, organization_id)
275
- plugin.prompt_builder_catalogs = instance._chatbot_configs[chatbot_organization_id].prompt_builder_catalogs
276
- plugin.lmrp_catalogs = instance._chatbot_configs[chatbot_organization_id].lmrp_catalogs
276
+
277
+ prompt_builder_catalogs = instance._chatbot_configs[chatbot_organization_id].prompt_builder_catalogs
278
+ plugin.prompt_builder_catalogs = prompt_builder_catalogs
279
+
280
+ lmrp_catalogs = instance._chatbot_configs[chatbot_organization_id].lmrp_catalogs
281
+ plugin.lmrp_catalogs = lmrp_catalogs
282
+
277
283
  instance._builders[chatbot_organization_id] = plugin
278
284
 
279
285
  for pipeline_type in INTERNAL_PIPELINES:
@@ -281,13 +287,16 @@ class PipelineHandler(PluginHandler):
281
287
  internal_plugin = instance._plugins.get(pipeline_type_organization_id)
282
288
  if internal_plugin:
283
289
  try:
284
- internal_plugin.prompt_builder_catalogs = instance._chatbot_configs[
285
- chatbot_organization_id
286
- ].prompt_builder_catalogs
287
- internal_plugin.lmrp_catalogs = instance._chatbot_configs[chatbot_organization_id].lmrp_catalogs
290
+ internal_plugin.prompt_builder_catalogs = prompt_builder_catalogs
291
+ internal_plugin.lmrp_catalogs = lmrp_catalogs
288
292
  pipeline_config = instance._chatbot_configs[chatbot_organization_id].pipeline_config.copy()
289
- pipeline = await internal_plugin.build(pipeline_config)
290
- pipeline_tools = await internal_plugin.build_tools(pipeline_config)
293
+ pipeline = await cls._call_build(
294
+ internal_plugin,
295
+ pipeline_config,
296
+ prompt_builder_catalogs,
297
+ lmrp_catalogs,
298
+ )
299
+ pipeline_tools = await internal_plugin.build_tools(pipeline_config, prompt_builder_catalogs, lmrp_catalogs)
291
300
  pipeline_key = (chatbot_id, f"__{pipeline_type}__", organization_id)
292
301
  instance._chatbot_pipeline_keys.setdefault(chatbot_organization_id, set()).add(pipeline_key)
293
302
  instance._pipeline_cache[pipeline_key] = PipelineBundle(pipeline, pipeline_tools)
@@ -321,8 +330,13 @@ class PipelineHandler(PluginHandler):
321
330
  if credentials:
322
331
  pipeline_config["api_key"] = credentials
323
332
 
324
- pipeline = await plugin.build(pipeline_config)
325
- pipeline_tools = await plugin.build_tools(pipeline_config)
333
+ pipeline = await cls._call_build(
334
+ plugin,
335
+ pipeline_config,
336
+ prompt_builder_catalogs,
337
+ lmrp_catalogs,
338
+ )
339
+ pipeline_tools = await plugin.build_tools(pipeline_config, prompt_builder_catalogs, lmrp_catalogs)
326
340
  pipeline_key = (chatbot_id, str(model_id), organization_id)
327
341
  instance._chatbot_pipeline_keys.setdefault(chatbot_organization_id, set()).add(pipeline_key)
328
342
  instance._pipeline_cache[pipeline_key] = PipelineBundle(pipeline, pipeline_tools)
@@ -337,6 +351,41 @@ class PipelineHandler(PluginHandler):
337
351
  # Store the error message for later retrieval
338
352
  instance._store_pipeline_build_error(chatbot_id, str(model_id), organization_id, error_message)
339
353
 
354
+ @classmethod
355
+ async def _call_build(
356
+ cls,
357
+ plugin: Plugin,
358
+ pipeline_config: dict[str, Any],
359
+ prompt_builder_catalogs: dict[str, PromptBuilderCatalog] | None,
360
+ lmrp_catalogs: dict[str, LMRequestProcessorCatalog] | None,
361
+ ) -> Pipeline:
362
+ """Call plugin.build in a backward-compatible way.
363
+
364
+ If the plugin.build signature declares prompt_builder_catalogs or lmrp_catalogs,
365
+ they will be passed as keyword arguments. Otherwise, only pipeline_config is passed.
366
+ """
367
+ try:
368
+ sig = inspect.signature(plugin.build)
369
+ except (TypeError, ValueError):
370
+ # Fallback: call with just pipeline_config
371
+ return await plugin.build(pipeline_config)
372
+
373
+ params = list(sig.parameters.values())
374
+ # Skip 'self' if present
375
+ if params and params[0].name == "self":
376
+ params = params[1:]
377
+
378
+ param_names = {p.name for p in params}
379
+
380
+ if "prompt_builder_catalogs" in param_names or "lmrp_catalogs" in param_names:
381
+ return await plugin.build(
382
+ pipeline_config,
383
+ prompt_builder_catalogs=prompt_builder_catalogs,
384
+ lmrp_catalogs=lmrp_catalogs,
385
+ )
386
+
387
+ return await plugin.build(pipeline_config)
388
+
340
389
  def get_pipeline_builder(self, chatbot_id: str, organization_id: str = DEFAULT_ORGANIZATION_ID) -> Plugin:
341
390
  """Get a pipeline builder instance for the given chatbot.
342
391
 
@@ -137,6 +137,8 @@ class PipelineBuilderPlugin(Plugin, Generic[PipelineState, PipelinePresetConfig]
137
137
  async def build_tools(
138
138
  self,
139
139
  pipeline_config: dict[str, Any],
140
+ prompt_builder_catalogs: dict[str, BaseCatalog[Any]] | None = None,
141
+ lmrp_catalogs: dict[str, BaseCatalog[Any]] | None = None,
140
142
  ) -> list[ToolProcessor]:
141
143
  """Build a pipeline instance.
142
144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: glchat-plugin
3
- Version: 0.4.4
3
+ Version: 0.4.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,8 +8,8 @@ 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=lbMH8y_HU3LrqtMYXLzQ2906ZkMXARKY5vBuIGvRVdA,2969
11
- glchat_plugin/pipeline/pipeline_handler.py,sha256=BaGnbH4sy0DXyoZpeAlp6gWmqJMZlg7W9KpxCSMu-u8,36527
12
- glchat_plugin/pipeline/pipeline_plugin.py,sha256=fDQWJkEMgbbY6bK81gHjzp3fLZZN0a0Pv6_DS4wSKL0,5040
11
+ glchat_plugin/pipeline/pipeline_handler.py,sha256=JPJypNA1YdE6EGJg8gEq2xqDtWdxwxqpdqmbIlG6Ls8,38188
12
+ glchat_plugin/pipeline/pipeline_plugin.py,sha256=xUOVnMu2Skc1QseVpCAm45YBFnQIOEuSAqpHoBVsyJc,5182
13
13
  glchat_plugin/pipeline/tool_processor.py,sha256=pc-uHoBqOSXjLM8R_Wgws_z5ehPtaSeb9Bhk9aeLDus,2731
14
14
  glchat_plugin/service/__init__.py,sha256=9T4qzyYL052qLqva5el1F575OTRNaaf9tb9UvW-leTc,47
15
15
  glchat_plugin/service/base_rate_limiter_service.py,sha256=tgKwdr4EqnGo5iDRVJPnlg8W9q0hiUzfeewAtdW4IjU,1232
@@ -20,7 +20,7 @@ glchat_plugin/storage/base_anonymizer_storage.py,sha256=oFwovWrsjM7v1YjeN-4p-M3O
20
20
  glchat_plugin/storage/base_chat_history_storage.py,sha256=YIGM8zv7s5BQ8O7W1LfaLyQW4SF9Bt3aolowsoDaQw8,11257
21
21
  glchat_plugin/tools/__init__.py,sha256=OFotHbgQ8mZEbdlvlv5aVMdxfubPvkVWAcTwhIPdIqQ,542
22
22
  glchat_plugin/tools/decorators.py,sha256=AvQBV18wzXWdC483RSSmpfh92zsqTyp8SzDLIkreIGU,3925
23
- glchat_plugin-0.4.4.dist-info/METADATA,sha256=bQlhz2exJI-pcGGfjYFNpbdV5kMSePxbdCYhO6cvxZo,2063
24
- glchat_plugin-0.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- glchat_plugin-0.4.4.dist-info/top_level.txt,sha256=fzKSXmct5dY4CAKku4-mkdHX-QPAyQVvo8vpQj8qizY,14
26
- glchat_plugin-0.4.4.dist-info/RECORD,,
23
+ glchat_plugin-0.4.6.dist-info/METADATA,sha256=1g9LlVnwamc7VP3r-wCs293gBhCkcoWQUiaiVnwbhtc,2063
24
+ glchat_plugin-0.4.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ glchat_plugin-0.4.6.dist-info/top_level.txt,sha256=fzKSXmct5dY4CAKku4-mkdHX-QPAyQVvo8vpQj8qizY,14
26
+ glchat_plugin-0.4.6.dist-info/RECORD,,