-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move duckling loading to its own module (#7)
- Loading branch information
1 parent
57fb0fd
commit 62221f9
Showing
4 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
from datetime import datetime, timedelta | ||
from typing import List, Optional | ||
|
||
from rasa.shared.nlu.training_data.message import Message | ||
from rasa_sdk.interfaces import Action, Tracker | ||
from rasa_sdk.events import EventType, SlotSet | ||
from rasa_sdk.executor import CollectingDispatcher | ||
from rasa_sdk.interfaces import Action, Tracker | ||
from rasa_sdk.types import DomainDict | ||
from rasa.nlu.extractors.duckling_entity_extractor import DucklingEntityExtractor | ||
from typing import List, Optional | ||
|
||
duckling_config = {**DucklingEntityExtractor.get_default_config(), | ||
"url": "https://rasa:[email protected]", | ||
"dimensions": ["time"]} | ||
duckling = DucklingEntityExtractor(duckling_config) | ||
from actions.entity_extractor import duckling_entity_extractor | ||
|
||
|
||
class CheckRestaurantAvailability(Action): | ||
|
@@ -44,7 +40,7 @@ async def run( | |
|
||
def parse_datetime(text: str) -> Optional[datetime]: | ||
msg = Message.build(text) | ||
duckling.process([msg]) | ||
duckling_entity_extractor.process([msg]) | ||
if len(msg.data["entities"]) == 0: | ||
return None | ||
parsed_value = msg.data["entities"][0]["value"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from rasa.nlu.extractors.duckling_entity_extractor import DucklingEntityExtractor | ||
|
||
load_dotenv() | ||
duckling_url = os.environ.get("DUCKLING_URL") | ||
|
||
duckling_config = { | ||
**DucklingEntityExtractor.get_default_config(), | ||
"url": duckling_url, | ||
"dimensions": ["time"] | ||
} | ||
|
||
duckling_entity_extractor = DucklingEntityExtractor(duckling_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters