diff --git a/docs/source/conf.py b/docs/source/conf.py index 427bfdc93..1cb8123b2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -146,7 +146,7 @@ ] -autodoc_default_options = {"members": True, "undoc-members": False, "private-members": False} +autodoc_default_options = {"members": True, "undoc-members": False, "private-members": True} def setup(_): diff --git a/docs/source/utils/notebook.py b/docs/source/utils/notebook.py index 587faeba1..a5341d715 100644 --- a/docs/source/utils/notebook.py +++ b/docs/source/utils/notebook.py @@ -77,17 +77,22 @@ class DocumentationLink(ReplacePattern): USAGE EXAMPLES -------------- - [link](%doclink(api,script.core.script)) + %doclink(api,index_pipeline)) -> ../apiref/index_pipeline.rst - [link](%doclink(api,script.core.script,Node)) + %doclink(api,script.core.script) -> ../apiref/dff.script.core.script.rst - [link](%doclink(tutorial,messengers.web_api_interface.4_streamlit_chat)) + %doclink(api,script.core.script,Node) -> ../apiref/dff.script.core.script.rst#dff.script.core.script.Node - [link](%doclink(tutorial,messengers.web_api_interface.4_streamlit_chat,API-configuration)) + %doclink(tutorial,messengers.web_api_interface.4_streamlit_chat)) -> + ../tutorials/tutorials.messengers.web_api_interface.4_streamlit_chat.py - [link](%doclink(guide,basic_conceptions)) + %doclink(tutorial,messengers.web_api_interface.4_streamlit_chat,API-configuration) -> + ../tutorials/tutorials.messengers.web_api_interface.4_streamlit_chat.py#API-configuration - [link](%doclink(guide,basic_conceptions,example-conversational-chat-bot)) + %doclink(guide,basic_conceptions) -> ../user_guides/basic_conceptions.rst + + %doclink(guide,basic_conceptions,example-conversational-chat-bot) -> + ../user_guides/basic_conceptions.rst#example-conversational-chat-bot """ @@ -117,6 +122,9 @@ def link_to_doc_page( To link to the basic script tutorial, pass "script.core.1_basics" (without the "tutorials" prefix). To link to the basic concepts guide, pass "basic_conceptions". + + API index pages are also supported. + Passing "index_pipeline" will link to the "apiref/index_pipeline.html" page. :param anchor: An anchor on the page. (optional) @@ -129,7 +137,8 @@ def link_to_doc_page( A link to the corresponding documentation part. """ if page_type == "api": - return f"../apiref/dff.{page}.rst" + (f"#dff.{page}.{anchor}" if anchor is not None else "") + prefix = "" if page.startswith("index") else "dff." + return f"../apiref/{prefix}{page}.rst" + (f"#{prefix}{page}.{anchor}" if anchor is not None else "") elif page_type == "tutorial": return f"../tutorials/tutorials.{page}.py" + (f"#{anchor}" if anchor is not None else "") elif page_type == "guide": @@ -141,8 +150,58 @@ def replacement_string(matchobj: re.Match) -> str: return DocumentationLink.link_to_doc_page(*args) +class MarkdownDocumentationLink(DocumentationLink): + """ + Replace documentation linking directives with markdown-style links. + + Replace strings of the `%mddoclink({args})` format with corresponding links to local files. + + `args` is a comma-separated string of arguments to pass to the :py:meth:`.DocumentationLink.link_to_doc_page`. + + So, `%mddoclink(arg1,arg2,arg3)` will be replaced with `[text](link_to_doc_page(arg1, arg2, arg3))`, and + `%doclink(arg1,arg2)` will be replaced with `[text](link_to_doc_page(arg1, arg2))` with `text` being the last + path segment of the last argument. + + USAGE EXAMPLES + -------------- + + %mddoclink(api,index_pipeline) -> [index_pipeline]( + ../apiref/index_pipeline.rst + ) + + %mddoclink(api,script.core.script,Node) -> [Node]( + ../apiref/dff.script.core.script.rst#dff.script.core.script.Node + ) + + %mddoclink(tutorial,messengers.web_api_interface.4_streamlit_chat) -> [4_streamlit_chat]( + ../tutorials/tutorials.messengers.web_api_interface.4_streamlit_chat.py + ) + + %mddoclink(tutorial,messengers.web_api_interface.4_streamlit_chat,API-configuration) -> [API-configuration]( + ../tutorials/tutorials.messengers.web_api_interface.4_streamlit_chat.py#API-configuration + ) + + %mddoclink(guide,basic_conceptions) -> [basic_conceptions]( + ../user_guides/basic_conceptions.rst + ) + + %mddoclink(guide,basic_conceptions,example-conversational-chat-bot) -> [example-conversational-chat-bot]( + ../user_guides/basic_conceptions.rst#example-conversational-chat-bot + ) + + """ + + pattern: ClassVar[re.Pattern] = re.compile(r"%mddoclink\((.+?)\)") + + @staticmethod + def replacement_string(matchobj: re.Match) -> str: + args = matchobj.group(1).split(",") + link_text = args[-1].split(".")[-1] + return f"[{link_text}]({DocumentationLink.link_to_doc_page(*args)})" + + def apply_replace_patterns(text: str) -> str: - for cls in (InstallationCell, DocumentationLink): + for cls in (InstallationCell, DocumentationLink, MarkdownDocumentationLink): text = cls.replace(text) return text diff --git a/tests/tutorials/test_format.py b/tests/tutorials/test_format.py index 29bbbd639..772a059bd 100644 --- a/tests/tutorials/test_format.py +++ b/tests/tutorials/test_format.py @@ -13,7 +13,7 @@ re.compile(r"# %%\n"), # check python block ] -docstring_start_pattern = re.compile(r'# %% \[markdown\]\n"""\n#(?: .*:)? \d+\. .*\n(?:\n[\S\s]*)?"""\n') +docstring_start_pattern = re.compile(r'# %% \[markdown\]\n"""\n#(?: .*:)? \d+\. .*\n(?:\n[\S\s]*)?"""(?: # .*)?\n') comment_start_pattern = re.compile(r'# %% \[markdown\]\n# #(?: .*:)? \d+\. .*\n#(?:\n# [\S\s]*)?') diff --git a/tutorials/context_storages/1_basics.py b/tutorials/context_storages/1_basics.py index 5a009a30f..08cb4aee4 100644 --- a/tutorials/context_storages/1_basics.py +++ b/tutorials/context_storages/1_basics.py @@ -3,6 +3,11 @@ # 1. Basics The following tutorial shows the basic use of the database connection. + +See %mddoclink(api,context_storages.database,context_storage_factory) function +for creating a context storage by path. + +In this example JSON file is used as a storage. """ # %pip install dff[json,pickle] diff --git a/tutorials/context_storages/2_postgresql.py b/tutorials/context_storages/2_postgresql.py index 57693cbd1..4a9268575 100644 --- a/tutorials/context_storages/2_postgresql.py +++ b/tutorials/context_storages/2_postgresql.py @@ -3,6 +3,13 @@ # 2. PostgreSQL This is a tutorial on using PostgreSQL. + +See %mddoclink(api,context_storages.sql,SQLContextStorage) class +for storing your users' contexts in SQL databases. + +DFF uses [sqlalchemy](https://docs.sqlalchemy.org/en/20/) +and [asyncpg](https://magicstack.github.io/asyncpg/current/) +libraries for asynchronous access to PostgreSQL DB. """ # %pip install dff[postgresql] diff --git a/tutorials/context_storages/3_mongodb.py b/tutorials/context_storages/3_mongodb.py index f95b0ab08..f55ae3fbb 100644 --- a/tutorials/context_storages/3_mongodb.py +++ b/tutorials/context_storages/3_mongodb.py @@ -3,6 +3,12 @@ # 3. MongoDB This is a tutorial on using MongoDB. + +See %mddoclink(api,context_storages.mongo,MongoContextStorage) class +for storing you users' contexts in Mongo database. + +DFF uses [motor](https://motor.readthedocs.io/en/stable/) +library for asynchronous access to MongoDB. """ # %pip install dff[mongodb] diff --git a/tutorials/context_storages/4_redis.py b/tutorials/context_storages/4_redis.py index bb3ced51a..99c5457e0 100644 --- a/tutorials/context_storages/4_redis.py +++ b/tutorials/context_storages/4_redis.py @@ -3,6 +3,12 @@ # 4. Redis This is a tutorial on using Redis. + +See %mddoclink(api,context_storages.redis,RedisContextStorage) class +for storing you users' contexts in Redis database. + +DFF uses [redis.asyncio](https://redis.readthedocs.io/en/latest/) +library for asynchronous access to Redis DB. """ # %pip install dff[redis] diff --git a/tutorials/context_storages/5_mysql.py b/tutorials/context_storages/5_mysql.py index 8243f4d06..aed04712a 100644 --- a/tutorials/context_storages/5_mysql.py +++ b/tutorials/context_storages/5_mysql.py @@ -3,6 +3,13 @@ # 5. MySQL This is a tutorial on using MySQL. + +See %mddoclink(api,context_storages.sql,SQLContextStorage) class +for storing you users' contexts in SQL databases. + +DFF uses [sqlalchemy](https://docs.sqlalchemy.org/en/20/) +and [asyncmy](https://github.com/long2ice/asyncmy) +libraries for asynchronous access to MySQL DB. """ # %pip install dff[mysql] diff --git a/tutorials/context_storages/6_sqlite.py b/tutorials/context_storages/6_sqlite.py index 995ef4c3b..8d7e0b53b 100644 --- a/tutorials/context_storages/6_sqlite.py +++ b/tutorials/context_storages/6_sqlite.py @@ -3,6 +3,15 @@ # 6. SQLite This is a tutorial on using SQLite. + +See %mddoclink(api,context_storages.sql,SQLContextStorage) class +for storing you users' contexts in SQL databases. + +DFF uses [sqlalchemy](https://docs.sqlalchemy.org/en/20/) +and [aiosqlite](https://readthedocs.org/projects/aiosqlite/) +libraries for asynchronous access to SQLite DB. + +Note that protocol separator for windows differs from one for linux. """ # %pip install dff[sqlite] diff --git a/tutorials/context_storages/7_yandex_database.py b/tutorials/context_storages/7_yandex_database.py index 75cb54f42..247490041 100644 --- a/tutorials/context_storages/7_yandex_database.py +++ b/tutorials/context_storages/7_yandex_database.py @@ -3,6 +3,12 @@ # 7. Yandex DataBase This is a tutorial on how to use Yandex DataBase. + +See %mddoclink(api,context_storages.ydb,YDBContextStorage) class +for storing you users' contexts in Yandex database. + +DFF uses [ydb.aio](https://ydb.tech/en/docs/) +library for asynchronous access to Yandex DB. """ # %pip install dff[ydb] diff --git a/tutorials/context_storages/8_db_benchmarking.py b/tutorials/context_storages/8_db_benchmarking.py index 6793e6ac7..2c88de3ee 100644 --- a/tutorials/context_storages/8_db_benchmarking.py +++ b/tutorials/context_storages/8_db_benchmarking.py @@ -50,34 +50,28 @@ Benchmark results are saved to files. For that there exist two functions: -[benchmark_all]( -%doclink(api,utils.db_benchmark.benchmark,benchmark_all) -) +%mddoclink(api,utils.db_benchmark.benchmark,benchmark_all) and -[save_results_to_file]( -%doclink(api,utils.db_benchmark.benchmark,save_results_to_file) -). +%mddoclink(api,utils.db_benchmark.benchmark,save_results_to_file). Note: context storages passed into these functions will be cleared. ### Configuration The first one is a higher-level wrapper of the second one. -The first function accepts [BenchmarkCases]( -%doclink(api,utils.db_benchmark.benchmark,BenchmarkCase) -) which configure databases that are being benchmark and configurations of the benchmarks. +The first function accepts +%mddoclink(api,utils.db_benchmark.benchmark,BenchmarkCase) +which configure databases that are being benchmark and configurations of the benchmarks. The second function accepts only a single URI for the database and several benchmark configurations. So, the second function is simpler to use, while the first function allows for more configuration (e.g. having different databases benchmarked in a single file). -Both function use [BenchmarkConfig]( -%doclink(api,utils.db_benchmark.benchmark,BenchmarkConfig) -) to configure benchmark behaviour. +Both function use +%mddoclink(api,utils.db_benchmark.benchmark,BenchmarkConfig) +to configure benchmark behaviour. `BenchmarkConfig` is only an interface for benchmark configurations. Its most basic implementation is -[BasicBenchmarkConfig]( -%doclink(api,utils.db_benchmark.basic_config,BasicBenchmarkConfig) -). +%mddoclink(api,utils.db_benchmark.basic_config,BasicBenchmarkConfig). It has several parameters: @@ -125,9 +119,9 @@ """ ## Viewing benchmark results -Now that the results are saved to a file you can either view them using [report]( -%doclink(api,utils.db_benchmark.report,report) -) function or [our streamlit app]( +Now that the results are saved to a file you can either view them using the +%mddoclink(api,utils.db_benchmark.report,report) +function or [our streamlit app]( ../_misc/benchmark_streamlit.py ). """ @@ -187,21 +181,24 @@ ### Configuration presets -The [dff.utils.db_benchmarks.basic_config]( -%doclink(api,utils.db_benchmark.basic_config) -) module also includes a dictionary containing configuration presets. +The +%mddoclink(api,utils.db_benchmark.basic_config) +module also includes a dictionary containing configuration presets. Those cover various contexts and messages as well as some edge cases. - -To use configuration presets, simply pass them to benchmark functions. """ # %% -print(benchmark.basic_configurations.keys()) +print(benchmark.basic_config.basic_configurations.keys()) -# benchmark.benchmark_all( -# ..., -# benchmark_configs=benchmark.basic_configurations -# ) +# %% [markdown] +""" +To use configuration presets, simply pass them to benchmark functions: + + benchmark.benchmark_all( + ..., + benchmark_configs=benchmark.basic_configurations + ) +""" # %% [markdown] """ @@ -209,9 +206,9 @@ If the basic configuration is not enough for you, you can create your own. -To do so, inherit from the [dff.utils.db_benchmark.benchmark.BenchmarkConfig]( -%doclink(api,utils.db_benchmark.benchmark,BenchmarkConfig) -) class. You need to define three methods: +To do so, inherit from the +%mddoclink(api,utils.db_benchmark.benchmark,BenchmarkConfig) +class. You need to define three methods: - `get_context` -- method to get initial contexts. - `info` -- method for getting display info representing the configuration. diff --git a/tutorials/messengers/telegram/1_basic.py b/tutorials/messengers/telegram/1_basic.py index 81855bde5..c209e54c7 100644 --- a/tutorials/messengers/telegram/1_basic.py +++ b/tutorials/messengers/telegram/1_basic.py @@ -4,6 +4,12 @@ The following tutorial shows how to run a regular DFF script in Telegram. It asks users for the '/start' command and then loops in one place. + +Here, %mddoclink(api,messengers.telegram.interface,PollingTelegramInterface) +class and [telebot](https://pytba.readthedocs.io/en/latest/index.html) +library are used for accessing telegram API in polling mode. + +Telegram API token is required to access telegram API. """ # %pip install dff[telegram] diff --git a/tutorials/messengers/telegram/2_buttons.py b/tutorials/messengers/telegram/2_buttons.py index d395c75e1..b803d02e2 100644 --- a/tutorials/messengers/telegram/2_buttons.py +++ b/tutorials/messengers/telegram/2_buttons.py @@ -2,10 +2,20 @@ """ # Telegram: 2. Buttons - This tutorial shows how to display and hide a basic keyboard in Telegram. + +Here, %mddoclink(api,messengers.telegram.message,TelegramMessage) +class is used to represent telegram message, +%mddoclink(api,messengers.telegram.message,TelegramUI) and +%mddoclink(api,messengers.telegram.message,RemoveKeyboard) +classes are used for configuring additional telegram message features. + +Different %mddoclink(api,script.core.message,message) +classes are used for representing different common message features, +like Attachment, Audio, Button, Image, etc. """ + # %pip install dff[telegram] # %% diff --git a/tutorials/messengers/telegram/3_buttons_with_callback.py b/tutorials/messengers/telegram/3_buttons_with_callback.py index c3ecf4d70..ac55d0085 100644 --- a/tutorials/messengers/telegram/3_buttons_with_callback.py +++ b/tutorials/messengers/telegram/3_buttons_with_callback.py @@ -2,11 +2,21 @@ """ # Telegram: 3. Buttons with Callback - This tutorial demonstrates, how to add an inline keyboard and utilize inline queries. + +Here, %mddoclink(api,messengers.telegram.message,TelegramMessage) +class is used to represent telegram message, +%mddoclink(api,messengers.telegram.message,TelegramUI) and +%mddoclink(api,messengers.telegram.message,RemoveKeyboard) +classes are used for configuring additional telegram message features. + +Different %mddoclink(api,script.core.message,message) +classes are used for representing different common message features, +like Attachment, Audio, Button, Image, etc. """ + # %pip install dff[telegram] # %% diff --git a/tutorials/messengers/telegram/4_conditions.py b/tutorials/messengers/telegram/4_conditions.py index 1a49b2f09..81d4dc830 100644 --- a/tutorials/messengers/telegram/4_conditions.py +++ b/tutorials/messengers/telegram/4_conditions.py @@ -4,8 +4,12 @@ This tutorial shows how to process Telegram updates in your script and reuse handler triggers from the `pytelegrambotapi` library. + +Here, %mddoclink(api,messengers.telegram.messenger,telegram_condition) +function is used for graph navigation according to Telegram events. """ + # %pip install dff[telegram] # %% diff --git a/tutorials/messengers/telegram/5_conditions_with_media.py b/tutorials/messengers/telegram/5_conditions_with_media.py index 49c02f921..08fc4eb94 100644 --- a/tutorials/messengers/telegram/5_conditions_with_media.py +++ b/tutorials/messengers/telegram/5_conditions_with_media.py @@ -3,8 +3,16 @@ # Telegram: 5. Conditions with Media This tutorial shows how to use media-related logic in your script. + +Here, %mddoclink(api,messengers.telegram.messenger,telegram_condition) +function is used for graph navigation according to Telegram events. + +Different %mddoclink(api,script.core.message,message) +classes are used for representing different common message features, +like Attachment, Audio, Button, Image, etc. """ + # %pip install dff[telegram] # %% diff --git a/tutorials/messengers/telegram/6_conditions_extras.py b/tutorials/messengers/telegram/6_conditions_extras.py index bc1ef5e6a..aca4131ed 100644 --- a/tutorials/messengers/telegram/6_conditions_extras.py +++ b/tutorials/messengers/telegram/6_conditions_extras.py @@ -4,8 +4,13 @@ This tutorial shows how to use additional update filters inherited from the `pytelegrambotapi` library. + +%mddoclink(api,messengers.telegram.messenger,telegram_condition) +function and different types of %mddoclink(api,messengers.telegram.messenger,UpdateType) +are used for telegram message type checking. """ + # %pip install dff[telegram] # %% diff --git a/tutorials/messengers/telegram/7_polling_setup.py b/tutorials/messengers/telegram/7_polling_setup.py index 68a2b1f0a..f513a2438 100644 --- a/tutorials/messengers/telegram/7_polling_setup.py +++ b/tutorials/messengers/telegram/7_polling_setup.py @@ -4,6 +4,8 @@ The following tutorial shows how to configure `PollingTelegramInterface`. +See %mddoclink(api,messengers.telegram.interface,PollingTelegramInterface) +for more information. """ # %pip install dff[telegram] diff --git a/tutorials/messengers/telegram/8_webhook_setup.py b/tutorials/messengers/telegram/8_webhook_setup.py index 709cf5e3e..2590e2224 100644 --- a/tutorials/messengers/telegram/8_webhook_setup.py +++ b/tutorials/messengers/telegram/8_webhook_setup.py @@ -4,6 +4,9 @@ The following tutorial shows how to use `CallbackTelegramInterface` that makes your bot accessible through a public webhook. + +See %mddoclink(api,messengers.common.interface,CallbackMessengerInterface) +for more information. """ # %pip install dff[telegram] flask diff --git a/tutorials/messengers/web_api_interface/1_fastapi.py b/tutorials/messengers/web_api_interface/1_fastapi.py index 77ca50c62..73df867a1 100644 --- a/tutorials/messengers/web_api_interface/1_fastapi.py +++ b/tutorials/messengers/web_api_interface/1_fastapi.py @@ -5,6 +5,11 @@ This tutorial shows how to create an API for DFF using FastAPI. You can see the result at http://127.0.0.1:8000/docs. + +Here, `_run_pipeline` (same as %mddoclink(api,pipeline.pipeline.pipeline,Pipeline.run)) +method is used to execute pipeline once. + +%mddoclink(api,script.core.message,Message) is used in creating a JSON Schema for the endpoint. """ # %pip install dff uvicorn fastapi diff --git a/tutorials/messengers/web_api_interface/2_websocket_chat.py b/tutorials/messengers/web_api_interface/2_websocket_chat.py index 40efce5f5..3153d77ce 100644 --- a/tutorials/messengers/web_api_interface/2_websocket_chat.py +++ b/tutorials/messengers/web_api_interface/2_websocket_chat.py @@ -14,6 +14,11 @@ > ... for this example, we'll use a very simple HTML document with some JavaScript, > all inside a long string. > This, of course, is not optimal and you wouldn't use it for production. + +Here, `_run_pipeline` (same as %mddoclink(api,pipeline.pipeline.pipeline,Pipeline.run)) +method is used to execute pipeline once. + +%mddoclink(api,script.core.message,Message) is used to represent text messages. """ # %pip install dff uvicorn fastapi diff --git a/tutorials/pipeline/1_basics.py b/tutorials/pipeline/1_basics.py index 74257fa74..d2919b27e 100644 --- a/tutorials/pipeline/1_basics.py +++ b/tutorials/pipeline/1_basics.py @@ -4,6 +4,9 @@ The following tutorial shows basic usage of `pipeline` module as an extension to `dff.script.core`. + +Here, `__call__` (same as %mddoclink(api,pipeline.pipeline.pipeline,Pipeline.run)) +method is used to execute pipeline once. """ # %pip install dff diff --git a/tutorials/pipeline/2_pre_and_post_processors.py b/tutorials/pipeline/2_pre_and_post_processors.py index b467395ce..eb335feb3 100644 --- a/tutorials/pipeline/2_pre_and_post_processors.py +++ b/tutorials/pipeline/2_pre_and_post_processors.py @@ -4,6 +4,9 @@ The following tutorial shows more advanced usage of `pipeline` module as an extension to `dff.script.core`. + +Here, %mddoclink(api,script.core.context,Context.misc) +dictionary of context is used for storing additional data. """ # %pip install dff diff --git a/tutorials/pipeline/3_pipeline_dict_with_services_basic.py b/tutorials/pipeline/3_pipeline_dict_with_services_basic.py index 7f3c44cc6..df3c0c36d 100644 --- a/tutorials/pipeline/3_pipeline_dict_with_services_basic.py +++ b/tutorials/pipeline/3_pipeline_dict_with_services_basic.py @@ -4,6 +4,12 @@ The following tutorial shows `pipeline` creation from dict and most important pipeline components. + +Here, %mddoclink(api,pipeline.service.service,Service) +class, that can be used for pre- and postprocessing of messages is shown. + +Pipeline's %mddoclink(api,pipeline.pipeline.pipeline,Pipeline.from_dict) +static method is used for pipeline creation (from dictionary). """ # %pip install dff diff --git a/tutorials/pipeline/3_pipeline_dict_with_services_full.py b/tutorials/pipeline/3_pipeline_dict_with_services_full.py index 950f37929..b085fa2ff 100644 --- a/tutorials/pipeline/3_pipeline_dict_with_services_full.py +++ b/tutorials/pipeline/3_pipeline_dict_with_services_full.py @@ -4,6 +4,9 @@ The following tutorial shows `pipeline` creation from dict and most important pipeline components. + +This tutorial is a more advanced version of the +[previous tutorial](%doclink(tutorial,pipeline.3_pipeline_dict_with_services_basic)). """ # %pip install dff diff --git a/tutorials/pipeline/4_groups_and_conditions_basic.py b/tutorials/pipeline/4_groups_and_conditions_basic.py index b833d5f12..18b4527b5 100644 --- a/tutorials/pipeline/4_groups_and_conditions_basic.py +++ b/tutorials/pipeline/4_groups_and_conditions_basic.py @@ -3,6 +3,10 @@ # 4. Groups and conditions (basic) The following example shows `pipeline` service group usage and start conditions. + +Here, %mddoclink(api,pipeline.service.service,Service)s +and %mddoclink(api,pipeline.service.group,ServiceGroup)s +are shown for advanced data pre- and postprocessing based on conditions. """ # %pip install dff diff --git a/tutorials/pipeline/4_groups_and_conditions_full.py b/tutorials/pipeline/4_groups_and_conditions_full.py index 112025268..e363fda2d 100644 --- a/tutorials/pipeline/4_groups_and_conditions_full.py +++ b/tutorials/pipeline/4_groups_and_conditions_full.py @@ -3,6 +3,9 @@ # 4. Groups and conditions (full) The following tutorial shows `pipeline` service group usage and start conditions. + +This tutorial is a more advanced version of the +[previous tutorial](%doclink(tutorial,pipeline.4_groups_and_conditions_basic)). """ # %pip install dff diff --git a/tutorials/pipeline/5_asynchronous_groups_and_services_basic.py b/tutorials/pipeline/5_asynchronous_groups_and_services_basic.py index ddfcbf5ab..4d25fa7b9 100644 --- a/tutorials/pipeline/5_asynchronous_groups_and_services_basic.py +++ b/tutorials/pipeline/5_asynchronous_groups_and_services_basic.py @@ -4,6 +4,9 @@ The following tutorial shows `pipeline` asynchronous service and service group usage. + +Here, %mddoclink(api,pipeline.service.group,ServiceGroup)s +are shown for advanced and asynchronous data pre- and postprocessing. """ # %pip install dff diff --git a/tutorials/pipeline/5_asynchronous_groups_and_services_full.py b/tutorials/pipeline/5_asynchronous_groups_and_services_full.py index 7141ba220..dc1d585ca 100644 --- a/tutorials/pipeline/5_asynchronous_groups_and_services_full.py +++ b/tutorials/pipeline/5_asynchronous_groups_and_services_full.py @@ -4,6 +4,9 @@ The following tutorial shows `pipeline` asynchronous service and service group usage. + +This tutorial is a more advanced version of the +[previous tutorial](%doclink(tutorial,pipeline.5_asynchronous_groups_and_services_basic)). """ # %pip install dff diff --git a/tutorials/pipeline/6_custom_messenger_interface.py b/tutorials/pipeline/6_custom_messenger_interface.py index 19a704e54..c20a38b20 100644 --- a/tutorials/pipeline/6_custom_messenger_interface.py +++ b/tutorials/pipeline/6_custom_messenger_interface.py @@ -3,6 +3,10 @@ # 6. Custom messenger interface The following tutorial shows messenger interfaces usage. + +Here, %mddoclink(api,messengers.common.interface,CallbackMessengerInterface) +and %mddoclink(api,messengers.common.interface,PollingMessengerInterface) +are shown as alternatives for connection to custom user messenger backends. """ # %pip install dff flask diff --git a/tutorials/pipeline/7_extra_handlers_basic.py b/tutorials/pipeline/7_extra_handlers_basic.py index 5e7186078..2f72955b6 100644 --- a/tutorials/pipeline/7_extra_handlers_basic.py +++ b/tutorials/pipeline/7_extra_handlers_basic.py @@ -3,6 +3,10 @@ # 7. Extra Handlers (basic) The following tutorial shows extra handlers possibilities and use cases. + +Here, extra handlers %mddoclink(api,pipeline.service.extra,BeforeHandler) +and %mddoclink(api,pipeline.service.extra,AfterHandler) +are shown as additional means of data processing, attached to services. """ # %pip install dff diff --git a/tutorials/pipeline/7_extra_handlers_full.py b/tutorials/pipeline/7_extra_handlers_full.py index 281f0801b..0027c8ca9 100644 --- a/tutorials/pipeline/7_extra_handlers_full.py +++ b/tutorials/pipeline/7_extra_handlers_full.py @@ -3,6 +3,9 @@ # 7. Extra Handlers (full) The following tutorial shows extra handlers possibilities and use cases. + +This tutorial is a more advanced version of the +[previous tutorial](%doclink(tutorial,pipeline.7_extra_handlers_basic)). """ # %pip install dff psutil diff --git a/tutorials/pipeline/8_extra_handlers_and_extensions.py b/tutorials/pipeline/8_extra_handlers_and_extensions.py index 9828e4d84..8b610af5f 100644 --- a/tutorials/pipeline/8_extra_handlers_and_extensions.py +++ b/tutorials/pipeline/8_extra_handlers_and_extensions.py @@ -4,6 +4,10 @@ The following tutorial shows how pipeline can be extended by global extra handlers and custom functions. + +Here, %mddoclink(api,pipeline.pipeline.pipeline,Pipeline.add_global_handler) +function is shown, that can be used to add extra handlers before +and/or after all pipeline services. """ # %pip install dff diff --git a/tutorials/script/core/1_basics.py b/tutorials/script/core/1_basics.py index b8a3606ac..a5ebb2d99 100644 --- a/tutorials/script/core/1_basics.py +++ b/tutorials/script/core/1_basics.py @@ -3,6 +3,15 @@ # Core: 1. Basics This notebook shows basic tutorial of creating a simple dialog bot (agent). + +Here, basic usege of %mddoclink(api,pipeline.pipeline.pipeline,Pipeline) +primitive is shown: its' creation with +%mddoclink(api,pipeline.pipeline.pipeline,Pipeline.from_script) +and execution. + +Additionally, function %mddoclink(api,utils.testing.common,check_happy_path) +that can be used for Pipeline testing is presented. + Let's do all the necessary imports from DFF: """ diff --git a/tutorials/script/core/2_conditions.py b/tutorials/script/core/2_conditions.py index 1b0ac3030..35b862d4b 100644 --- a/tutorials/script/core/2_conditions.py +++ b/tutorials/script/core/2_conditions.py @@ -4,6 +4,10 @@ This tutorial shows different options for setting transition conditions from one node to another. + +Here, [conditions](%doclink(api,script.conditions.std_conditions)) +for script transitions are shown. + First of all, let's do all the necessary imports from DFF. """ diff --git a/tutorials/script/core/3_responses.py b/tutorials/script/core/3_responses.py index bc6f0c92d..3d12a75ce 100644 --- a/tutorials/script/core/3_responses.py +++ b/tutorials/script/core/3_responses.py @@ -3,6 +3,10 @@ # Core: 3. Responses This tutorial shows different options for setting responses. + +Here, [responses](%doclink(api,script.responses.std_responses)) +that allow giving custom answers to users are shown. + Let's do all the necessary imports from DFF. """ diff --git a/tutorials/script/core/4_transitions.py b/tutorials/script/core/4_transitions.py index eaaf9de89..86a6f9e99 100644 --- a/tutorials/script/core/4_transitions.py +++ b/tutorials/script/core/4_transitions.py @@ -3,9 +3,17 @@ # Core: 4. Transitions This tutorial shows settings for transitions between flows and nodes. + +Here, [conditions](%doclink(api,script.conditions.std_conditions)) +for transition between many different script steps are shown. + +Some of the destination steps can be set using +[labels](%doclink(api,script.labels.std_labels)). + First of all, let's do all the necessary imports from DFF. """ + # %pip install dff # %% diff --git a/tutorials/script/core/5_global_transitions.py b/tutorials/script/core/5_global_transitions.py index 8fc51e270..8d555d0f1 100644 --- a/tutorials/script/core/5_global_transitions.py +++ b/tutorials/script/core/5_global_transitions.py @@ -3,9 +3,14 @@ # Core: 5. Global transitions This tutorial shows the global setting of transitions. + +Here, global [conditions](%doclink(api,script.conditions.std_conditions)) +for default transition between many different script steps are shown. + First of all, let's do all the necessary imports from DFF. """ + # %pip install dff # %% diff --git a/tutorials/script/core/7_pre_response_processing.py b/tutorials/script/core/7_pre_response_processing.py index 324509181..d43e9c17d 100644 --- a/tutorials/script/core/7_pre_response_processing.py +++ b/tutorials/script/core/7_pre_response_processing.py @@ -3,6 +3,13 @@ # Core: 7. Pre-response processing This tutorial shows pre-response processing feature. + +Here, %mddoclink(api,script.core.keywords,Keywords.PRE_RESPONSE_PROCESSING) +is demonstrated which can be used for additional context processing before response handlers. + +There are also some other %mddoclink(api,script.core.keywords,Keywords) +worth attention used in this tutorial. + First of all, let's do all the necessary imports from DFF. """ diff --git a/tutorials/script/core/8_misc.py b/tutorials/script/core/8_misc.py index b389d81d1..7756eca12 100644 --- a/tutorials/script/core/8_misc.py +++ b/tutorials/script/core/8_misc.py @@ -3,6 +3,10 @@ # Core: 8. Misc This tutorial shows `MISC` (miscellaneous) keyword usage. + +See %mddoclink(api,script.core.keywords,Keywords.MISC) +for more information. + First of all, let's do all the necessary imports from DFF. """ diff --git a/tutorials/script/core/9_pre_transitions_processing.py b/tutorials/script/core/9_pre_transitions_processing.py index 138775673..859a1cd5f 100644 --- a/tutorials/script/core/9_pre_transitions_processing.py +++ b/tutorials/script/core/9_pre_transitions_processing.py @@ -3,6 +3,11 @@ # Core: 9. Pre-transitions processing This tutorial shows pre-transitions processing feature. + +Here, %mddoclink(api,script.core.keywords,Keywords.PRE_TRANSITIONS_PROCESSING) +is demonstrated which can be used for additional context +processing before transitioning to the next step. + First of all, let's do all the necessary imports from DFF. """ diff --git a/tutorials/script/responses/1_basics.py b/tutorials/script/responses/1_basics.py index 138be697a..c737b05f5 100644 --- a/tutorials/script/responses/1_basics.py +++ b/tutorials/script/responses/1_basics.py @@ -2,6 +2,10 @@ """ # Responses: 1. Basics +Here, the process of response forming is shown. +Special keywords %mddoclink(api,script.core.keywords,Keywords.RESPONSE) +and %mddoclink(api,script.core.keywords,Keywords.TRANSITIONS) +are used for that. """ # %pip install dff diff --git a/tutorials/script/responses/2_buttons.py b/tutorials/script/responses/2_buttons.py index 88e81dec3..08cec46db 100644 --- a/tutorials/script/responses/2_buttons.py +++ b/tutorials/script/responses/2_buttons.py @@ -2,8 +2,14 @@ """ # Responses: 2. Buttons +In this tutorial %mddoclink(api,script.core.message,Button) +class is demonstrated. +Buttons are one of %mddoclink(api,script.core.message,Message) fields. +They can be attached to any message but will only work if the chosen +[messenger interface](%doclink(api,index_messenger_interfaces)) supports them. """ + # %pip install dff # %% diff --git a/tutorials/script/responses/3_media.py b/tutorials/script/responses/3_media.py index fb97d9803..8b43d58f9 100644 --- a/tutorials/script/responses/3_media.py +++ b/tutorials/script/responses/3_media.py @@ -2,6 +2,13 @@ """ # Responses: 3. Media +Here, %mddoclink(api,script.core.message,Attachments) class is shown. +Attachments can be used for attaching different media elements +(such as %mddoclink(api,script.core.message,Image), %mddoclink(api,script.core.message,Document) +or %mddoclink(api,script.core.message,Audio)). + +They can be attached to any message but will only work if the chosen +[messenger interface](%doclink(api,index_messenger_interfaces)) supports them. """ # %pip install dff diff --git a/tutorials/script/responses/4_multi_message.py b/tutorials/script/responses/4_multi_message.py index 01fb0b968..d6dca4b1f 100644 --- a/tutorials/script/responses/4_multi_message.py +++ b/tutorials/script/responses/4_multi_message.py @@ -3,6 +3,9 @@ # Responses: 4. Multi Message This tutorial shows Multi Message usage. + +The %mddoclink(api,script.core.message,MultiMessage) represents a combination of several messages. + Let's do all the necessary imports from DFF. """ diff --git a/tutorials/utils/1_cache.py b/tutorials/utils/1_cache.py index 3de8aab5c..bc1235551 100644 --- a/tutorials/utils/1_cache.py +++ b/tutorials/utils/1_cache.py @@ -2,6 +2,15 @@ """ # 1. Cache +In this tutorial use of +%mddoclink(api,utils.turn_caching.singleton_turn_caching,cache) +function is demonstrated. + +This function is used a lot like `functools.cache` function and +helps by saving results of heavy function execution and avoiding recalculation. + +Caches are kept in a library-wide singleton +and are cleared at the end of each turn. """ # %pip install dff diff --git a/tutorials/utils/2_lru_cache.py b/tutorials/utils/2_lru_cache.py index 86d77289f..0aaf326bc 100644 --- a/tutorials/utils/2_lru_cache.py +++ b/tutorials/utils/2_lru_cache.py @@ -2,6 +2,17 @@ """ # 2. LRU Cache +In this tutorial use of +%mddoclink(api,utils.turn_caching.singleton_turn_caching,lru_cache) +function is demonstrated. + +This function is used a lot like `functools.lru_cache` function and +helps by saving results of heavy function execution and avoiding recalculation. + +Caches are kept in a library-wide singleton +and are cleared at the end of each turn. + +Maximum size parameter limits the amount of function execution results cached. """ # %pip install dff