8000 core bot fixes to sample and libraries, still broken but initial prom… · rsliang/botbuilder-python@031055b · GitHub
[go: up one dir, main page]

Skip to content

Commit 031055b

Browse files
committed
core bot fixes to sample and libraries, still broken but initial prompt working
1 parent cf7d7f8 commit 031055b

File tree

10 files changed

+32
-25
lines changed

10 files changed

+32
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async def send_activities(self, context: TurnContext, activities: List[Activity]
194194
await asyncio.sleep(delay_in_ms)
195195
else:
196196
client = self.create_connector_client(activity.service_url)
197-
await client.conversations.send_to_conversation(activity.conversation.id, activity)
197+
client.conversations.send_to_conversation(activity.conversation.id, activity)
198198
except Exception as e:
199199
raise e
200200

libraries/botbuilder-core/botbuilder/core/memory_storage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ async def write(self, changes: Dict[str, StoreItem]):
3535
try:
3636
# iterate over the changes
3737
for (key, change) in changes.items():
38-
#import pdb; pdb.set_trace()
3938
new_value = change
4039
old_state = None
4140
old_state_etag = None

libraries/botbuilder-dialogs/botbuilder/dialogs/component_dialog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, dialog_id: str):
2626
raise TypeError('ComponentDialog(): dialog_id cannot be None.')
2727

2828
self._dialogs = DialogSet()
29+
self._initial_dialog_id = None
2930

3031
# TODO: Add TelemetryClient
3132

@@ -37,7 +38,7 @@ def initial_dialog_id(self) -> str:
3738
:param:
3839
:return str:ID of the dialog this instance is for.
3940
"""
40-
return self._id
41+
return self._initial_dialog_id
4142

4243
@initial_dialog_id.setter
4344
def initial_dialog_id(self, value: str) -> None:
@@ -46,7 +47,7 @@ def initial_dialog_id(self, value: str) -> None:
4647
:param value: ID of the dialog this instance is for.
4748
:return:
4849
"""
49-
self._id = value
50+
self._initial_dialog_id = value
5051

5152
async def begin_dialog(self, outer_dc: DialogContext, options: object = None) -> DialogTurnResult:
5253
if outer_dc is None:

libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_context.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ async def begin_dialog(self, dialog_id: str, options: object = None):
106106
self._stack.append(instance)
107107

108108
# Call dialog's begin_dialog() method
109-
import pdb; pdb.set_trace()
110109
return await dialog.begin_dialog(self, options)
111110

112111
# TODO: Fix options: PromptOptions instead of object

libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def __init__(self, dialog_id: str, validator: object = None):
4040
async def begin_dialog(self, dc: DialogContext, options: object) -> DialogTurnResult:
4141
if not dc:
4242
raise TypeError('Prompt(): dc cannot be None.')
43-
if not options is PromptOptions:
43+
if not isinstance(options, PromptOptions):
4444
raise TypeError('Prompt(): Prompt options are required for Prompt dialogs.')
4545
# Ensure prompts have input hint set
4646
if options.prompt != None and not options.prompt.input_hint:
4747
options.prompt.input_hint = InputHints.expecting_input
4848

49-
if options.RetryPrompt != None and not options.prompt.input_hint:
49+
if options.retry_prompt != None and not options.prompt.input_hint:
5050
options.retry_prompt.input_hint = InputHints.expecting_input
5151

5252
# Initialize prompt state

libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt_options.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
# Licensed under the MIT License.
33

44
from botbuilder.schema import Activity
5+
from botbuilder.dialogs.choices import Choice, ListStyle
56

67

78
class PromptOptions:
89

9-
def __init__(self, prompt: Activity = None, retry_prompt: Activity = None, choices: [] = None, style: object = None, validations: object = None, number_of_attempts: int = 0):
10-
self._prompt: prompt
11-
self._retry_prompt: retry_prompt
12-
# TODO: Replace with Choice Object once ported
13-
self._choices: choices
14-
# TODO: Replace with ListStyle Object once ported
10+
def __init__(self, prompt: Activity = None, retry_prompt: Activity = None, choices: [Choice] = None, style: ListStyle = None, validations: object = None, number_of_attempts: int = 0):
11+
self._prompt= prompt
12+
self._retry_prompt= retry_prompt
13+
self._choices= choices
1514
self._style = style
1615
self._validations = validations
1716
self._number_of_attempts = validations
@@ -49,13 +48,13 @@ def retry_prompt(self, value: Activity) -> None:
4948
self._retry_prompt = value
5049

5150
@property
52-
def choices(self) -> object:
51+
def choices(self) -> Choice:
5352
"""Gets the list of choices associated with the prompt.
5453
"""
5554
return self._choices
5655

