Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
from azure.cognitiveservices.language.luis.runtime.models import LuisResult
from msrest.authentication import CognitiveServicesCredentials

from botbuilder.core import BotAssert, IntentScore, RecognizerResult, TurnContext
from botbuilder.core import (
BotAssert,
IntentScore,
Recognizer,
RecognizerResult,
TurnContext,
)
from botbuilder.schema import ActivityTypes

from . import LuisApplication, LuisPredictionOptions, LuisTelemetryConstants
from .activity_util import ActivityUtil
from .luis_util import LuisUtil


class LuisRecognizer:
class LuisRecognizer(Recognizer):
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm - not sure if this is for Luis V3 or old one, but looking at C#, there's another level of TelemetryRecognizer if you want to be faithful to that..

Copy link
Member Author

Choose a reason for hiding this comment

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

Old one. Yes, but that interface only provide more method overloading (not supported in python) and attributes (not supported in the ABC pattern), making it redundant.

The idea here is to provide an interface that can be used at testing, where this ABC is sufficient.

"""
A LUIS based implementation of <see cref="IRecognizer"/>.
"""
Expand Down Expand Up @@ -95,7 +101,7 @@ def top_intent(

return top_intent or default_intent

async def recognize(
async def recognize( # pylint: disable=arguments-differ
self,
turn_context: TurnContext,
telemetry_properties: Dict[str, str] = None,
Expand Down
6 changes: 3 additions & 3 deletions libraries/botbuilder-core/botbuilder/core/recognizer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from abc import ABC
from abc import ABC, abstractmethod
from .turn_context import TurnContext
from .recognizer_result import RecognizerResult


class Recognizer(ABC):
@staticmethod
async def recognize(turn_context: TurnContext) -> RecognizerResult:
@abstractmethod
async def recognize(self, turn_context: TurnContext) -> RecognizerResult:
raise NotImplementedError()