Skip to content

Commit

Permalink
add (disabled) course recommendation module (#23)
Browse files Browse the repository at this point in the history
* migrated changes from https://github.com/mmig/ki-campus-bot

* reverted local endpoint configuration

* reverted to  to default processing pipeline

* BUGFIX removed duplication when referencing inform_coursesearch slot

must set level-value via /inform_coursesearch{"level":"Experte"}'} not /inform_coursesearch/inform_coursesearch{"level":"Experte"}'}

* FIX indent format: consistently use tabs for indenting code

* BUGFIX [reapply fix] removed duplication when referencing inform_coursesearch slot

must set level-value via /inform_coursesearch{"level":"Experte"}'} not /inform_coursesearch/inform_coursesearch{"level":"Experte"}'}

* BUGFIX for typo fomat -> format

* BUGFIX use correct method name levels_db() instead of duplicate duration_db()

* updated usage-instructions for development

* REVERT previous commit 76b7c1e

* REVERT previous commit 76b7c1e

* updated usage-instructions for development

* implemented querying the recommender endpoint & showing its results

* added instructions for configuring the recommender endpoint

* git-ignore configuration/credentials file for recommender endpoint

* added utterances in case of error-results when querying course-recommendations

* FIX use absolute path for loading config-file instead of relative path w.r.t. current-working-directory

* added some DEBUG-output for get-recommendations-action

* small changes texts, action delete slot value

* REFACTOR extracted recommender-specific actions to separate file

* BUGFIX avoid duplicate class-names for actions

* REFACTOR use own low-resources implementation for loading YAML file/configuration

* changed training data, updated action, config

* FIX update docker configuration for new config-loading mechanism

 * install dependency for YAML library in docker for action server
 * do load/mount recommender-config file via docker-compose config when running action server

* FIX for spacy-pipeline: do install German spacy model via docker configuration

* FIX indentation for volume configuration

* added separate endpoints-configuration for docker

 * added specific endpoints-configuration file for docker to allow using default endpoints-configuration for local rasa shell

* FEATURE implemented loading action's response-texts from YAML file

 * implemented helpers for loading YAML file with response-texts (i.e. "utterances") that are used within action implementations
 * extracted response-texts (i.e. "utterances") from actions/actions.py to action_responses/actions_responses.yml
 * added action_responses/ as mounted volume in docker-compose configuration

* added (placeholder) label for course-title

 + use relative import for responses.py
 + removed commented-out utterances

* extracted response-texts/utterances from actions_recommender.py

* FIX explicitly load YAML files with UTF-8 encoding

* WORKAROUND for BUG in socket.io adapter: do not dispatch utterances with empty text (i.e. avoid buttons-only utterances)

NOTE currently socket.io adapter will cause error on encountering messages with empty/None text, e.g. messages that only contain a button group
WORKAROUND do include some (non-empty) text when dispatching button-groups within the same message

* IMPROVE only query course_title once per action invocation from responses

* REFACTOR extract/use response-strings for course-titles

* IMPROVE only query course_title once per action invocation from responses (2)

* NOOP

re-formatted to match formatting in
rasa/KI-Campus_en/actions/actions.py

* extracted English response texts

* adapted docker for English chatbot for response-text loading

* FIX disabled installing spacy model since NLU pipeline was reverted to not use spacy NLP

* FIX instructions for starting action server to ensure that all actions are started

