naeural-client 2.1.2__tar.gz → 2.1.4__tar.gz

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.
Files changed (125) hide show
  1. {naeural_client-2.1.2 → naeural_client-2.1.4}/.github/workflows/python-publish.yml +4 -1
  2. {naeural_client-2.1.2 → naeural_client-2.1.4}/PKG-INFO +1 -1
  3. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/_ver.py +1 -1
  4. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/generic_session.py +144 -1
  5. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/apps.py +2 -1
  6. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/base.py +18 -3
  7. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/environment.py +2 -0
  8. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/payload.py +4 -0
  9. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/instance/__init__.py +2 -2
  10. naeural_client-2.1.2/naeural_client/default/instance/basic_telegram_bot_01_plugin.py → naeural_client-2.1.4/naeural_client/default/instance/telegram_basic_bot_01_plugin.py +1 -1
  11. naeural_client-2.1.4/naeural_client/default/instance/telegram_conversational_bot_01_plugin.py +7 -0
  12. {naeural_client-2.1.2 → naeural_client-2.1.4}/pyproject.toml +1 -1
  13. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/.example_env +2 -0
  14. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex10_telegram_echo_bot.py +4 -11
  15. naeural_client-2.1.4/tutorials/ex11_telegram_blackjack_bot.py +203 -0
  16. naeural_client-2.1.4/tutorials/ex12_telegram_smart_bot.py +48 -0
  17. naeural_client-2.1.2/tutorials/ex11_telegram_smart_bot.py +0 -44
  18. {naeural_client-2.1.2 → naeural_client-2.1.4}/.devcontainer/Dockerfile +0 -0
  19. {naeural_client-2.1.2 → naeural_client-2.1.4}/.devcontainer/devcontainer.json +0 -0
  20. {naeural_client-2.1.2 → naeural_client-2.1.4}/.gitattributes +0 -0
  21. {naeural_client-2.1.2 → naeural_client-2.1.4}/.gitignore +0 -0
  22. {naeural_client-2.1.2 → naeural_client-2.1.4}/.vscode/launch.json +0 -0
  23. {naeural_client-2.1.2 → naeural_client-2.1.4}/LICENSE +0 -0
  24. {naeural_client-2.1.2 → naeural_client-2.1.4}/README.md +0 -0
  25. {naeural_client-2.1.2 → naeural_client-2.1.4}/TODOs.md +0 -0
  26. {naeural_client-2.1.2 → naeural_client-2.1.4}/__init__.py +0 -0
  27. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/__init__.py +0 -0
  28. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/__init__.py +0 -0
  29. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/distributed_custom_code_presets.py +0 -0
  30. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/instance.py +0 -0
  31. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/payload/__init__.py +0 -0
  32. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/payload/payload.py +0 -0
  33. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/pipeline.py +0 -0
  34. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/plugin_template.py +0 -0
  35. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/responses.py +0 -0
  36. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base/transaction.py +0 -0
  37. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/base_decentra_object.py +0 -0
  38. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/bc/__init__.py +0 -0
  39. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/bc/base.py +0 -0
  40. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/bc/chain.py +0 -0
  41. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/bc/ec.py +0 -0
  42. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/certs/__init__.py +0 -0
  43. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt +0 -0
  44. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/code_cheker/__init__.py +0 -0
  45. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/code_cheker/base.py +0 -0
  46. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/code_cheker/checker.py +0 -0
  47. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/comm/__init__.py +0 -0
  48. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/comm/amqp_wrapper.py +0 -0
  49. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/comm/mqtt_wrapper.py +0 -0
  50. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/README.md +0 -0
  51. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/__init__.py +0 -0
  52. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/comms.py +0 -0
  53. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/formatter.py +0 -0
  54. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/heartbeat.py +0 -0
  55. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/const/misc.py +0 -0
  56. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/__init__.py +0 -0
  57. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/instance/chain_dist_custom_job_01_plugin.py +0 -0
  58. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/instance/custom_web_app_01_plugin.py +0 -0
  59. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/instance/net_mon_01_plugin.py +0 -0
  60. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/instance/view_scene_01_plugin.py +0 -0
  61. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/default/session/mqtt_session.py +0 -0
  62. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/__init__.py +0 -0
  63. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/base/__init__.py +0 -0
  64. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/base/base_formatter.py +0 -0
  65. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/default/__init__.py +0 -0
  66. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/default/a_dummy.py +0 -0
  67. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/default/aixp1.py +0 -0
  68. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/default/default.py +0 -0
  69. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/io_formatter/io_formatter_manager.py +0 -0
  70. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/__init__.py +0 -0
  71. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/base_logger.py +0 -0
  72. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/__init__.py +0 -0
  73. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/class_instance_mixin.py +0 -0
  74. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/computer_vision_mixin.py +0 -0
  75. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/datetime_mixin.py +0 -0
  76. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/download_mixin.py +0 -0
  77. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/general_serialization_mixin.py +0 -0
  78. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/json_serialization_mixin.py +0 -0
  79. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/pickle_serialization_mixin.py +0 -0
  80. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/process_mixin.py +0 -0
  81. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/resource_size_mixin.py +0 -0
  82. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/timers_mixin.py +0 -0
  83. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/upload_mixin.py +0 -0
  84. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/logger_mixins/utils_mixin.py +0 -0
  85. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/small_logger.py +0 -0
  86. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/tzlocal/__init__.py +0 -0
  87. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/tzlocal/unix.py +0 -0
  88. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/tzlocal/utils.py +0 -0
  89. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/tzlocal/win32.py +0 -0
  90. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/logging/tzlocal/windows_tz.py +0 -0
  91. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/plugins_manager_mixin.py +0 -0
  92. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/utils/__init__.py +0 -0
  93. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/utils/comm_utils.py +0 -0
  94. {naeural_client-2.1.2 → naeural_client-2.1.4}/naeural_client/utils/dotenv.py +0 -0
  95. {naeural_client-2.1.2 → naeural_client-2.1.4}/requirements.txt +0 -0
  96. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/8. custom_code_fastapi_assets/index.html +0 -0
  97. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/9. code_sandbox_from_scratch_assets/index.html +0 -0
  98. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/_example_pk_sdk.pem +0 -0
  99. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex01_part1_connect.py +0 -0
  100. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex01_part2_filter.py +0 -0
  101. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex02_first_deploy.py +0 -0
  102. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex03_custom_code_on_one_remote__example_1.py +0 -0
  103. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex04_custom_code_on_one_remote__example_2.py +0 -0
  104. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex05_custom_code_on_one_remote__example_3.py +0 -0
  105. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex06_custom_code_on_multiple_remotes__example_1.py +0 -0
  106. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex07_custom_code_on_multiple_remotes__example_2.py +0 -0
  107. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex08_custom_web_app.py +0 -0
  108. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/ex09_code_sandbox_from_scratch.py +0 -0
  109. {naeural_client-2.1.2 → naeural_client-2.1.4}/tutorials/video_presentation/1. hello_world.ipynb +0 -0
  110. {naeural_client-2.1.2 → naeural_client-2.1.4}/winrun.bat +0 -0
  111. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/.example_env +0 -0
  112. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/README.md +0 -0
  113. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/_archive/test.py +0 -0
  114. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/_tutorials/3. simple_real_time_custom_code.py +0 -0
  115. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/_tutorials/4. real_time_custom_code_2.py +0 -0
  116. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/_tutorials/8. chatbot.py +0 -0
  117. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/attach_example.py +0 -0
  118. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/decentralized/chain_dist_example.py +0 -0
  119. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/decentralized/chain_dist_example_initiator.py +0 -0
  120. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/decentralized/chain_dist_example_worker.py +0 -0
  121. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/ex1.py +0 -0
  122. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/hello.py +0 -0
  123. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/remote_exec.py +0 -0
  124. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/save_images.py +0 -0
  125. {naeural_client-2.1.2 → naeural_client-2.1.4}/xperimental/utils/get_documentation.py +0 -0
