Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.0rc1 #388

Merged
merged 13 commits into from
Sep 7, 2024
Merged

v1.0.0rc1 #388

merged 13 commits into from
Sep 7, 2024

Conversation

RLKRo
Copy link
Member

@RLKRo RLKRo commented Sep 7, 2024

Changelog

This release includes a huge rework of core library features.

It is highly recommended to reread documentation relating to scripting.
(basic concepts user guide; script and pipeline tutorials)

Breaking Changes

  • Removed Pipeline.from_script. Use __init__ instead (Pydantic improvements #372)
  • All conditions (standard and slot) moved to chatsky.conditions (Feat/core rework #381)
  • All labels (standard) moved to chatsky.destinations (Feat/core rework #381)
  • All processing functions (slot) moved to chatsky.processing (Feat/core rework #381)
  • All responses (standard and slot) moved to chatsky.responses (Feat/core rework #381)
  • All conditions, destinations, processing functions, responses are now upper camel case (Feat/core rework #381)
  • script.core module moved to chatsky.core (Feat/core rework #381)
  • Pipeline moved to chatsky.core (Feat/core rework #381)
  • pipeline.service submodule moved to chatsky.core.service (Feat/core rework #381)
  • Added class Transition. TRANSITIONS is now a list of such objects instead of a dict.
    Destination, condition and priority are all fields of this class. Priority is now separate from node label (Feat/core rework #381)
  • Removed cnd.true and cnd.false. Condition field of Transition now accepts True and False literals.
    If condition field of Transition is not set, it defaults to True. (Feat/core rework #381)
  • Removed lbl.repeat renamed to dst.Current. Added dst.FromHistory to get labels from history past dst.Previous. (Feat/core rework #381)
  • Custom script functions now have to be subclassed from BaseScriptFunction.
    e.g. custom response function now have to be subclassed from BaseResponse. (Feat/core rework #381)
  • All keywords from chatsky.script.core.keywords moved to chatsky.core.script (Feat/core rework #381)
  • PRE_TRANSITIONS_PROCESSING renamed to PRE_TRANSITION (Feat/core rework #381)
  • PRE_RESPONSE_PROCESSING renamed to PRE_RESPONSE (Feat/core rework #381)
  • Removed chatsky.utils.turn_caching (Feat/core rework #381)
  • Turn id 0 is now reserved for start label. Actual turns start at id 1.
    Context has method init to init from a start label (Feat/core rework #381)
  • Removed proc.ExtractAll -- the function is unsafe as it overwrites the entire slot storage. it is still available as method of the slot manager (Feat/script parser #385)
  • The order of execution for pre-transition, pre-response processing is reversed: global processings will be the last ones. (fix node merge #387)

Features

  • RESPONSE can now be a string. It will be converted to Message(text=) automatically (Feat/core rework #381)
  • Custom functions do validation (e.g. response function can now return a string and it will be cast to Message) (Feat/core rework #381)
  • Current instance of Pipeline can now be accessed via Context.pipeline (Feat/core rework #381)
  • Added NodeLabel class to replace tuple node labels (Feat/core rework #381)
  • Added method Script.get_inherited_node to get a node that inherits global and local properties.
    ctx.current_node is obtained via this method (Feat/core rework #381)
  • Renamed response_comparer of check_happy_path to response_comparator, removed default comparators, removed context from signature;
    messages in happy_path can now be any of Message, dict, str;
    printout_enable flag renamed to printout and made False by default. (Feat/core rework #381)
  • Added ModifyResponse base processing class which allows modifying current node response. (Feat/core rework #381)
  • Added Pipeline from file import (Feat/script parser #385)
  • Added function that creates an index of commonly-used Chatsky objects (Feat/script parser #385)

Fixes

  • Slot template filling now works for numerical slot names (e.g. slot_name="0") (Feat/core rework #381)
  • Slot Groups can now be initialized from a dictionary (Feat/core rework #381)
  • Exceptions in user functions are now properly handled: (Feat/core rework #381)
    • response errors result in an empty message
    • processing errors are ignored
    • transition errors mark that specific transition as failed
  • Slot extraction will now not write the value to the slot storage if value was not successfully extracted. Can be changed via the success_only flag (Feat/script parser #385)

Documentation

Devel

RLKRo and others added 13 commits July 3, 2024 17:56
…380)

Bumps the deps group with 17 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [pydantic](https://github.com/pydantic/pydantic) | `2.7.4` | `2.8.2` |
| [ydb](https://github.com/ydb-platform/ydb-python-sdk) | `3.12.3` |
`3.15.0` |
| [altair](https://github.com/vega/altair) | `5.3.0` | `5.4.0` |
| [pympler](https://github.com/pympler/pympler) | `1.0.1` | `1.1` |
| [humanize](https://github.com/python-humanize/humanize) | `4.9.0` |
`4.10.0` |
| [cryptography](https://github.com/pyca/cryptography) | `42.0.8` |
`43.0.0` |
|
[python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot)
| `21.3` | `21.4` |
|
[opentelemetry-exporter-otlp](https://github.com/open-telemetry/opentelemetry-python)
| `1.25.0` | `1.26.0` |
| [black](https://github.com/psf/black) | `24.4.2` | `24.8.0` |
| [mypy](https://github.com/python/mypy) | `1.10.1` | `1.11.1` |
| [pytest](https://github.com/pytest-dev/pytest) | `8.2.2` | `8.3.2` |
| [coverage](https://github.com/nedbat/coveragepy) | `7.5.4` | `7.6.1` |
| [jsonschema](https://github.com/python-jsonschema/jsonschema) |
`4.22.0` | `4.23.0` |
|
[python-on-whales](https://github.com/gabrieldemarmiesse/python-on-whales)
| `0.71.0` | `0.72.0` |
| [fastapi](https://github.com/fastapi/fastapi) | `0.111.0` | `0.112.0`
|
| [streamlit](https://github.com/streamlit/streamlit) | `1.36.0` |
`1.37.1` |
| [sphinx-gallery](https://github.com/sphinx-gallery/sphinx-gallery) |
`0.16.0` | `0.17.1` |

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Description:

- TLDR: All classes in /chatsky/pipeline/ are rewritten in Pydantic,
some changes to class hierarchy and the classes themselves. Changed
tutorials with regards to new class signatures.
- Classes `PipelineComponent`, `Pipeline` and `ComponentExtraHandler`
are now subclasses of Pydantic's `BaseModel`, massively reducing code
bloat in their initialization and that of their children (such as
`Service`).
- Also, classes `Service`, `ServiceGroup` and `Actor` are now subclasses
of `PipelineComponent`. No functionality is removed in `ServiceGroup`.
All tutorials and tests pass like before, with a few changes.
- Reasoning for changing class hierarchy: Before this, an instance of
`Actor` would be called from within a `Service` with a special flag,
which seemed like a workaround, and now it can be called directly as an
instance of `PipelineComponent`, instead of heavily relying on the
`Service` class. You could say that this slightly reduces the code's
complexity. In fact, it also binds `Actor` to `PipelineComponent`,
instead of it being independent, making code look more cohesive.
- TypeBuilders have been removed, because Pydantic can already deal with
them effectively, giving type hints for IDE like before. Different input
types are still handled like before, except nested `Service` declaration
is removed. (`Service` class doesn't accept `Service` as it's handler
anymore) Same with nested `ComponentExtraHandler`s.
- For some reason Extra Handlers in `Service`s would work even if the
Service itself was turned off via `start_condition`. That was a bug. Now
this condition is checked in `PipelineComponent` instead. I assume
`Actor` must always have it as True.

# Checklist

- [x] Removed `from_script()` and other redundant methods.
- [x] Changed `components` into `pre-services` and `post-services`
throughout tutorials. (at `Pipeline` initialization)
- [x] Got tests to pass.
- [x] I have performed a self-review of the changes
- [x] Updated Pipeline's API and tutorials

# To Consider

- Add more tests if necessary
- Update the remaining API reference / tutorials / guides
- Search for more references to changed entities in the codebase

---------

Co-authored-by: Roman Zlobin <[email protected]>
# Description

## Breaking Changes

- All conditions (standard and slot) moved to `chatsky.conditions`
- All labels (standard) moved to `chatsky.destinations`
- All processing functions (slot) moved to `chatsky.processing`
- All responses (standard and slot) moved to `chatsky.responses`
- All conditions, destinations, processing functions, responses are now
upper camel case
- `script.core` module moved to `chatsky.core`
- `Pipeline` moved to `chatsky.core`
- `pipeline.service` submodule moved to `chatsky.core.service`
- Added class `Transition`. `TRANSITIONS` is now a list of such objects
instead of a dict.
Destination, condition and priority are all fields of this class.
Priority is now separate from node label
- Removed `cnd.true` and `cnd.false`. Condition field of `Transition`
now accepts `True` and `False` literals.
  If condition field of `Transition` is not set, it defaults to `True`.
- Removed `lbl.repeat` renamed to `dst.Current`. Added `dst.FromHistory`
to get labels from history past `dst.Previous`.
- Custom script functions now have to be subclassed from
`BaseScriptFunction`.
e.g. custom response function now have to be subclassed from
`BaseResponse`.
- All keywords from `chatsky.script.core.keywords` moved to
`chatsky.core.script`
- `PRE_TRANSITIONS_PROCESSING` renamed to `PRE_TRANSITION`
- `PRE_RESPONSE_PROCESSING` renamed to `PRE_RESPONSE`
- Removed `chatsky.utils.turn_caching`
- Turn id `0` is now reserved for start label. Actual turns start at id
1.
  Context has method `init` to init from a start label

## Features 

- `RESPONSE` can now be a string. It will be converted to
`Message(text=)` automatically
- Custom functions do validation (e.g. response function can now return
a string and it will be cast to `Message`)
- Current instance of `Pipeline` can now be accessed via
`Context.pipeline`
- Added `NodeLabel` class to replace tuple node labels
- The order of global/local transition inheritance for
`ctx.current_node` is now reversed
  (`[*node, *local, *global]` instead of `[*global, *local, *node]`)
  to reflect the inheritance priority order (node>local>global)
- Added method `Script.get_inherited_node` to get a node that inherits
global and local properties.
  `ctx.current_node` is obtained via this method
- Renamed response_comparer of `check_happy_path` to
response_comparator, removed default comparators, removed context from
signature;
  messages in `happy_path` can now be any of `Message`, `dict`, `str`;
`printout_enable` flag renamed to `printout` and made `False` by
default.

## Fixes

- Slot template filling now works for numerical slot names (e.g.
`slot_name="0"`)
- Slot Groups can now be initialized from a dictionary
- Exceptions in user functions are now properly handled:
  - response errors result in an empty message
  - processing errors are ignored
  - transition errors mark that specific transition as failed

## Documentation

- Some improvements to basic conceptions user guide and global tutorial
- Added a tip on getting previous nodes to pre transition tutorial
- Removed `responses.1_basics` tutorial
- Slight improvements to web api interface tutorials

## Devel

- Added `log_event_catcher` fixture to help test captured logs
- Added `TYPE_CHECKING` exclude from coverage; now only certain
exception raises are excluded from coverage
- Removed `run_interactive_mode`. Just use `pipeline.run()`.
- Removed Annotated values with pickle serializer/validators. Better to
use field_validators/field_serializers to preserve model schema
- Added `InitTypes` for various BaseModels to indicate types that can be
validated into that model
- `Actor` now doesn't have any parameters
- `normalization` utils replaced with pydantic validators
- An instance of `Script` can now be validated from a script dict
(without the `script` field)
- Removed `Context.cast`. Use `model_validate` and `model_validate_json`
instead.
# Description

Added option to initialize Pipeline from yaml/json files.

## Changelog

### Breaking changes

- Removed `proc.ExtractAll` -- the function is unsafe as it overwrites
the entire slot storage. it is still available as method of the slot
manager

### Features

- Add Pipeline from file import
- Add function that creates an index of commonly-used Chatsky objects
- Added imports to some `__init__` files
- Allow initializing NodeLabel from a list of two strings

### Bug fixes

- Slot extraction will now not write the value to the slot storage if
value was not successfully extracted. Can be changed via the
`success_only` flag

### Devel
- Add aliases to script keywords

# Checklist

- [x] I have performed a self-review of the changes

# To Consider

- Add tests (if functionality is changed)
- Update API reference / tutorials / guides
- Update CONTRIBUTING.md (if devel workflow is changed)
- Update `.ignore` files, scripts (such as `lint`), distribution
manifest (if files are added/deleted)
- Search for references to changed entities in the codebase

---------

Co-authored-by: Ramimashkouk <[email protected]>
Co-authored-by: Ramimashkouk <[email protected]>
# Description

Now dictionaries are merged in a way that localized processing functions
are called first.
(node > local > global)

# Checklist

- [x] I have performed a self-review of the changes

*List here tasks to complete in order to mark this PR as ready for
review.*

# To Consider

- Add tests (if functionality is changed)
- Update API reference / tutorials / guides
- Update CONTRIBUTING.md (if devel workflow is changed)
- Update `.ignore` files, scripts (such as `lint`), distribution
manifest (if files are added/deleted)
- Search for references to changed entities in the codebase
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears this PR is a release PR (change its base from master if that is not the case).

Here's a release checklist:

  • Update package version
  • Update poetry.lock
  • Change PR merge option
  • Update template repo
  • Search for objects to be deprecated

@RLKRo RLKRo merged commit 60a1887 into master Sep 7, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants