Skip to content

Commit 4673a57

Browse files
authored
Merge branch 'master' into daveta-appinsights-sample
2 parents 1403611 + ac4fa17 commit 4673a57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4678
-2789
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ __pycache__/
44

55
# Virtual environment
66
env*/
7+
venv*/
78

89
# PTVS analysis
910
.ptvs/

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

libraries/botbuilder-ai/README.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
============================
3+
BotBuilder-AI SDK for Python
4+
============================
5+
6+
.. image:: https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Python/SDK_v4-Python-CI?branchName=master
7+
:target: https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Python/SDK_v4-Python-CI
8+
:align: right
9+
:alt: Azure DevOps status for master branch
10+
.. image:: https://badge.fury.io/py/botbuilder-ai.svg
11+
:target: https://badge.fury.io/py/botbuilder-ai
12+
:alt: Latest PyPI package version
13+
14+
Cognitive services extensions for Microsoft BotBuilder.
15+
16+
17+
How to Install
18+
==============
19+
20+
.. code-block:: python
21+
22+
pip install botbuilder-ai
23+
24+
25+
Documentation/Wiki
26+
==================
27+
28+
You can find more information on the botbuilder-python project by visiting our `Wiki`_.
29+
30+
Requirements
31+
============
32+
33+
* `Python >= 3.7.0`_
34+
35+
36+
Source Code
37+
===========
38+
The latest developer version is available in a github repository:
39+
https://github.com/Microsoft/botbuilder-python/
40+
41+
42+
Contributing
43+
============
44+
45+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
46+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
47+
the rights to use your contribution. For details, visit https://cla.microsoft.com.
48+
49+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
50+
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
51+
provided by the bot. You will only need to do this once across all repos using our CLA.
52+
53+
This project has adopted the `Microsoft Open Source Code of Conduct`_.
54+
For more information see the `Code of Conduct FAQ`_ or
55+
contact `[email protected]`_ with any additional questions or comments.
56+
57+
Reporting Security Issues
58+
=========================
59+
60+
Security issues and bugs should be reported privately, via email, to the Microsoft Security
61+
Response Center (MSRC) at `[email protected]`_. You should
62+
receive a response within 24 hours. If for some reason you do not, please follow up via
63+
email to ensure we received your original message. Further information, including the
64+
`MSRC PGP`_ key, can be found in
65+
the `Security TechCenter`_.
66+
67+
License
68+
=======
69+
70+
Copyright (c) Microsoft Corporation. All rights reserved.
71+
72+
Licensed under the MIT_ License.
73+
74+
.. _Wiki: https://github.com/Microsoft/botbuilder-python/wiki
75+
.. _Python >= 3.7.0: https://www.python.org/downloads/
76+
.. _MIT: https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
77+
.. _Microsoft Open Source Code of Conduct: https://opensource.microsoft.com/codeofconduct/
78+
.. _Code of Conduct FAQ: https://opensource.microsoft.com/codeofconduct/faq/
79+
80+
81+
.. _MSRC PGP: https://technet.microsoft.com/en-us/security/dn606155
82+
.. _Security TechCenter: https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
83+
84+
.. <https://technet.microsoft.com/en-us/security/default>`_

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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ async def recognize(
154154
turn_context: TurnContext,
155155
telemetry_properties: Dict[str, str] = None,
156156
telemetry_metrics: Dict[str, float] = None,
157+
luis_prediction_options: LuisPredictionOptions = None
157158
) -> RecognizerResult:
158159
"""Return results of the analysis (Suggested actions and intents).
159160
@@ -168,7 +169,7 @@ async def recognize(
168169
"""
169170

170171
return await self._recognize_internal(
171-
turn_context, telemetry_properties, telemetry_metrics
172+
turn_context, telemetry_properties, telemetry_metrics, luis_prediction_options
172173
)
173174