@@ -8,7 +8,10 @@
8
8
 
9
9
  name: Publish Python 🐍 distributions 📦 to PyPI
10
10
 
11
- on: push
11
+ on:
12
+ push:
13
+ branches:
14
+ - main
12
15
 
13
16
  jobs:
14
17
  build-n-publish:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: naeural_client
3
- Version: 2.1.2
3
+ Version: 2.1.4
4
4
  Summary: `naeural_client` is the Python SDK required for client app development for the Naeural Edge Protocol Edge Protocol framework
5
5
  Project-URL: Homepage, https://github.com/Naeural Edge ProtocolEdgeProtocol/naeural_client
6
6
  Project-URL: Bug Tracker, https://github.com/Naeural Edge ProtocolEdgeProtocol/naeural_client/issues
@@ -1,4 +1,4 @@
1
- __VER__ = "2.1.2"
1
+ __VER__ = "2.1.4"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -1717,7 +1717,7 @@ class GenericSession(BaseDecentrAIObject):
1717
1717
  *,
1718
1718
  node,
1719
1719
  name,
1720
- signature=PLUGIN_SIGNATURES.BASIC_TELEGRAM_BOT_01,
1720
+ signature=PLUGIN_SIGNATURES.TELEGRAM_BASIC_BOT_01,
1721
1721
  message_handler=None,