i.e. also actions that are located in other python-files under actions/*.py, other than actions.py

* IMPROVE documentation of parameters in response-texts

* implemented new slot type

* small correction domain

* implemented login check & querying user profile & using profile data for recommendations

* REVERT removed activation/configuration for socketio

* small updates stories

* BUGFIX initialize variable "response" for all cases / code-paths

* FIX handle empty/None values for slots in actions

* FIX handle empty/None values for slots in validate-action

* added line-break after debug-output & marked all print-debug instructions with DEV comment FIXME DEBUG

* NOOP (removed unused import)

* FIX WORKAROUND to ensure that the message-text precedes button-list

* workaround slot validation

* HACK fix removed/missing intent utter_end_of_conversation

temporary fix missing intent that was removed from
domain.yml
-> old version for intent copied to
DFKIBot_de/domain.yml

* REFACTOR extract language code for achievements-request from implementation file to labels file

* deleted end_of_conversation,

* KIC-Bot changed intent "inform" to "courses"

* rename coursesearch "recommender", update stories

* quick fix responses, cleanup

* response fix

* fixed action utterances

* FIX use separate endpoint-configuration for docker deployment, i.e. do enable local service in default endpoint-configuration

* disabled debug output

* BUGFIX delete reference of removed DEBUG action utter_course_form_slots

* added github-action for (testing) training rasa models upon PUSH

* remove (disabled) debug-output for python version from action

* disabled course recommender module

 * DISABLED import for course recommender module (sub-project DFKIBot_de)
 * REVERTED modified texts for greeting & goodbye
 * DISABLED additional tip-action (used in modified greeting)

Co-authored-by: TabeaOt <[email protected]>
Co-authored-by: Tabea Otten <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2022
1 parent 23b3f70 commit 3194ca7
Show file tree
Hide file tree
Showing 36 changed files with 3,159 additions and 64 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/train-rasa-models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test training rasa models

on: [push]

jobs:
train:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 rasa[full]==3.2.5
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Train models with rasa (DE)
run: |
rasa train
working-directory: rasa/KI-Campus_de
- name: Train models with rasa (EN)
run: |
rasa train
working-directory: rasa/KI-Campus_en
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Created by https://www.gitignore.io/api/linux,macos,windows,visualstudio

## exclude virtual env
chatbot-env

## exclude models folder ##
rasa/models/*

Expand Down Expand Up @@ -373,3 +376,4 @@ graph.html
keras.json
global.yml
.bash_history
/rasa/KI-Campus_de/kic_recommender.yml
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ Choose the folder with the chatbot in English (KI-Campus_en) or in German (KI-Ca
rasa train
```

## Configuration

### Course Recommender Endpoint

> __NOTE__ Currently only supported for German chabot (`rasa/KI-Campus_de/`)
Create (or modify) the configuration file `kic_recommender.yml` in directory
```
rasa/KI-Campus_de/
```

and add/modify configuration entry for Course Recommender Endpoint with the
base URL for the endpoint and the access token:
```yml
# This file contains the custom service endpoints your bot can use.

# recommender service (DFKI) configuration
recommender_api:
url: "<base URL for recommender service endpoint>"
token: "<recommender access token>"

```

## Usage

### Start the Rasa Server
Expand All @@ -19,10 +42,34 @@ Choose the folder with the chatbot in English (KI-Campus_en) or in German (KI-Ca
### Start the Action Server

```sh
cd actions/
rasa run actions
```

NOTE the actions **must not** be started from within the `actions/` sub-directory,
but the `rasa` project's root directory (e.g. `rasa/KI-Campus_de/`),
otherwise not all actions may be automatically started.

### Start for Development

Change configuration to _'for local development'_ endpoint in `endpoints.yml` in sub-directories
```
rasa/KI-Campus_de/
rasa/KI-Campus_en/
```

then (within the respective directory) start the chatbot shell with

```sh
rasa shell
```

for testing logged-in user, get your `access-token` from the ki-campus website and start shell with

```sh
rasa shell --conversation-id <access-token>
```


## Docker

In the outer project structure run:
Expand Down
4 changes: 3 additions & 1 deletion docker-compose_de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
build:
context: ./rasa/KI-Campus_de
volumes:
- "./rasa/KI-Campus_de:/app"
- "./rasa/KI-Campus_de:/app"
ports:
- "12345:5005"
# Server Port: 12345:5005
Expand All @@ -18,5 +18,7 @@ services:
volumes:
- ./rasa/KI-Campus_de/actions:/app/actions
- ./rasa/KI-Campus_de/data:/app/data
- ./rasa/KI-Campus_de/action_responses:/app/action_responses
- ./rasa/KI-Campus_de/kic_recommender.yml:/app/kic_recommender.yml
ports:
- 5045:5055
3 changes: 2 additions & 1 deletion docker-compose_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
build:
context: ./rasa/KI-Campus_en
volumes:
- "./rasa/KI-Campus_en:/app"
- "./rasa/KI-Campus_en:/app"
ports:
- "54321:5005"
# Server Port: 54321:5005
Expand All @@ -18,5 +18,6 @@ services:
volumes:
- ./rasa/KI-Campus_en/actions:/app/actions
- ./rasa/KI-Campus_en/data:/app/data
- ./rasa/KI-Campus_en/action_responses:/app/action_responses
ports:
- 5055:5055
71 changes: 71 additions & 0 deletions rasa/KI-Campus_de/DFKIBot_de/data/dfki_faq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: '3.1'

nlu:

- intent: interjection_time
examples: |
- Meinst du wöchentlich ?
- Meinst du monatlich ?
- Meinst du stündlich ?
- Den Monat ?
- In einem Monat ?
- Die Woche ?
- In einer Woche ?
- Wie ist die Dauer gemeint?
- Wie ist die Zeitangabe gemeint?
- Wie ist die Stundenzahl gemeint?
- Wie ist die Zeitraum gemeint?
- pro Woche?
- pro Monat?
- Erkläre die Dauer
- Erkläre die Zeitangabe
- Erkläre die Stundenzahl
- Erkläre die Zeitraum
- intent: interjection_costs
examples: |
- Wie teuer ist das ?
- Wie teuer sind die Kurse ?
- Wie teuer ?
- Kostet die Kurse was?
- Kostet das was?
- Wie sind die Kosten für die Kurse ?
- Wie sind die Kosten ?
- Wie sind die Preise für die Kurse ?
- Wie sind die Preise ?
- Was sind die Kosten für die Kurse ?
- Was sind die Kosten ?
- Was sind die Preise für die Kurse ?
- Was sind die Preise ?
- Muss man die Kurse bezahlen?
- Muss man Geld bezahlen?
- Sind die Kurse frei ?
- Sind die Kurse kostenlos ?
- intent: interjection_languages
examples: |
- Welche Sprachen verwendet ihr?
- Welche Sprachen habt ihr?
- Gibt es auch alternative ?
- Gibt es auch mehr ?
- Gibt es auch andere Sprachen ?
- Bitte Sprachoptionen?
- Mehr Sprachoptionen?
- Weitere Sprachoptionen?
- Sprachoptionen?
- Habt ihr nur [Deutsch](language)?
- Habt ihr nur [Englisch](language)?
- andere Sprachen
- intent: interjection_topic
examples: |
- Habt ihr auch andere Themen?
- Weitere Themenfelder
- Mehr Themen
- Habt ihr auch Kurse zu [Statistik]{"entity": "topic", "value": "Einführung R"}
- Gibt es auch was über [Statistik]{"entity": "topic", "value": "Einführung R"}
- Andere Themen
- Kannst du mir mehr Themen nennen?
- Ich suche ein anderes Thema
- Anderes Thema
- Anderes Themenfeld
114 changes: 114 additions & 0 deletions rasa/KI-Campus_de/DFKIBot_de/data/interactive_nlu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
version: "3.1"
nlu:
- intent: greet
examples: |
- hi
- hallo kim
- hi kim
- hallöchen
- heyho
- intent: start_recommender_form
examples: |
- kannst du mir einen kurs suchen
- ich suche einen kurs
- ich suche nen kurs zum thema [ki]{"entity": "topic", "value": "KI"}
- empfehle mir einen kurs!
- dann gib mir eine empfehlung
- starte die kurssuche
- gib mir mal ne empfehlung
- intent: affirm
examples: |
- ja
- intent: negative_feedback
examples: |
- das waren schlechte Empfehlungen
- intent: change_language_slot
examples: |
- kannst du die sprache der empfehlung ändern?
- Kann ich die Sprache ändern?
- ändere die Sprache auf [Englisch]{"entity": "language", "value": "englisch"}
- kannst du die sprache auf [deutsch](language) ändern?
- mach mit der kurssuche weiter
- intent: additional_learning_recommendation
examples: |
- gib mir weitere empfehlungen
- hast du noch mehr empfehlungen für mich?
- gib mir zusätzliche empfehlungen
- intent: thank
examples: |
- danke das wars
- das wars
- Danke das war alles
- danke
- intent: deny
examples: |
- nein
- nein danke
- gar nicht
- intent: interjection_languages
examples: |
- welche sprachen habt ihr noch
- welche sprachen habt ir?
- intent: interjection_costs
examples: |
- Kosten die Kurse was?
- intent: interjection_topic
examples: |
- was für themen habt ihr überhaupt?
- was für themen habt ihr sonst noch?
- intent: change_topic_slot
examples: |
- hast du mehr empfehlungen zum thema [ki]{"entity": "topic", "value": "KI"}?
- Kannst du das Thema bitte ändern für die Empfehlung
- Kannst du das thema auf [ML]{"entity": "topic", "value": "Maschinelles Lernen"} ändern?
- ändere das Thema der Empfehlung
- intent: faq
examples: |
- Was ist KI?
- an wen richtet sich der KI Campus
- Was ist ein MOOC
- kannst du mir erklären was ki ist
- intent: get_courses
examples: |
- zeige mir meine Kurse
- in welche kurse bin ich eingeschrieben?
- intent: stop_form
examples: |
- abbrechen
- bitte abbrechen
- intent: change_max_duration_slot
examples: |
- Ändere die Dauer der Kurse
- intent: get_achievements
examples: |
- Welche Leistungen habe ich bereits?
- intent: change_level_slot
examples: |
- ich möchte doch auch empfehlungen für [experten]{"entity": "level", "value": "Experte"} bekommen
- intent: change_certificate_slot
examples: |
- kannst du mir auch kurse ohne [zertifikat]{"entity": "certificate", "value": "Leistungsnachweis"} empfehlen
- intent: goodbye
examples: |
- Tschüss
- intent: inform
examples: |
- hast du auch [russisch](language)
- intent: help
examples: |
- hilfe
- synonym: KI
examples: |
- ki
- synonym: englisch
examples: |
- Englisch
- synonym: Maschinelles Lernen
examples: |
- ML
- synonym: Experte
examples: |
- experten
- synonym: Leistungsnachweis
examples: |
- zertifikat
Loading

0 comments on commit 3194ca7

Please sign in to comment.