174175
def on_recognizer_result(
@@ -288,6 +289,7 @@ async def _recognize_internal(
288289
turn_context: TurnContext,
289290
telemetry_properties: Dict[str, str],
290291
telemetry_metrics: Dict[str, float],
292+
luis_prediction_options: LuisPredictionOptions = None
291293
) -> RecognizerResult:
292294

293295
BotAssert.context_not_none(turn_context)
@@ -299,6 +301,11 @@ async def _recognize_internal(
299301
recognizer_result: RecognizerResult = None
300302
luis_result: LuisResult = None
301303

304+
if luis_prediction_options:
305+
options = self._merge_options(luis_prediction_options)
306+
else:
307+
options = self._options
308+
302309
if not utterance or utterance.isspace():
303310
recognizer_result = RecognizerResult(
304311
text=utterance, intents={"": IntentScore(score=1.0)}, entities={}
@@ -307,12 +314,12 @@ async def _recognize_internal(
307314
luis_result = self._runtime.prediction.resolve(
308315
self._application.application_id,
309316
utterance,
310-
timezone_offset=self._options.timezone_offset,
311-
verbose=self._options.include_all_intents,
312-
staging=self._options.staging,
313-
spell_check=self._options.spell_check,
314-
bing_spell_check_subscription_key=self._options.bing_spell_check_subscription_key,
315-
log=self._options.log if self._options.log is not None else True,
317+
timezone_offset=options.timezone_offset,
318+
verbose=options.include_all_intents,
319+
staging=options.staging,
320+
spell_check=options.spell_check,
321+
bing_spell_check_subscription_key=options.bing_spell_check_subscription_key,
322+
log=options.log if options.log is not None else True,
316323
)
317324

318325
recognizer_result = RecognizerResult(
@@ -322,8 +329,8 @@ async def _recognize_internal(
322329
entities=LuisUtil.extract_entities_and_metadata(
323330
luis_result.entities,
324331
luis_result.composite_entities,
325-
self._options.include_instance_data
326-
if self._options.include_instance_data is not None
332+
options.include_instance_data
333+
if options.include_instance_data is not None
327334
else True,
328335
),
329336
)
@@ -336,7 +343,7 @@ async def _recognize_internal(
336343
recognizer_result, turn_context, telemetry_properties, telemetry_metrics
337344
)
338345

339-
await self._emit_trace_info(turn_context, luis_result, recognizer_result)
346+
await self._emit_trace_info(turn_context, luis_result, recognizer_result, options)
340347

341348
return recognizer_result
342349

@@ -345,11 +352,12 @@ async def _emit_trace_info(
345352
turn_context: TurnContext,
346353
luis_result: LuisResult,
347354
recognizer_result: RecognizerResult,
355+
options: LuisPredictionOptions
348356
) -> None:
349357
trace_info: Dict[str, object] = {
350358
"recognizerResult": LuisUtil.recognizer_result_as_dict(recognizer_result),
351359
"luisModel": {"ModelID": self._application.application_id},
352-
"luisOptions": {"Staging": self._options.staging},
360+
"luisOptions": {"Staging": options.staging},
353361
"luisResult": LuisUtil.luis_result_as_dict(luis_result),
354362
}
355363

@@ -362,3 +370,11 @@ async def _emit_trace_info(
362370
)
363371

364372
await turn_context.send_activity(trace_activity)
373+
374+
def _merge_options(
375+
self,
376+
user_defined_options: LuisPredictionOptions
377+
) -> LuisPredictionOptions:
378+
merged_options = LuisPredictionOptions()
379+
merged_options.__dict__.update(user_defined_options.__dict__)
380+
return merged_options

libraries/botbuilder-ai/setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@
2222
info = f.read()
2323
exec(info, package_info)
2424

25+
with open(os.path.join(root, 'README.rst'), encoding='utf-8') as f:
26+
long_description = f.read()
27+
2528
setup(
2629
name=package_info["__title__"],
2730
version=package_info["__version__"],
2831
url=package_info["__uri__"],
2932
author=package_info["__author__"],
3033
description=package_info["__description__"],
3134
keywords="botbuilder-ai LUIS QnAMaker bots ai botframework botbuilder",
32-
long_description=package_info["__summary__"],
35+
long_description=long_description,
36+
long_description_content_type='text/x-rst',
3337
license=package_info["__license__"],
3438
packages=["botbuilder.ai", "botbuilder.ai.qna", "botbuilder.ai.luis"],
3539
install_requires=REQUIRES + TESTS_REQUIRES,
3640
tests_require=TESTS_REQUIRES,
3741
include_package_data=True,
3842
classifiers=[
39-
"Programming Language :: Python :: 3.6",
43+
"Programming Language :: Python :: 3.7",
4044
"Intended Audience :: Developers",
4145
"License :: OSI Approved :: MIT License",
4246
"Operating System :: OS Independent",

libraries/botbuilder-ai/tests/luis/luis_recognizer_test.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,42 @@ async def test_telemetry_no_override_async(self):
635635
self.assertTrue("fromId" in call0_args[1])
636636
self.assertTrue("entities" in call0_args[1])
637637

638+
def test_pass_luis_prediction_options_to_recognizer(self):
639+
# Arrange
640+
my_app = LuisApplication(
641+
LuisRecognizerTest._luisAppId,
642+
LuisRecognizerTest._subscriptionKey,
643+
endpoint=None,
644+
)
645+
646+
luis_prediction_options = LuisPredictionOptions(
647+
log_personal_information=True, include_all_intents=True, include_instance_data=True
648+
)
649+
650+
# Assert
651+
recognizer = LuisRecognizer(my_app)
652+
merged_options = recognizer._merge_options(luis_prediction_options)
653+
self.assertTrue(merged_options.log_personal_information)
654+
self.assertTrue(merged_options.include_all_intents)
655+
self.assertTrue(merged_options.include_instance_data)
656+
self.assertFalse(recognizer._options.log_personal_information)
657+
self.assertFalse(recognizer._options.include_all_intents)
658+
self.assertFalse(recognizer._options.include_instance_data)
659+
660+
def test_dont_pass_luis_prediction_options_to_recognizer(self):
661+
# Arrange
662+
my_app = LuisApplication(
663+
LuisRecognizerTest._luisAppId,
664+
LuisRecognizerTest._subscriptionKey,
665+
endpoint=None,
666+
)
667+
668+
# Assert
669+
recognizer = LuisRecognizer(my_app)
670+
self.assertFalse(recognizer._options.log_personal_information)
671+
self.assertFalse(recognizer._options.include_all_intents)
672+
self.assertFalse(recognizer._options.include_instance_data)
673+
638674
async def test_composite1(self):
639675
await self._test_json("Composite1.json")
640676

libraries/botbuilder-applicationinsights/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ BotBuilder-ApplicationInsights SDK for Python
77
:target: https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Python/SDK_v4-Python-CI
88
:align: right
99
:alt: Azure DevOps status for master branch
10-
.. image:: https://badge.fury.io/py/botbuilder-core.svg
11-
:target: https://badge.fury.io/py/botbuilder-core
10+
.. image:: https://badge.fury.io/py/botbuilder-applicationinsights.svg
11+
:target: https://badge.fury.io/py/botbuilder-applicationinsights
1212
:alt: Latest PyPI package version
1313

1414
Within the Bot Framework, BotBuilder-ApplicationInsights enables the Azure Application Insights service.
@@ -33,7 +33,7 @@ You can find more information on the botbuilder-python project by visiting our `
3333
Requirements
3434
============
3535

36-
* `Python >= 3.6.8`_
36+
* `Python >= 3.7.0`_
3737

3838

3939
Source Code
@@ -75,7 +75,7 @@ Copyright (c) Microsoft Corporation. All rights reserved.
7575
Licensed under the MIT_ License.
7676

7777
.. _Wiki: https://github.com/Microsoft/botbuilder-python/wiki
78-
.. _Python >= 3.6.8: https://www.python.org/downloads/
78+
.. _Python >= 3.7.0: https://www.python.org/downloads/
7979
.. _MIT: https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
8080
.. _Microsoft Open Source Code of Conduct: https://opensource.microsoft.com/codeofconduct/
8181
.. _Code of Conduct FAQ: https://opensource.microsoft.com/codeofconduct/faq/

libraries/botbuilder-applicationinsights/django_tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Django generates *code* to create projects (`django-admin startproject`) and app
99

1010
File | | Description
1111
--- | ---
12-
all_tests.sh | Runs our current test matrix of python/django versions. Current matrix is python (3.6) and django (2.2).
12+
all_tests.sh | Runs our current test matrix of python/django versions. Current matrix is python (3.7) and django (2.2).
1313
README.md | This file.
1414
run_test.sh | Runs specific python/django version to create project, copy replacement files and runs tests.
1515
template.html | Template file

libraries/botbuilder-applicationinsights/django_tests/all_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BASEDIR=$(pwd)
1111

1212
# Django/python compatibility matrix...
1313
if $PYTHON -c "import sys; sys.exit(1 if (sys.version_info.major == 3 and sys.version_info.minor == 6) else 0)"; then
14-
echo "[Error] Environment should be configured with Python 3.6!" 1>&2
14+
echo "[Error] Environment should be configured with Python 3.7!" 1>&2
1515
exit 2
1616
fi
1717
# Add more versions here (space delimited).

libraries/botbuilder-applicationinsights/setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,25 @@
2424
info = f.read()
2525
exec(info, package_info)
2626

27+
with open(os.path.join(root, 'README.rst'), encoding='utf-8') as f:
28+
long_description = f.read()
29+
2730
setup(
2831
name=package_info['__title__'],
2932
version=package_info['__version__'],
3033
url=package_info['__uri__'],
3134
author=package_info['__author__'],
3235
description=package_info['__description__'],
3336
keywords=['BotBuilderApplicationInsights', 'bots', 'ai', 'botframework', 'botbuilder'],
34-
long_description=package_info['__summary__'],
37+
long_description=long_description,
38+
long_description_content_type='text/x-rst',
3539
license=package_info['__license__'],
3640
packages=['botbuilder.applicationinsights','botbuilder.applicationinsights.django' ],
3741
install_requires=REQUIRES + TESTS_REQUIRES,
3842
tests_require=TESTS_REQUIRES,
3943
include_package_data=True,
4044
classifiers=[
41-
'Programming Language :: Python :: 3.6',
45+
'Programming Language :: Python :: 3.7',
4246
'Intended Audience :: Developers',
4347
'License :: OSI Approved :: MIT License',
4448
'Operating System :: OS Independent',

0 commit comments

Comments
 (0)