Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

dynamic_select.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from collections.abc import Mapping
  2. from typing import Any
  3. from core.plugin.entities.plugin import GenericProviderID
  4. from core.plugin.entities.plugin_daemon import PluginDynamicSelectOptionsResponse
  5. from core.plugin.impl.base import BasePluginClient
  6. class DynamicSelectClient(BasePluginClient):
  7. def fetch_dynamic_select_options(
  8. self,
  9. tenant_id: str,
  10. user_id: str,
  11. plugin_id: str,
  12. provider: str,
  13. action: str,
  14. credentials: Mapping[str, Any],
  15. parameter: str,
  16. ) -> PluginDynamicSelectOptionsResponse:
  17. """
  18. Fetch dynamic select options for a plugin parameter.
  19. """
  20. response = self._request_with_plugin_daemon_response_stream(
  21. "POST",
  22. f"plugin/{tenant_id}/dispatch/dynamic_select/fetch_parameter_options",
  23. PluginDynamicSelectOptionsResponse,
  24. data={
  25. "user_id": user_id,
  26. "data": {
  27. "provider": GenericProviderID(provider).provider_name,
  28. "credentials": credentials,
  29. "provider_action": action,
  30. "parameter": parameter,
  31. },
  32. },
  33. headers={
  34. "X-Plugin-ID": plugin_id,
  35. "Content-Type": "application/json",
  36. },
  37. )
  38. for options in response:
  39. return options
  40. raise ValueError("Plugin service returned no options")