Skip to content

Commit

Permalink
Merge branch 'feat/partial_context_updates' of https://github.com/dee…
Browse files Browse the repository at this point in the history
…ppavlov/dialog_flow_framework into feat/partial_context_updates
  • Loading branch information
pseusys committed Oct 21, 2024
2 parents 5340256 + 403e2e1 commit 9aad1bb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: deploy website
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
uses: JamesIves/github-pages-deploy-action@v4.6.4
with:
branch: gh-pages
folder: docs/build/
Expand Down
35 changes: 20 additions & 15 deletions chatsky/utils/db_benchmark/basic_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class BasicBenchmarkConfig(BenchmarkConfig, frozen=True):
Number of times the contexts will be benchmarked.
Increasing this number decreases standard error of the mean for benchmarked data.
"""
from_dialog_len: int = 300
from_dialog_len: int = 25
"""Starting dialog len of a context."""
to_dialog_len: int = 311
to_dialog_len: int = 50
"""
Final dialog len of a context.
:py:meth:`~.BasicBenchmarkConfig.context_updater` will return contexts
Expand Down Expand Up @@ -150,14 +150,21 @@ async def info(self):
- "misc_size" -- size of a misc field of a context.
- "message_size" -- size of a misc field of a message.
"""
def remove_db_from_context(ctx: Context):
ctx._storage = None
ctx.requests._storage = None
ctx.responses._storage = None
ctx.labels._storage = None

starting_context = await get_context(MemoryContextStorage(), self.from_dialog_len, self.message_dimensions, self.misc_dimensions)
final_contex = await get_context(MemoryContextStorage(), self.to_dialog_len, self.message_dimensions, self.misc_dimensions)
remove_db_from_context(starting_context)
remove_db_from_context(final_contex)
return {
"params": self.model_dump(),
"sizes": {
"starting_context_size": naturalsize(asizeof.asizeof(await self.get_context(MemoryContextStorage())), gnu=True),
"final_context_size": naturalsize(
asizeof.asizeof(await get_context(MemoryContextStorage(), self.to_dialog_len, self.message_dimensions, self.misc_dimensions)),
gnu=True,
),
"starting_context_size": naturalsize(asizeof.asizeof(starting_context.model_dump(mode="python")), gnu=True),
"final_context_size": naturalsize(asizeof.asizeof(final_contex.model_dump(mode="python")), gnu=True),
"misc_size": naturalsize(asizeof.asizeof(get_dict(self.misc_dimensions)), gnu=True),
"message_size": naturalsize(asizeof.asizeof(get_message(self.message_dimensions)), gnu=True),
},
Expand All @@ -184,27 +191,25 @@ async def context_updater(self, context: Context) -> Optional[Context]:
basic_configurations = {
"large-misc": BasicBenchmarkConfig(
from_dialog_len=1,
to_dialog_len=50,
to_dialog_len=26,
message_dimensions=(3, 5, 6, 5, 3),
misc_dimensions=(2, 4, 3, 8, 100),
),
"short-messages": BasicBenchmarkConfig(
from_dialog_len=500,
to_dialog_len=550,
message_dimensions=(2, 30),
misc_dimensions=(0, 0),
),
"default": BasicBenchmarkConfig(),
"large-misc--long-dialog": BasicBenchmarkConfig(
from_dialog_len=500,
to_dialog_len=550,
"large-misc-long-dialog": BasicBenchmarkConfig(
from_dialog_len=50,
to_dialog_len=75,
message_dimensions=(3, 5, 6, 5, 3),
misc_dimensions=(2, 4, 3, 8, 100),
),
"very-long-dialog-len": BasicBenchmarkConfig(
context_num=10,
from_dialog_len=10000,
to_dialog_len=10050,
from_dialog_len=1000,
to_dialog_len=1050,
),
"very-long-message-len": BasicBenchmarkConfig(
context_num=10,
Expand Down
9 changes: 6 additions & 3 deletions docs/source/user_guides/slot_extraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ A dot-separated string that acts as a path from the root slot to the needed slot
In the example above ``name_slot`` would have the name "name"
because that is the key used to store it in the ``profile_slot``.

If you have a nested structure (of ``GroupSlots``) separate the names with dots:
Let's consider nested group slots:

.. code-block:: python
Expand Down Expand Up @@ -141,7 +141,10 @@ The `conditions` submodule provides a function for checking if specific slots ha

Both `processing` and `response` submodules provide functions for filling templates with
extracted slot values.
Choose whichever one you like, there's not much difference between them at the moment.

- ``FillTemplate`` changes the response function of the current node to ``FilledTemplate`` at the ``PRE_RESPONSE`` level.
- ``FilledTemplate`` is a response function that fills slots after producing inner response
(which can be ``BaseResponse``, ``Message`` or simply a string).

.. code-block:: python
Expand All @@ -153,7 +156,7 @@ Choose whichever one you like, there's not much difference between them at the m
RESPONSE: rsp.FilledTemplate("Your first name: {name}")
Some real examples of scripts utilizing slot extraction can be found in the
An example of script utilizing slot extraction can be found in the
`tutorials section <../tutorials/tutorials.slots.1_basic_example.html>`_.

Further reading
Expand Down
15 changes: 14 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9aad1bb

Please sign in to comment.