8000 fix: Corrections for errors in Skill Dialogs (#2110) · microsoft/botbuilder-python@3521ce3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3521ce3

Browse files
tracyboehrerTracy Boehrer
andauthored
fix: Corrections for errors in Skill Dialogs (#2110)
* Corrections for errors in Skill Dialogs * black formatting * black formatting (PS. VS Code Black Formatter does not do exactly same thing as pipeline) * Test correction for Skill Dialog fix --------- Co-authored-by: Tracy Boehrer <trboehre@microsoft.com>
1 parent 6a63f16 commit 3521ce3

File tree

30 files changed

+148
-119
lines changed

30 files changed

+148
-119
lines changed

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_helper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ def payload_to_activity(payload: SlackPayload) -> Activity:
128128
channel_id="slack",
129129
conversation=ConversationAccount(id=payload.channel["id"], properties={}),
130130
from_property=ChannelAccount(
131-
id=payload.message.bot_id
132-
if payload.message.bot_id
133-
else payload.user["id"]
131+
id=(
132+
payload.message.bot_id
133+
if payload.message.bot_id
134+
else payload.user["id"]
135+
)
134136
),
135137
recipient=ChannelAccount(),
136138
channel_data=payload,

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ def fill_luis_event_properties(
236236

237237
# Use the LogPersonalInformat 10000 ion flag to toggle logging PII data, text is a common example
238238
if self.log_personal_information and turn_context.activity.text:
239-
properties[
240-
LuisTelemetryConstants.question_property
241-
] = turn_context.activity.text
239+
properties[LuisTelemetryConstants.question_property] = (
240+
turn_context.activity.text
241+
)
242242

243243
# Additional Properties can override "stock" properties.
244244
if telemetry_properties is not None:

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer_v2.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ async def recognizer_internal(self, turn_context: TurnContext):
5353
staging=self.luis_recognizer_options_v2.staging,
5454
spell_check=self.luis_recognizer_options_v2.spell_check,
5555
bing_spell_check_subscription_key=self.luis_recognizer_options_v2.bing_spell_check_subscription_key,
56-
log=self.luis_recognizer_options_v2.log
57-
if self.luis_recognizer_options_v2.log is not None
58-
else True,
56+
log=(
57+
self.luis_recognizer_options_v2.log
58+
if self.luis_recognizer_options_v2.log is not None
59+
else True
60+
),
5961
)
6062

6163
recognizer_result: RecognizerResult = RecognizerResult(
@@ -65,9 +67,11 @@ async def recognizer_internal(self, turn_context: TurnContext):
6567
entities=LuisUtil.extract_entities_and_metadata(
6668
luis_result.entities,
6769
luis_result.composite_entities,
68-
self.luis_recognizer_options_v2.include_instance_data
69-
if self.luis_recognizer_options_v2.include_instance_data is not None
70-
else True,
70+
(
71+
self.luis_recognizer_options_v2.include_instance_data
72+
if self.luis_recognizer_options_v2.include_instance_data is not None
73+
else True
74+
),
7175
),
7276
)
7377

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer_v3.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ def _build_url(self):
116116
uri += "/slots/%s/predict" % (self.luis_recognizer_options_v3.slot)
117117

118118
params = "?verbose=%s&show-all-intents=%s&log=%s" % (
119-
"true"
120-
if self.luis_recognizer_options_v3.include_instance_data
121-
else "false",
119+
(
120+
"true"
121+
if self.luis_recognizer_options_v3.include_instance_data
122+
else "false"
123+
),
122124
"true" if self.luis_recognizer_options_v3.include_all_intents else "false",
123125
"true" if self.luis_recognizer_options_v3.log else "false",
124126
)

libraries/botbuilder-ai/botbuilder/ai/qna/dialogs/qnamaker_dialog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ async def __call_generate_answer(self, step_context: WaterfallStepContext):
248248
dialog_options.options.context = QnARequestContext()
249249

250250
# Storing the context info
251-
step_context.values[
252-
QnAMakerDialog.PROPERTY_CURRENT_QUERY
253-
] = step_context.context.activity.text
251+
step_context.values[QnAMakerDialog.PROPERTY_CURRENT_QUERY] = (
252+
step_context.context.activity.text
253+
)
254254

255255
# -Check if previous context is present, if yes then put it with the query
256256
# -Check for id if query is present in reverse index.

libraries/botbuilder-ai/botbuilder/ai/qna/models/ranker_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
class RankerTypes:
6-
76
"""Default Ranker Behaviour. i.e. Ranking based on Questions and Answer."""
87

98
DEFAULT = "Default"

libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ async def fill_qna_event(
182182
properties: Dict[str, str] = dict()
183183
metrics: Dict[str, float] = dict()
184184

185-
properties[
186-
QnATelemetryConstants.knowledge_base_id_property
187-
] = self._endpoint.knowledge_base_id
185+
properties[QnATelemetryConstants.knowledge_base_id_property] = (
186+
self._endpoint.knowledge_base_id
187+
)
188188

189189
text: str = turn_context.activity.text
190190
user_name: str = turn_context.activity.from_property.name

libraries/botbuilder-ai/botbuilder/ai/qna/utils/train_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ async def call_train(self, feedback_records: List[FeedbackRecord]):
4545
await self._query_train(feedback_records)
4646

4747
async def _query_train(self, feedback_records: List[FeedbackRecord]):
48-
url: str = f"{ self._endpoint.host }/knowledgebases/{ self._endpoint.knowledge_base_id }/train"
48+
url: str = (
49+
f"{ self._endpoint.host }/knowledgebases/{ self._endpoint.knowledge_base_id }/train"
50+
)
4951
payload_body = TrainRequestBody(feedback_records=feedback_records)
5052
http_request_helper = HttpRequestUtils(self._http_client)
5153

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,11 @@ async def create_conversation(
387387
name=ActivityEventNames.create_conversation,
388388
channel_id=channel_id,
389389
service_url=service_url,
390-
id=resource_response.activity_id
391-
if resource_response.activity_id
392-
else str(uuid.uuid4()),
390+
id=(
391+
resource_response.activity_id
392+
if resource_response.activity_id
393+
else str(uuid.uuid4())
394+
),
393395
conversation=ConversationAccount(
394396
id=resource_response.id,
395397
tenant_id=parameters.tenant_id,

libraries/botbuilder-core/botbuilder/core/cloud_adapter_base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ async def continue_conversation( # pylint: disable=arguments-differ
150150
self,
151151
reference: ConversationReference,
152152
callback: Callable,
153-
bot_app_id: str,
153+
bot_app_id: str = None, # pylint: disable=unused-argument
154+
claims_identity: ClaimsIdentity = None, # pylint: disable=unused-argument
155+
audience: str = None, # pylint: disable=unused-argument
154156
):
155157
"""
156158
Sends a proactive message to a conversation.
@@ -166,6 +168,14 @@ async def continue_conversation( # pylint: disable=arguments-differ
166168
and is generally found in the `MicrosoftAppId` parameter in `config.py`.
167169
:type bot_app_id: :class:`typing.str`
168170
"""
171+
if claims_identity:
172+
return await self.continue_conversation_with_claims(
173+
claims_identity=claims_identity,
174+
reference=reference,
175+
audience=audience,
176+
logic=callback,
177+
)
178+
169179
return await self.process_proa 4227 ctive(
170180
self.create_claims_identity(bot_app_id),
171181
get_continuation_activity(reference),

0 commit comments

Comments
 (0)
0