Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entity extrctor fixed #1697

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Import or define the EXTRACTOR constant.

According to the static analysis hint (F821), EXTRACTOR is undefined. To fix this, add an appropriate definition or import. For example:

+ from rasa.shared.nlu.constants import EXTRACTOR

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Ruff (0.8.2)

300-300: Undefined name EXTRACTOR

(F821)

entities_new.append(entity.copy())
return entities_new
Loading