5756
@choices.setter
58-
def choices(self, value: object) -> None:
57+
def choices(self, value: Choice) -> None:
5958
"""Sets the list of choices associated with the prompt.
6059
Parameters
6160
----------
@@ -65,13 +64,13 @@ def choices(self, value: object) -> None:
6564
self._choices = value
6665

6766
@property
68-
def style(self) -> object:
67+
def style(self) -> ListStyle:
6968
"""Gets the ListStyle for a ChoicePrompt.
7069
"""
7170
return self._style
7271

7372
@style.setter
74-
def style(self, value: object) -> None:
73+
def style(self, value: ListStyle) -> None:
7574
"""Sets the ListStyle for a ChoicePrompt.
7675
Parameters
7776
----------

libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/text_prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ async def on_prompt(self, turn_context: TurnContext, state: Dict[str, object], o
2323
raise TypeError('TextPrompt.on_prompt(): options cannot be None.')
2424

2525
if is_retry == True and options.retry_prompt != None:
26-
prompt = turn_context.send_activity(options.retry_prompt)
26+
await turn_context.send_activity(options.retry_prompt)
2727
else:
2828
if options.prompt != None:
29-
turn_context.send_activity(options.prompt)
29+
await turn_context.send_activity(options.prompt)
3030

3131

3232
async def on_recognize(self, turn_context: TurnContext, state: Dict[str, object], options: PromptOptions) -> PromptRecognizerResult:

libraries/botbuilder-dialogs/botbuilder/dialogs/waterfall_step_context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ class WaterfallStepContext(DialogContext):
1313

1414
def __init__(self, parent, dc: DialogContext, options: object, values: Dict[str, object], index: int, reason: DialogReason, result: object = None):
1515
super(WaterfallStepContext, self).__init__(dc.dialogs, dc.context, DialogState(dc.stack))
16-
self._parent = parent
16+
self._wf_parent = parent
1717
self._next_called = False
1818
self._index = index
1919
self._options = options
2020
self._reason = reason
2121
self._result = result
2222
self._values = values
23+
self.parent = dc.parent
2324

2425
@property
2526
def index(self) -> int:
@@ -39,8 +40,8 @@ def values(self) -> Dict[str,object]:
3940

4041
async def next(self, result: object) -> DialogTurnResult:
4142
if self._next_called is True:
42-
raise Exception("WaterfallStepContext.next(): method already called for dialog and step '%s'[%s]." % (self._parent.id, self._index))
43+
raise Exception("WaterfallStepContext.next(): method already called for dialog and step '%s'[%s]." % (self._wf_parent.id, self._index))
4344

4445
# Trigger next step
4546
self._next_called = True
46-
return await self._parent.resume_dialog(self, DialogReason.NextCalled, result)
47+
return await self._wf_parent.resume_dialog(self, DialogReason.NextCalled, result)

samples/Core-Bot/dialogs/booking_dialog.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ def __init__(self, dialog_id: str = None):
1313
self.add_dialog(ConfirmPrompt(ConfirmPrompt.__name__))
1414
self.add_dialog(DateResolverDialog(DateResolverDialog.__name__))
1515
self.add_dialog(WaterfallDialog(WaterfallDialog.__name__, [
16-
16+
self.destination_step,
17+
self.origin_step,
18+
self.travel_date_step,
19+
self.confirm_step,
20+
self.final_step
1721
]))
1822

1923
self.initial_dialog_id = WaterfallDialog.__name__

samples/Core-Bot/dialogs/main_dialog.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ def __init__(self, configuration: dict, dialog_id: str = None):
1717
self.add_dialog(TextPrompt(TextPrompt.__name__))
1818
self.add_dialog(BookingDialog())
1919
self.add_dialog(WaterfallDialog('WFDialog', [
20-
20+
self.intro_step,
21+
self.act_step,
22+
self.final_step
2123
]))
24+
25+
self.initial_dialog_id = 'WFDialog'
2226

2327
async def intro_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
2428
if (not self._configuration.get("LuisAppId", "") or not self._configuration.get("LuisAPIKey", "") or not self._configuration.get("LuisAPIHostName", "")):
2529
await step_context.context.send_activity(
2630
MessageFactory.text("NOTE: LUIS is not configured. To enable all capabilities, add 'LuisAppId', 'LuisAPIKey' and 'LuisAPIHostName' to the appsettings.json file."))
2731

28-
return await step_context.next()
32+
return await step_context.next(None)
2933
else:
3034
return await step_context.prompt(TextPrompt.__name__, PromptOptions(prompt = MessageFactory.text("What can I help you with today?")))
3135

0 co 2851 mmit comments

Comments
 (0)
0