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

Feat/add docker image #384

Open
wants to merge 42 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
481fd55
qol: add attachments to cli interface
RLKRo Feb 11, 2024
973abaa
qol: make keywords upper case
RLKRo Feb 11, 2024
98692f9
qol: accept list of attachments as `Message.attachment`
RLKRo Feb 11, 2024
a9bbbb9
qol: make choice function accept responses as args
RLKRo Feb 11, 2024
d25fd30
qol: import script objects inside `dff/__init__.py`
RLKRo Feb 11, 2024
e8fc8f6
json import draft
RLKRo Feb 12, 2024
dfd61b5
add json import examples
RLKRo Feb 12, 2024
66b3bb0
add submodule aliases
RLKRo Feb 20, 2024
9637110
update resolve_target_object to use submodule aliases
RLKRo Feb 20, 2024
c4f04ba
add function to retrieve dff object mapping
RLKRo Feb 20, 2024
cfda4f7
small fixes
RLKRo Feb 22, 2024
0e5f72a
capitalize messages
RLKRo Mar 20, 2024
56755b9
improve import system for custom objects
RLKRo Mar 20, 2024
4b4cf69
make custom_dir standard way to address custom dir
RLKRo Mar 22, 2024
ce18579
prepare parser for dev release
RLKRo May 27, 2024
702ddc8
Merge branch 'master' into 'chore/slots2parser'
Ramimashkouk Jul 18, 2024
0c53232
Merge branch 'master' into chore/slots2parser
Ramimashkouk Jul 22, 2024
d787906
feat: Integrate slots parsing
Ramimashkouk Jul 22, 2024
8a4781d
chore: Add pre-transitions to script example
Ramimashkouk Jul 23, 2024
486a432
refactor: Use a consistent approach with slots
Ramimashkouk Aug 15, 2024
12c5913
feat: Add dockerfile image
Ramimashkouk Aug 15, 2024
cb0348d
refactor: Separate dockerfiles each in dir
Ramimashkouk Aug 22, 2024
8a49408
chore: Add chatsky to compose.yml
Ramimashkouk Aug 22, 2024
4f1c35f
chore: Add command to compose
Ramimashkouk Aug 28, 2024
f7faf1e
chore: Copy default pipeline to dockerfile
Ramimashkouk Aug 28, 2024
748aaec
feat: Add HTTPMessengerInterface
Ramimashkouk Aug 28, 2024
85f55ff
ci: Add workflow to build & publish docker image
Ramimashkouk Aug 28, 2024
3b8391b
fix: Make image workflow work
Ramimashkouk Sep 5, 2024
710d361
Merge branch 'feat/add-http-interface' into feat/add-docker-image
Ramimashkouk Sep 5, 2024
84a6630
chore: Publish docker image to ghrc
Ramimashkouk Sep 19, 2024
3e9e9d8
fix: Update dockerfile to find the built wheel
Ramimashkouk Sep 19, 2024
6af361b
Merge branch 'dev' into feat/add-docker-image
Ramimashkouk Sep 19, 2024
4a406c0
chore: Continue merge
Ramimashkouk Sep 19, 2024
7d15ab1
fix: Install dependencies in dokcerfile
Ramimashkouk Sep 19, 2024
6d17536
push poetry lock
Ramimashkouk Sep 19, 2024
a20de2c
chore: lock poetry
Ramimashkouk Nov 14, 2024
a0394eb
Merge branch 'dev' into feat/add-docker-image
Ramimashkouk Nov 14, 2024
d4296f0
fix: Import Message properly
Ramimashkouk Nov 14, 2024
029da89
chore: Get http_interface port from .env
Ramimashkouk Nov 18, 2024
51bc913
chore: Get port
Ramimashkouk Nov 18, 2024
584d06b
feat: Add http_interace health check
Ramimashkouk Nov 20, 2024
7e8f261
fix: Provide ctx_id for HttpInterface
Ramimashkouk Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'dev' into feat/add-docker-image
Ramimashkouk committed Sep 19, 2024
commit 6af361b66e6cad5e5dfef946c199162bff8e25db
3 changes: 3 additions & 0 deletions .github/process_github_events.py
Original file line number Diff line number Diff line change
@@ -50,6 +50,9 @@ def post_comment_on_pr(comment: str, pr_number: int):
- [ ] Change PR merge option
- [ ] Update template repo
- [ ] Search for objects to be deprecated
- [ ] Test parts not covered with pytest:
- [ ] web_api tutorials
- [ ] Test integrations with external services (telegram; stats)
"""


60 changes: 27 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Chatsky
![Chatsky](https://raw.githubusercontent.com/deeppavlov/chatsky/master/docs/source/_static/images/Chatsky-full-dark.svg)

[![Documentation Status](https://github.com/deeppavlov/chatsky/workflows/build_and_publish_docs/badge.svg?branch=dev)](https://deeppavlov.github.io/chatsky)
[![Codestyle](https://github.com/deeppavlov/chatsky/workflows/codestyle/badge.svg?branch=dev)](https://github.com/deeppavlov/chatsky/actions/workflows/codestyle.yml)
@@ -79,53 +79,47 @@ All the abstractions used in this example are thoroughly explained in the dedica
[user guide](https://deeppavlov.github.io/chatsky/user_guides/basic_conceptions.html).

```python
from chatsky.script import GLOBAL, TRANSITIONS, RESPONSE, Message
from chatsky.pipeline import Pipeline
import chatsky.script.conditions.std_conditions as cnd
from chatsky import (
GLOBAL,
TRANSITIONS,
RESPONSE,
Pipeline,
conditions as cnd,
Transition as Tr,
)

# create a dialog script
script = {
GLOBAL: {
TRANSITIONS: {
("flow", "node_hi"): cnd.exact_match("Hi"),
("flow", "node_ok"): cnd.true()
}
TRANSITIONS: [
Tr(
dst=("flow", "node_hi"),
cnd=cnd.ExactMatch("Hi"),
),
Tr(
dst=("flow", "node_ok")
)
]
},
"flow": {
"node_hi": {RESPONSE: Message("Hi!")},
"node_ok": {RESPONSE: Message("OK")},
"node_hi": {RESPONSE: "Hi!"},
"node_ok": {RESPONSE: "OK"},
},
}

# init pipeline
pipeline = Pipeline.from_script(script, start_label=("flow", "node_hi"))
# initialize Pipeline (needed to run the script)
pipeline = Pipeline(script, start_label=("flow", "node_hi"))


def turn_handler(in_request: Message, pipeline: Pipeline) -> Message:
# Pass user request into pipeline and get dialog context (message history)
# The pipeline will automatically choose the correct response using script
ctx = pipeline(in_request, 0)
# Get last response from the context
out_response = ctx.last_response
return out_response


while True:
in_request = input("Your message: ")
out_response = turn_handler(Message(in_request), pipeline)
print("Response: ", out_response.text)
pipeline.run()
```

When you run this code, you get similar output:
```
Your message: hi
Response: OK
Your message: Hi
Response: Hi!
Your message: ok
Response: OK
Your message: ok
Response: OK
request: hi
response: text='OK'
request: Hi
response: text='Hi!'
```

More advanced examples are available as a part of documentation:
41 changes: 36 additions & 5 deletions chatsky/__init__.py
Original file line number Diff line number Diff line change
@@ -6,12 +6,43 @@
__version__ = version(__name__)


import nest_asyncio
import nest_asyncio as __nest_asyncio__

__nest_asyncio__.apply()

from chatsky.core import (
GLOBAL,
LOCAL,
RESPONSE,
TRANSITIONS,
MISC,
PRE_RESPONSE,
PRE_TRANSITION,
BaseCondition,
AnyCondition,
BaseResponse,
AnyResponse,
BaseDestination,
AnyDestination,
BaseProcessing,
BasePriority,
AnyPriority,
Pipeline,
Context,
Message,
Transition,
Transition as Tr,
MessageInitTypes,
NodeLabel,
NodeLabelInitTypes,
AbsoluteNodeLabel,
AbsoluteNodeLabelInitTypes,
)
import chatsky.conditions as cnd
import chatsky.destinations as dst
import chatsky.responses as rsp
import chatsky.processing as proc

nest_asyncio.apply()

from chatsky.pipeline import Pipeline
from chatsky.script import Context, Script

from chatsky.msg import *

11 changes: 8 additions & 3 deletions chatsky/__rebuild_pydantic_models__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# flake8: noqa: F401

from chatsky.pipeline import Pipeline
from chatsky.pipeline.types import ExtraHandlerRuntimeInfo
from chatsky.script import Context, Script
from chatsky.core.service.types import ExtraHandlerRuntimeInfo, StartConditionCheckerFunction, ComponentExecutionState
from chatsky.core import Context, Script
from chatsky.core.script import Node
from chatsky.core.pipeline import Pipeline
from chatsky.slots.slots import SlotManager
from chatsky.core.context import FrameworkData

Pipeline.model_rebuild()
Script.model_rebuild()
Context.model_rebuild()
ExtraHandlerRuntimeInfo.model_rebuild()
FrameworkData.model_rebuild()
12 changes: 12 additions & 0 deletions chatsky/conditions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from chatsky.conditions.standard import (
ExactMatch,
HasText,
Regexp,
Any,
All,
Negation,
CheckLastLabels,
Not,
HasCallbackQuery,
)
from chatsky.conditions.slots import SlotsExtracted
38 changes: 38 additions & 0 deletions chatsky/conditions/slots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Slot Conditions
---------------------------
Provides slot-related conditions.
"""

from __future__ import annotations
from typing import Literal, List

from chatsky.core import Context, BaseCondition
from chatsky.slots.slots import SlotName


class SlotsExtracted(BaseCondition):
"""
Check if :py:attr:`.slots` are extracted.

:param mode: Whether to check if all slots are extracted or any slot is extracted.
"""

slots: List[SlotName]
"""
Names of the slots that need to be checked.
"""
mode: Literal["any", "all"] = "all"
"""
Whether to check if all slots are extracted or any slot is extracted.
"""

def __init__(self, *slots: SlotName, mode: Literal["any", "all"] = "all"):
super().__init__(slots=slots, mode=mode)

async def call(self, ctx: Context) -> bool:
manager = ctx.framework_data.slot_manager
if self.mode == "all":
return all(manager.is_slot_extracted(slot) for slot in self.slots)
elif self.mode == "any":
return any(manager.is_slot_extracted(slot) for slot in self.slots)
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.