chore: import upstream snapshot with attribution
Docs Tests / Check for file changes (push) Has been cancelled
Docs Tests / Test Documentation (push) Has been cancelled
Docs Tests / Documentation Linting Checks (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-policies) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.8, test-policies) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.9, test-policies) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.10, test-policies) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.8, test-policies) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-performance) (push) Has been cancelled
Continuous Integration / Run Tests (windows-2022, 3.9, test-policies) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (ubuntu-24.04, 3.10) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (ubuntu-24.04, 3.8) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (ubuntu-24.04, 3.9) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (windows-2022, 3.10) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (windows-2022, 3.8) (push) Has been cancelled
Continuous Integration / Run Flaky Tests (windows-2022, 3.9) (push) Has been cancelled
Continuous Integration / Check for file changes (push) Has been cancelled
Continuous Integration / Wait for docs tests (push) Has been cancelled
Continuous Integration / Code Quality (push) Has been cancelled
Continuous Integration / Check for changelog (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-cli) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-core-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-full-model-training) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-nlu-featurizers) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-nlu-predictors) (push) Has been cancelled
Continuous Integration / Run Tests (ubuntu-24.04, 3.10, test-other-unit-tests) (push) Has been cancelled
Continuous Integration / Upload coverage reports to codeclimate (push) Has been cancelled
Continuous Integration / Run Non-Sequential Integration Tests (push) Has been cancelled
Continuous Integration / Run Broker Integration Tests (push) Has been cancelled
Continuous Integration / Run Sequential Integration Tests (push) Has been cancelled
Continuous Integration / Build Docker base images and setup environment (push) Has been cancelled
Continuous Integration / Build Docker (default) (push) Has been cancelled
Continuous Integration / Build Docker (full) (push) Has been cancelled
Continuous Integration / Build Docker (mitie-en) (push) Has been cancelled
Continuous Integration / Build Docker (spacy-de) (push) Has been cancelled
Continuous Integration / Build Docker (spacy-en) (push) Has been cancelled
Continuous Integration / Build Docker (spacy-it) (push) Has been cancelled
Continuous Integration / Deploy to PyPI (push) Has been cancelled
Continuous Integration / Notify Slack & Publish Release Notes (push) Has been cancelled
Publish Documentation / Evaluate release tag (push) Has been cancelled
Publish Documentation / Prebuild Docs (push) Has been cancelled
Publish Documentation / Preview Docs (push) Has been cancelled
Publish Documentation / Check for file changes (push) Has been cancelled
Publish Documentation / Publish Docs (push) Has been cancelled
Automatic PR Merger / mergepal (push) Has been cancelled
CI Github Actions / Run Tests (push) Has been cancelled
Semgrep / Semgrep Workflow Security Scan (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:24:47 +08:00
commit dc6079821b
1384 changed files with 261110 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# Knowledge Base Bot
This example bot uses a knowledge base to answer user's requests.
## Whats inside this example?
This example contains some training data and the main files needed to build an
assistant on your local machine. The `knowledgebasebot` consists of the following files:
- **data/nlu.yml** contains training examples for the NLU model
- **data/stories.yml** contains training stories for the Core model
- **actions/actions.py** contains the custom action for querying the knowledge base
- **config.yml** contains the model configuration
- **domain.yml** contains the domain of the assistant
- **endpoints.yml** contains the webhook configuration for the custom action
- **knowledge_base_data.json** contains the data for the knowledge base
## How to use this example?
To train your knowledge base bot, execute
```
rasa train
```
This will store a zipped model file in `models/`.
Start the action server by
```
rasa run actions
```
To chat with the bot on the command line, run
```
rasa shell
```
For more information about the individual commands, please check out our
[documentation](http://rasa.com/docs/rasa/command-line-interface).
## Encountered any issues?
Let us know about it by posting on [Rasa Community Forum](https://forum.rasa.com)!
@@ -0,0 +1,16 @@
from rasa_sdk.knowledge_base.storage import InMemoryKnowledgeBase
from rasa_sdk.knowledge_base.actions import ActionQueryKnowledgeBase
class ActionMyKB(ActionQueryKnowledgeBase):
def __init__(self):
# load knowledge base with data from the given file
knowledge_base = InMemoryKnowledgeBase("knowledge_base_data.json")
# overwrite the representation function of the hotel object
# by default the representation function is just the name of the object
knowledge_base.set_representation_function_of_object(
"hotel", lambda obj: obj["name"] + " (" + obj["city"] + ")"
)
super().__init__(knowledge_base)
+20
View File
@@ -0,0 +1,20 @@
recipe: default.v1
assistant_id: knowledge_base_bot
language: en
pipeline:
- name: "WhitespaceTokenizer"
- name: "RegexFeaturizer"
- name: "LexicalSyntacticFeaturizer"
- name: "CountVectorsFeaturizer"
- name: "CountVectorsFeaturizer"
analyzer: "char_wb"
min_ngram: 1
max_ngram: 4
- name: "DIETClassifier"
epochs: 100
- name: "EntitySynonymMapper"
policies:
- name: RulePolicy
+76
View File
@@ -0,0 +1,76 @@
version: "3.1"
nlu:
- intent: bot_challenge
examples: |
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
- intent: greet
examples: |
- hey
- hello
- hi
- good morning
- good evening
- hey there
- intent: goodbye
examples: |
- bye
- goodbye
- see you around
- see you later
- intent: query_knowledge_base
examples: |
- what [restaurants]{"entity": "object_type", "value": "restaurant"} can you recommend?
- list some [restaurants]{"entity": "object_type", "value": "restaurant"}
- can you name some [restaurants]{"entity": "object_type", "value": "restaurant"} please?
- can you show me some [restaurant]{"entity": "object_type", "value": "restaurant"} options
- list [German]{"entity": "cuisine"} [restaurants]{"entity": "object_type", "value": "restaurant"}
- do you have any [mexican]{"entity": "cuisine"} [restaurants]{"entity": "object_type", "value": "restaurant"}?
- do you know the [price range]{"entity": "attribute", "value": "price-range"} of [that one]{"entity": "mention"}?
- what [cuisine]{"entity": "attribute"} is [it]{"entity": "mention"}?
- do you know what [cuisine]{"entity": "attribute"} the [last one]{"entity": "mention", "value": "LAST"} has?
- does [Donath]{"entity": "restaurant"} have [outside seating]{"entity": "attribute", "value": "outside-seating"}?
- what is the [price range]{"entity": "attribute", "value": "price-range"} of [Berlin Burrito Company]{"entity": "restaurant"}?
- what is with [I due forni]{"entity": "restaurant"}?
- Do you also have any [Vietnamese]{"entity": "cuisine"} [restaurants]{"entity": "object_type", "value": "restaurant"}?
- What about any [Mexican]{"entity": "cuisine", "value": "mexican"} [restaurants]{"entity": "object_type", "value": "restaurant"}?
- Do you also know some [Italian]{"entity": "cuisine"} [restaurants]{"entity": "object_type", "value": "restaurant"}?
- can you tell me the [price range]{"entity": "attribute", "value": "price-range"} of [that restaurant]{"entity": "mention"}?
- what [cuisine]{"entity": "attribute"} do [they]{"entity": "mention"} have?
- what [hotels]{"entity": "object_type", "value": "hotel"} can you recommend?
- please list some [hotels]{"entity": "object_type", "value": "hotel"} in [Frankfurt am Main]{"entity": "city"} for me
- what [hotels]{"entity": "object_type", "value": "hotel"} do you know in [Berlin]{"entity": "city"}?
- name some [hotels]{"entity": "object_type", "value": "hotel"} in [Berlin]{"entity": "city"}
- show me some [hotels]{"entity": "object_type", "value": "hotel"}
- what are [hotels]{"entity": "object_type", "value": "hotel"} in [Berlin]{"entity": "city"}
- does the [last]{"entity": "mention", "value": "LAST"} one offer [breakfast]{"entity": "attribute", "value": "breakfast-included"}?
- does the [second one]{"entity": "mention", "value": "2"} [include breakfast]{"entity": "attribute", "value": "breakfast-included"}?
- what is the [price range]{"entity": "attribute", "value": "price-range"} of the [second]{"entity": "mention", "value": "2"} hotel?
- does the [first]{"entity": "mention", "value": "1"} one have [wifi]{"entity": "attribute", "value": "free-wifi"}?
- does the [third]{"entity": "mention", "value": "3"} one have a [swimming pool]{"entity": "attribute", "value": "swimming-pool"}?
- what is the [star rating]{"entity": "attribute", "value": "star-rating"} of [Berlin Wall Hostel]{"entity": "hotel"}?
- Does the [Hilton]{"entity": "hotel"} have a [swimming pool]{"entity": "attribute", "value": "swimming-pool"}?
- lookup: restaurant
examples: |
- Donath
- Berlin Burrito Company
- I due forni
- Lụa Restaurant
- Pfefferberg
- Marubi Ramen
- Gong Gan
- lookup: hotel
examples: |
- Hilton
- B&B
- Berlin Wall Hostel
- City Hotel
- Jugendherberge
- Berlin Hotel
+18
View File
@@ -0,0 +1,18 @@
version: "3.1"
rules:
- rule: greet
steps:
- intent: greet
- action: utter_greet
- rule: goodbye
steps:
- intent: goodbye
- action: utter_goodbye
- rule: query knowledge base
steps:
- intent: query_knowledge_base
- action: action_query_knowledge_base
- rule: bot challenge
steps:
- intent: bot_challenge
- action: utter_iamabot
@@ -0,0 +1,8 @@
version: "3.1"
stories:
- story: greet and then query knowledge base
steps:
- intent: greet
- action: utter_greet
- intent: query_knowledge_base
- action: action_query_knowledge_base
+84
View File
@@ -0,0 +1,84 @@
version: "3.1"
intents:
- greet
- goodbye
- query_knowledge_base
- bot_challenge
entities:
- object_type
- mention
- attribute
- hotel
- restaurant
- cuisine
- city
slots:
object_type:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: object_type
mention:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: mention
attribute:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: attribute
hotel:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: hotel
restaurant:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: restaurant
city:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: city
cuisine:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: cuisine
actions:
- action_query_knowledge_base
responses:
utter_greet:
- text: "Hey!"
- text: "Hello! How can I help you?"
utter_goodbye:
- text: "Bye"
- text: "Goodbye. See you soon."
utter_ask_rephrase:
- text: "Sorry, I'm not sure I understand. Can you rephrase?"
- text: "Can you please rephrase? I did not got that."
utter_iamabot:
- text: "I am a bot, powered by Rasa."
session_config:
session_expiration_time: 60 # value in minutes
carry_over_slots_to_new_session: true
+2
View File
@@ -0,0 +1,2 @@
action_endpoint:
url: "http://localhost:5055/webhook"
@@ -0,0 +1,125 @@
{
"restaurant": [
{
"id": 0,
"name": "Donath",
"cuisine": "Italian",
"outside-seating": true,
"price-range": "mid-range"
},
{
"id": 1,
"name": "Berlin Burrito Company",
"cuisine": "Mexican",
"outside-seating": false,
"price-range": "cheap"
},
{
"id": 2,
"name": "I due forni",
"cuisine": "Italian",
"outside-seating": true,
"price-range": "mid-range"
},
{
"id": 3,
"name": "Lụa Restaurant",
"cuisine": "Vietnamese",
"outside-seating": true,
"price-range": "cheap"
},
{
"id": 4,
"name": "Pfefferberg",
"cuisine": "German",
"outside-seating": true,
"price-range": "mid-range"
},
{
"id": 5,
"name": "Marubi Ramen",
"cuisine": "Japanese",
"outside-seating": false,
"price-range": "cheap"
},
{
"id": 6,
"name": "Gong Gan",
"cuisine": "Korean",
"outside-seating": true,
"price-range": "cheap"
}
],
"hotel": [
{
"id": 0,
"name": "Hilton",
"price-range": "expensive",
"breakfast-included": true,
"city": "Berlin",
"free-wifi": true,
"star-rating": 5,
"swimming-pool": true
},
{
"id": 1,
"name": "Hilton",
"price-range": "expensive",
"breakfast-included": true,
"city": "Frankfurt am Main",
"free-wifi": true,
"star-rating": 4,
"swimming-pool": false
},
{
"id": 2,
"name": "B&B",
"price-range": "mid-range",
"breakfast-included": false,
"city": "Berlin",
"free-wifi": false,
"star-rating": 1,
"swimming-pool": false
},
{
"id": 3,
"name": "Berlin Wall Hostel",
"price-range": "cheap",
"breakfast-included": false,
"city": "Berlin",
"free-wifi": true,
"star-rating": 2,
"swimming-pool": false
},
{
"id": 4,
"name": "City Hotel",
"price-range": "expensive",
"breakfast-included": true,
"city": "Frankfurt am Main",
"free-wifi": true,
"star-rating": 3,
"swimming-pool": false
},
{
"id": 5,
"name": "Jugendherberge",
"price-range": "cheap",
"breakfast-included": true,
"city": "Berlin",
"free-wifi": false,
"star-rating": 2,
"swimming-pool": false
},
{
"id": 6,
"name": "Berlin Hotel",
"price-range": "mid-range",
"breakfast-included": true,
"city": "Berlin",
"free-wifi": true,
"star-rating": 3,
"swimming-pool": true
}
]
}