Skip to content

Commit

Permalink
entity extrctor fixed (#1697)
Browse files Browse the repository at this point in the history
* entity extrctor fixed

* contants added
  • Loading branch information
sfahad1414 authored Dec 24, 2024
1 parent 401afe0 commit d214b3d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion kairon/nlu/classifiers/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rasa.engine.storage.storage import ModelStorage
from rasa.nlu.classifiers.classifier import IntentClassifier
from rasa.nlu.extractors.extractor import EntityExtractorMixin
from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ENTITY_ATTRIBUTE_TYPE
from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ENTITY_ATTRIBUTE_TYPE, EXTRACTOR
from rasa.shared.nlu.training_data.message import Message
from rasa.shared.nlu.training_data.training_data import TrainingData
from rasa.shared.utils.io import create_directory_for_file
Expand Down Expand Up @@ -282,3 +282,21 @@ def persist(self) -> None:
io_utils.json_pickle(
os.path.join(model_path, data_file_name), self.data
)

def add_extractor_name(
self, entities: List[Dict[Text, Any]]
) -> List[Dict[Text, Any]]:
"""Adds this extractor's name to a list of entities.
Args:
entities: the extracted entities.
Returns:
the modified entities.
"""
entities_new = []
for entity in entities:
if isinstance(entity, dict):
entity[EXTRACTOR] = self.name
entities_new.append(entity.copy())
return entities_new

0 comments on commit d214b3d

Please sign in to comment.