dc6079821b
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
91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
from typing import Text, List, Optional, Union, TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from rasa.shared.core.domain import Domain
|
|
from rasa.shared.core.generator import TrackerWithCachedStates
|
|
from rasa.shared.core.training_data.structures import StoryGraph
|
|
from rasa.shared.importers.importer import TrainingDataImporter
|
|
|
|
|
|
def extract_story_graph(
|
|
resource_name: Text, domain: "Domain", exclusion_percentage: Optional[int] = None
|
|
) -> "StoryGraph":
|
|
"""Loads training stories / rules from file or directory.
|
|
|
|
Args:
|
|
resource_name: Path to file or directory.
|
|
domain: The model domain.
|
|
exclusion_percentage: Percentage of stories which should be dropped. `None`
|
|
if all training data should be used.
|
|
|
|
Returns:
|
|
The loaded training data as graph.
|
|
"""
|
|
from rasa.shared.core.training_data.structures import StoryGraph
|
|
import rasa.shared.core.training_data.loading as core_loading
|
|
|
|
story_steps = core_loading.load_data_from_resource(
|
|
resource_name, domain, exclusion_percentage=exclusion_percentage
|
|
)
|
|
return StoryGraph(story_steps)
|
|
|
|
|
|
def load_data(
|
|
resource_name: Union[Text, "TrainingDataImporter"],
|
|
domain: "Domain",
|
|
remove_duplicates: bool = True,
|
|
unique_last_num_states: Optional[int] = None,
|
|
augmentation_factor: int = 50,
|
|
tracker_limit: Optional[int] = None,
|
|
use_story_concatenation: bool = True,
|
|
debug_plots: bool = False,
|
|
exclusion_percentage: Optional[int] = None,
|
|
) -> List["TrackerWithCachedStates"]:
|
|
"""
|
|
Load training data from a resource.
|
|
|
|
Args:
|
|
resource_name: resource to load the data from. either a path or an importer
|
|
domain: domain used for loading
|
|
remove_duplicates: should duplicated training examples be removed?
|
|
unique_last_num_states: number of states in a conversation that make the
|
|
a tracker unique (this is used to identify duplicates)
|
|
augmentation_factor:
|
|
by how much should the story training data be augmented
|
|
tracker_limit:
|
|
maximum number of trackers to generate during augmentation
|
|
use_story_concatenation:
|
|
should stories be concatenated when doing data augmentation
|
|
debug_plots:
|
|
generate debug plots during loading
|
|
exclusion_percentage:
|
|
how much data to exclude
|
|
|
|
Returns:
|
|
list of loaded trackers
|
|
"""
|
|
from rasa.shared.core.generator import TrainingDataGenerator
|
|
from rasa.shared.importers.importer import TrainingDataImporter
|
|
|
|
if resource_name:
|
|
if isinstance(resource_name, TrainingDataImporter):
|
|
graph = resource_name.get_stories(exclusion_percentage=exclusion_percentage)
|
|
else:
|
|
graph = extract_story_graph(
|
|
resource_name, domain, exclusion_percentage=exclusion_percentage
|
|
)
|
|
|
|
g = TrainingDataGenerator(
|
|
graph,
|
|
domain,
|
|
remove_duplicates,
|
|
unique_last_num_states,
|
|
augmentation_factor,
|
|
tracker_limit,
|
|
use_story_concatenation,
|
|
debug_plots,
|
|
)
|
|
return g.generate()
|
|
else:
|
|
return []
|