1722
1722
  telegram_bot_token=None,
1723
1723
  telegram_bot_token_env_key=ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY,
@@ -1725,7 +1725,41 @@ class GenericSession(BaseDecentrAIObject):
1725
1725
  telegram_bot_name_env_key=ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY,
1726
1726
  **kwargs
1727
1727
  ):
1728
+ """
1729
+ Create a new basic Telegram bot on a node.
1730
+
1731
+ Parameters
1732
+ ----------
1728
1733
 
1734
+ node : str
1735
+ Address or Name of the Naeural Edge Protocol edge node that will handle this Telegram bot.
1736
+
1737
+ name : str
1738
+ Name of the Telegram bot.
1739
+
1740
+ signature : str, optional
1741
+ The signature of the plugin that will be used. Defaults to PLUGIN_SIGNATURES.TELEGRAM_BASIC_BOT_01.
1742
+
1743
+ message_handler : callable, optional
1744
+ The message handler function that will be called when a message is received. Defaults to None.
1745
+
1746
+ telegram_bot_token : str, optional
1747
+ The Telegram bot token. Defaults to None.
1748
+
1749
+ telegram_bot_token_env_key : str, optional
1750
+ The environment variable key that holds the Telegram bot token. Defaults to ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY.
1751
+
1752
+ telegram_bot_name : str, optional
1753
+ The Telegram bot name. Defaults to None.
1754
+
1755
+ telegram_bot_name_env_key : str, optional
1756
+ The environment variable key that holds the Telegram bot name. Defaults to ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY.
1757
+
1758
+ Returns
1759
+ -------
1760
+ tuple
1761
+ `Pipeline` and a `Instance` objects tuple.
1762
+ """
1729
1763
  assert callable(message_handler), "The `message_handler` method parameter must be provided."
1730
1764
 
1731
1765
  if telegram_bot_token is None:
@@ -1765,6 +1799,115 @@ class GenericSession(BaseDecentrAIObject):
1765
1799
  )
1766
1800
  return pipeline, instance
1767
1801
 
1802
+
1803
+ def create_telegram_conversational_bot(
1804
+ self,
1805
+ *,
1806
+ node,
1807
+ name,
1808
+ signature=PLUGIN_SIGNATURES.TELEGRAM_CONVERSATIONAL_BOT_01,
1809
+ telegram_bot_token=None,
1810
+ telegram_bot_token_env_key=ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY,
1811
+ telegram_bot_name=None,
1812
+ telegram_bot_name_env_key=ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY,
1813
+
1814
+ system_prompt=None,
1815
+ agent_type="API",
1816
+ api_token_env_key=ENVIRONMENT.TELEGRAM_API_AGENT_TOKEN_ENV_KEY,
1817
+ api_token=None,
1818
+ rag_source_url=None,
1819
+ **kwargs
1820
+ ):
1821
+
1822
+ """
1823
+ Create a new conversational Telegram bot on a node.
1824
+
1825
+ Parameters
1826
+ ----------
1827
+
1828
+ node : str
1829
+ Address or Name of the Naeural Edge Protocol edge node that will handle this Telegram bot.
1830
+
1831
+ name : str
1832
+ Name of the Telegram bot.
1833
+
1834
+ signature : str, optional
1835
+ The signature of the plugin that will be used. Defaults to PLUGIN_SIGNATURES.TELEGRAM_BASIC_BOT_01.
1836
+
1837
+ telegram_bot_token : str, optional
1838
+ The Telegram bot token. Defaults to None.
1839
+
1840
+ telegram_bot_token_env_key : str, optional
1841
+ The environment variable key that holds the Telegram bot token. Defaults to ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY.
1842
+
1843
+ telegram_bot_name : str, optional
1844
+ The Telegram bot name. Defaults to None.
1845
+
1846
+ telegram_bot_name_env_key : str, optional
1847
+ The environment variable key that holds the Telegram bot name. Defaults to ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY.
1848
+
1849
+ system_prompt : str, optional
1850
+ The system prompt. Defaults to None.
1851
+
1852
+ agent_type : str, optional
1853
+ The agent type. Defaults to "API".
1854
+
1855
+ api_token_env_key : str, optional
1856
+ The environment variable key that holds the API token. Defaults to ENVIRONMENT.TELEGRAM_API_AGENT_TOKEN_ENV_KEY.
1857
+
1858
+ api_token : str, optional
1859
+ The API token. Defaults to None.
1860
+
1861
+ rag_source_url : str, optional
1862
+ The RAG database source URL upon which the bot will be able to generate responses. Defaults to None.
1863
+
1864
+ Returns
1865
+ -------
1866
+ tuple
1867
+ `Pipeline` and a `Instance` objects tuple.
1868
+ """
1869
+ if agent_type == "API":
1870
+ if api_token is None:
1871
+ api_token = os.getenv(api_token_env_key)
1872
+ if api_token is None:
1873
+ message = f"Warning! No API token provided as via env {ENVIRONMENT.TELEGRAM_API_AGENT_TOKEN_ENV_KEY} or explicitly as `api_token` param."
1874
+ raise ValueError(message)
1875
+
1876
+ if telegram_bot_token is None:
1877
+ telegram_bot_token = os.getenv(telegram_bot_token_env_key)
1878
+ if telegram_bot_token is None:
1879
+ message = f"Warning! No Telegram bot token provided as via env {ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY} or explicitly as `telegram_bot_token` param."
1880
+ raise ValueError(message)
1881
+
1882
+ if telegram_bot_name is None:
1883
+ telegram_bot_name = os.getenv(telegram_bot_name_env_key)
1884
+ if telegram_bot_name is None:
1885
+ message = f"Warning! No Telegram bot name provided as via env {ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY} or explicitly as `telegram_bot_name` param."
1886
+ raise ValueError(message)
1887
+
1888
+
1889
+ pipeline: Pipeline = self.create_pipeline(
1890
+ node=node,
1891
+ name=name,
1892
+ # default TYPE is "Void"
1893
+ )
1894
+
1895
+
1896
+ obfuscated_token = telegram_bot_token[:4] + "*" * (len(telegram_bot_token) - 4)
1897
+ self.P(f"Creating telegram bot {telegram_bot_name} with token {obfuscated_token}...", color='b')
1898
+ instance = pipeline.create_plugin_instance(
1899
+ signature=signature,
1900
+ instance_id=self.log.get_unique_id(),
1901
+ telegram_bot_token=telegram_bot_token,
1902
+ telegram_bot_name=telegram_bot_name,
1903
+ system_prompt=system_prompt,
1904
+ agent_type=agent_type,
1905
+ api_token=api_token,
1906
+ rag_source_url=rag_source_url,
1907
+ **kwargs
1908
+ )
1909
+ return pipeline, instance
1910
+
1768
1911
 
