-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion.py
39 lines (36 loc) · 1.26 KB
/
question.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import random
import json
class Question:
def __init__(self, x = None, y = None, prefix = "") -> None:
self.x = x or random.randrange(10)
self.y = y or random.randrange(10)
self.prefix = prefix
def get_json(self) -> object:
text = f'What is {self.x} + {self.y}?'
if self.prefix != "":
text = self.prefix + " " + text
return {
"expectUserResponse": True,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": text,
"displayText": text,
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
]
}
],
"conversationToken": json.dumps({"x": self.x, "y": self.y, "ans": self.x+self.y})
}