1769
1912
  def broadcast_instance_command_and_wait_for_response_payload(
1770
1913
  self,
@@ -7,5 +7,6 @@ class PLUGIN_SIGNATURES:
7
7
  VIEW_SCENE_01 = 'VIEW_SCENE_01'
8
8
  CUSTOM_WEB_APP_01 = 'CUSTOM_CODE_FASTAPI_01'
9
9
  CHAIN_DIST_CUSTOM_JOB_01 = 'PROCESS_REAL_TIME_COLLECTED_DATA_CUSTOM_EXEC_CHAIN_DIST'
10
- BASIC_TELEGRAM_BOT_01 = 'BASIC_TELEGRAM_BOT_01'
10
+ TELEGRAM_BASIC_BOT_01 = 'TELEGRAM_BASIC_BOT_01'
11
+ TELEGRAM_CONVERSATIONAL_BOT_01 = 'TELEGRAM_CONVERSATIONAL_BOT_01'
11
12
  # INSERT_NEW_PLUGIN_HERE
@@ -2,6 +2,17 @@ EE_ID = 'EE_ID'
2
2
  SB_ID = 'SB_ID' # change to SB_ID = EE_ID post mod from sb to ee
3
3
 
4
4
 
5
+ class DCT_TYPES:
6
+ VOID_PIPELINE = 'Void'
7
+ NETWORK_LISTENER = 'NetworkListener'
8
+ METASTREAM_PIPELINE = 'MetaStream'
9
+
10
+
11
+ class DCT_OPTIONS:
12
+ NETWORK_LISTENER_PATH_FILTER = "PATH_FILTER"
13
+ NETWORK_LISTENER_MESSAGE_FILTER = "MESSAGE_FILTER"
14
+ ADMIN_PIPELINE_VER = 'ADMIN_PIPELINE_VER'
15
+
5
16
  class CONFIG_STREAM:
6
17
  K_URL = 'URL'
7
18
  K_TYPE = 'TYPE'
@@ -22,7 +33,7 @@ class CONFIG_STREAM:
22
33
  K_PIPELINE_COMMAND = 'PIPELINE_COMMAND'
23
34
  K_USE_LOCAL_COMMS_ONLY = 'USE_LOCAL_COMMS_ONLY'
24
35
 
25
- METASTREAM = 'MetaStream'
36
+ METASTREAM = DCT_TYPES.METASTREAM_PIPELINE
26
37
 
27
38
  INITIATOR_ID = K_INITIATOR_ID
28
39
  SESSION_ID = K_SESSION_ID
@@ -53,10 +64,14 @@ class CONFIG_STREAM:
53
64
 
54
65
  MANDATORY = [K_NAME, K_TYPE]
55
66
 
56
- VOID_STREAM = 'VOID'
67
+ VOID_STREAM = DCT_TYPES.VOID_PIPELINE
68
+
69
+ DEFAULT_ADMIN_PIPELINE_TYPE = DCT_TYPES.NETWORK_LISTENER
57
70
 
58
71
  NO_DATA_STREAMS = [VOID_STREAM]
59
-
72
+
73
+ PIPELINE_OPTIONS = DCT_OPTIONS
74
+ PIPELINE_TYPES = DCT_TYPES
60
75
 
61
76
  class BIZ_PLUGIN_DATA:
62
77
  INSTANCE_ID = 'INSTANCE_ID'
@@ -31,3 +31,5 @@ class ENVIRONMENT:
31
31
 
32
32
  TELEGRAM_BOT_TOKEN_ENV_KEY = 'TELEGRAM_BOT_TOKEN'
33
33
  TELEGRAM_BOT_NAME_ENV_KEY = 'TELEGRAM_BOT_NAME'
34
+
35
+ TELEGRAM_API_AGENT_TOKEN_ENV_KEY = 'TELEGRAM_API_AGENT_TOKEN'
@@ -181,6 +181,8 @@ class PAYLOAD_DATA:
181
181
  EE_SENDER = BC_CT.SENDER
182
182
  EE_HASH = BC_CT.HASH
183
183
  EE_SIGN = BC_CT.SIGN
184
+
185
+ EE_DESTINATION = "EE_DEST"
184
186
 
185
187
  NOTIFICATION = 'NOTIFICATION'
186
188
  INFO = 'INFO'
@@ -188,3 +190,5 @@ class PAYLOAD_DATA:
188
190
  TAGS = 'TAGS'
189
191
 
190
192
  ID_TAGS = 'ID_TAGS'
193
+
194
+
@@ -2,7 +2,7 @@ from .net_mon_01_plugin import NetMon01
2
2
  from .view_scene_01_plugin import ViewScene01
3
3
  from .custom_web_app_01_plugin import CustomWebApp01
4
4
  from .chain_dist_custom_job_01_plugin import ChainDistCustomJob01
5
- from .basic_telegram_bot_01_plugin import BasicTelegramBot01
5
+ from .telegram_basic_bot_01_plugin import BasicTelegramBot01
6
6
 
7
7
 
8
8
  class PLUGIN_TYPES:
@@ -13,4 +13,4 @@ class PLUGIN_TYPES:
13
13
  VIEW_SCENE_01 = ViewScene01
14
14
  CUSTOM_WEB_APP_01 = CustomWebApp01
15
15
  CHAIN_DIST_CUSTOM_JOB_01 = ChainDistCustomJob01
16
- BASIC_TELEGRAM_BOT_01 = BasicTelegramBot01
16
+ TELEGRAM_BASIC_BOT_01 = BasicTelegramBot01
@@ -2,6 +2,6 @@ from ...base import Instance
2
2
  from ...const import PLUGIN_SIGNATURES
3
3
 
4
4
  class BasicTelegramBot01(Instance):
5
- signature = PLUGIN_SIGNATURES.BASIC_TELEGRAM_BOT_01
5
+ signature = PLUGIN_SIGNATURES.TELEGRAM_BASIC_BOT_01
6
6
 
7
7
 
@@ -0,0 +1,7 @@
1
+ from ...base import Instance
2
+ from ...const import PLUGIN_SIGNATURES
3
+
4
+ class TelegramConversationalBot01(Instance):
5
+ signature = PLUGIN_SIGNATURES.TELEGRAM_CONVERSATIONAL_BOT_01
6
+
7
+
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "naeural_client"
7
- version = "2.1.2"
7
+ version = "2.1.4"
8
8
  authors = [
9
9
  { name="Stefan Saraev", email="saraevstefan@gmail.com" },
10
10
  { name="Andrei Ionut Damian", email="andrei.damian@me.com" },
@@ -4,3 +4,5 @@ EE_PASSWORD=TODO: fill this variable
4
4
  EE_HOSTNAME=r9092118.ala.eu-central-1.emqxsl.com
5
5
  EE_PORT=8883
6
6
  EE_SECURED=true
7
+
8
+ TARGET_NODE=0xai....
@@ -19,21 +19,14 @@ if __name__ == "__main__":
19
19
  my_node = os.getenv("TARGET_NODE") # we can specify a node here, if we want to connect to a specific
20
20
 
21
21
  session = Session() # assume .env is available and will be used for the connection and tokens
22
- time.sleep(10) # wait 10 sec to collect network status
23
-
24
- if my_node:
25
- node = my_node
26
- session.P(f"Using the specified node: {node}", color='b')
27
- else:
28
- session.wait_for_any_node() # we wait for any node to present itself as active
29
- node = session.get_active_nodes()[0] # we get the first active node
30
-
22
+ session.wait_for_node(my_node) # wait for the node to be active
23
+
31
24
 
32
25
  # now we create a telegram bot pipeline & plugin instance
33
26
  # we can chose to use the token directly or use the environment key
34
- # instance: PLUGIN_TYPES.BASIC_TELEGRAM_BOT_01
27
+ # instance: PLUGIN_TYPES.TELEGRAM_BASIC_BOT_01
35
28
  pipeline, _ = session.create_telegram_simple_bot(
36
- node=node,
29
+ node=my_node,
37
30
  name="telegram_bot_echo",
38
31
  # telegram_bot_token=os.getenv("TELEGRAM_BOT_TOKEN"), # we use the token directly
39
32
  # telegram_bot_token_env_key=TELEGRAM_BOT_TOKEN_ENV_KEY, # not mandatory - we can use the default
@@ -0,0 +1,203 @@
1
+ import os
2
+ import time
3
+
4
+ from naeural_client import Session, CustomPluginTemplate
5
+
6
+ def reply(plugin, message: str, user: str):
7
+ # Define the deck of cards and their values
8
+ cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10',
9
+ 'Jack', 'Queen', 'King', 'Ace']
10
+ card_values = {
11
+ '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7,
12
+ '8': 8, '9': 9, '10': 10,
13
+ 'Jack': 10, 'Queen': 10, 'King': 10,
14
+ 'Ace': 11 # Ace is treated as 11 initially; we'll adjust as needed
15
+ }
16
+
17
+ # Initialize user state if not already present
18
+ if user not in plugin.obj_cache or plugin.obj_cache[user] is None:
19
+ plugin.obj_cache[user] = {
20
+ 'state': 'NOT_STARTED',
21
+ 'wins': 0,
22
+ 'losses': 0
23
+ }
24
+
25
+ # Retrieve the user's game state
26
+ user_cache = plugin.obj_cache[user]
27
+ message = message.strip().lower() # Normalize the input message
28
+
29
+ if user_cache.get('state') == 'NOT_STARTED':
30
+ if message == 'card' or message == 'start':
31
+ # Start a new game
32
+ user_cache['hand'] = [] # Initialize player's hand
33
+ user_cache['state'] = 'PLAYING'
34
+
35
+ # Deal the first card
36
+ card = plugin.np.random.choice(cards)
37
+ user_cache['hand'].append(card)
38
+
39
+ # Calculate hand value
40
+ total = 0
41
+ aces = 0 # Count of aces in hand
42
+ for c in user_cache['hand']:
43
+ if c == 'Ace':
44
+ aces += 1
45
+ else:
46
+ total += card_values[c]
47
+ # Adjust for aces
48
+ for _ in range(aces):
49
+ if total + 11 <= 21:
50
+ total += 11 # Count ace as 11 if it doesn't cause bust
51
+ else:
52
+ total += 1 # Otherwise, count ace as 1
53
+
54
+ # Return the initial game message
55
+ return (f"Welcome to a new game of Black Jack, you have a {card}. "
56
+ f"Your total is {total}. Type 'card' to get another card, or 'stop' to hold.")
57
+ else:
58
+ # Prompt user to start a new game
59
+ return "Welcome to Black Jack. Type 'card' to start a new game."
60
+
61
+ elif user_cache.get('state') == 'PLAYING':
62
+ if message == 'card':
63
+ # Player chooses to draw another card
64
+ card = plugin.np.random.choice(cards)
65
+ user_cache['hand'].append(card)
66
+
67
+ # Recalculate hand value
68
+ total = 0
69
+ aces = 0
70
+ for c in user_cache['hand']:
71
+ if c == 'Ace':
72
+ aces += 1
73
+ else:
74
+ total += card_values[c]
75
+ for _ in range(aces):
76
+ if total + 11 <= 21:
77
+ total += 11
78
+ else:
79
+ total += 1
80
+
81
+ hand_str = ', '.join(user_cache['hand']) # Format hand as a string
82
+
83
+ if total > 21:
84
+ # Player busts
85
+ user_cache['state'] = 'BUST'
86
+ user_cache['losses'] += 1 # Increment losses
87
+ return (f"You are given a {card}. Your hand: {hand_str}. "
88
+ f"Your total is {total}. Bust! You lose.\n"
89
+ f"Total Wins: {user_cache['wins']}, Total Losses: {user_cache['losses']}")
90
+ elif total == 21:
91
+ # Player hits Black Jack
92
+ user_cache['state'] = 'BLACKJACK'
93
+ user_cache['wins'] += 1 # Increment wins
94
+ return (f"You are given a {card}. Black Jack! Congratulations, you win! "
95
+ f"Your hand: {hand_str}.\n"
96
+ f"Total Wins: {user_cache['wins']}, Total Losses: {user_cache['losses']}")
97
+ else:
98
+ # Continue playing
99
+ return (f"You are given a {card}. Your hand: {hand_str}. "
100
+ f"Your total is {total}. Type 'card' to get another card, or 'stop' to hold.")
101
+ elif message == 'stop':
102
+ # Player chooses to hold; dealer's turn
103
+ dealer_hand = []
104
+ dealer_total = 0
105
+ dealer_aces = 0
106
+
107
+ # Dealer draws cards until total >= 17
108
+ while True:
109
+ dealer_card = plugin.np.random.choice(cards)
110
+ dealer_hand.append(dealer_card)
111
+
112
+ # Update dealer's total
113
+ if dealer_card == 'Ace':
114
+ dealer_aces += 1
115
+ else:
116
+ dealer_total += card_values[dealer_card]
117
+
118
+ # Calculate dealer's total considering aces
119
+ temp_total = dealer_total
120
+ aces = dealer_aces
121
+ for _ in range(aces):
122
+ if temp_total + 11 <= 21:
123
+ temp_total += 11
124
+ else:
125
+ temp_total += 1
126
+
127
+ dealer_total_with_aces = temp_total
128
+
129
+ # Dealer stops hitting when total >= 17
130
+ if dealer_total_with_aces >= 17:
131
+ dealer_total = dealer_total_with_aces
132
+ break
133
+ else:
134
+ dealer_total = dealer_total_with_aces
135
+
136
+ # Calculate player's total
137
+ player_total = 0
138
+ player_aces = 0
139
+ for c in user_cache['hand']:
140
+ if c == 'Ace':
141
+ player_aces += 1
142
+ else:
143
+ player_total += card_values[c]
144
+ for _ in range(player_aces):
145
+ if player_total + 11 <= 21:
146
+ player_total += 11
147
+ else:
148
+ player_total += 1
149
+
150
+ user_cache['state'] = 'GAME_OVER' # Update game state
151
+
152
+ # Determine the outcome
153
+ if dealer_total > 21:
154
+ result = "Dealer busts! You win!"
155
+ user_cache['wins'] += 1
156
+ elif player_total > dealer_total:
157
+ result = "You win!"
158
+ user_cache['wins'] += 1
159
+ elif player_total == dealer_total:
160
+ result = "It's a tie!"
161
+ # Ties are not counted as wins or losses
162
+ else:
163
+ result = "You lose!"
164
+ user_cache['losses'] += 1
165
+
166
+ player_hand_str = ', '.join(user_cache['hand'])
167
+ dealer_hand_str = ', '.join(dealer_hand)
168
+
169
+ # Return the game result with total wins and losses
170
+ return (f"You stopped with {player_total}. Your hand: {player_hand_str}.\n"
171
+ f"Dealer's hand: {dealer_hand_str} (Total: {dealer_total}).\n"
172
+ f"{result}\nTotal Wins: {user_cache['wins']}, Total Losses: {user_cache['losses']}")
173
+ else:
174
+ # Invalid input during playing
175
+ return "Invalid input. Please type 'card' to get another card, or 'stop' to hold."
176
+
177
+ elif user_cache.get('state') in ['BUST', 'BLACKJACK', 'GAME_OVER']:
178
+ # Game is over; reset state for a new game
179
+ user_cache['state'] = 'NOT_STARTED'
180
+ return "Game over. Type 'card' to start a new game."
181
+
182
+ else:
183
+ # Catch-all for unexpected state
184
+ return "An error occurred. Please start a new game."
185
+
186
+
187
+
188
+ if __name__ == "__main__":
189
+ my_node = os.getenv("TARGET_NODE") # we can specify a node here, if we want to connect to a specific
190
+
191
+ session = Session() # assume .env is available and will be used for the connection and tokens
192
+ session.wait_for_node(my_node) # wait for the node to be active
193
+
194
+
195
+ pipeline, _ = session.create_telegram_simple_bot(
196
+ node=my_node,
197
+ name="telegram_bot_blackjack",
198
+ message_handler=reply,
199
+ )
200
+
201
+ pipeline.deploy() # we deploy the pipeline
202
+
203
+
@@ -0,0 +1,48 @@
1
+ import os
2
+ import time
3
+
4
+ from naeural_client import Session, CustomPluginTemplate
5
+
6
+ if __name__ == "__main__":
7
+ my_node = os.getenv("TARGET_NODE") # we specify a node here
8
+
9
+ if my_node is None:
10
+ print("Please specify the node to connect to.")
11
+ exit(1)
12
+
13
+ SYSTEM_PROMPT = """
14
+ Hi! I am a simple echo bot. I will repeat everything you say to me.
15
+ """
16
+
17
+ session = Session() # assume .env is available and will be used for the connection and tokens
18
+ session.wait_for_node(my_node) # wait for the node to be active
19
+
20
+
21
+ # now we create a telegram bot pipeline & plugin instance
22
+ # we can chose to use the token directly or use the environment key
23
+ pipeline, _ = session.create_telegram_conversational_bot(
24
+ node=my_node,
25
+ name="telegram_chatbot",
26
+
27
+ # telegram_bot_token=None, # not mantatory - can be used to specify the token directly
28
+ # telegram_bot_token_env_key=ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY, # not mandatory - we can use the default
29
+ # telegram_bot_name=None, # not mandatory - can be used to specify the bot name directly
30
+ # telegram_bot_name_env_key=ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY, # not mandatory - we can use the default
31
+
32
+ system_prompt=SYSTEM_PROMPT, # simple bot based on system prompt only
33
+ agent_type="API", # "API", "HOSTED"
34
+ # api_token_env_key=ENVIRONMENT.TELEGRAM_API_AGENT_TOKEN_ENV_KEY, # not mandatory - we can use the default
35
+ # api_token=None, # not mandatory - can be used to specify the token directly
36
+ rag_source_url=None, # no rag source for this example
37
+ )
38
+
39
+ pipeline.deploy() # we deploy the pipeline
40
+
41
+ # # Observation:
42
+ # # next code is not mandatory - it is used to keep the session open and cleanup the resources
43
+ # # in production, you would not need this code as the script can close after the pipeline will be sent
44
+ # session.run(
45
+ # wait=60, # we run the session for 60 seconds
46
+ # close_pipelines=True, # we close the pipelines after the session
47
+ # close_session=True, # we close the session after the session
48
+ # )
@@ -1,44 +0,0 @@
1
- import os
2
-
3
- from naeural_client import Session, CustomPluginTemplate, PLUGIN_TYPES
4
-
5
- if __name__ == "__main__":
6
- # TELEGRAM_BOT_TOKEN_ENV_KEY = "TELEGRAM_BOT_TOKEN" # we can specify the token here
7
- MY_NODE = None # we can specify a node here, if we want to connect to a specific
8
-
9
- SYSTEM_PROMPT = """
10
- Hi! I am a simple echo bot. I will repeat everything you say to me.
11
- """
12
-
13
- session = Session() # assume .env is available and will be used for the connection and tokens
14
-
15
- if MY_NODE:
16
- node = MY_NODE
17
- else:
18
- session.wait_for_any_node() # we wait for any node to present itself as active
19
- node = session.get_active_nodes()[0] # we get the first active node
20
-
21
-
22
- # now we create a telegram bot pipeline & plugin instance
23
- # we can chose to use the token directly or use the environment key
24
- # instance: PLUGIN_TYPES.BASIC_TELEGRAM_BOT_01
25
- pipeline, _ = session.create_telegram_conversational_bot(
26
- node=node,
27
- name="telegram_bot_echo",
28
- # telegram_bot_token_env_key=TELEGRAM_BOT_TOKEN_ENV_KEY, # this is not mandatory
29
- system_prompt=SYSTEM_PROMPT, # simple bot based on system prompt only
30
- # rag_source=rag_db_url, # advanced
31
- # bot_type="API" # "API", "HOSTED"
32
- # api_token_env_key="BOT_API_TOKEN", # if bot_type is "API" - this is a default
33
- )
34
-
35
- pipeline.deploy() # we deploy the pipeline
36
-
37
- # # Observation:
38
- # # next code is not mandatory - it is used to keep the session open and cleanup the resources
39
- # # in production, you would not need this code as the script can close after the pipeline will be sent
40
- # session.run(
41
- # wait=60, # we run the session for 60 seconds
42
- # close_pipelines=True, # we close the pipelines after the session
43
- # close_session=True, # we close the session after the session
44
- # )
File without changes
File without changes
File without changes