Skip to content

Commit 7be11e5

Browse files
haodeqinavneetrao
authored andcommitted
refactor(highlighting): Fix inferencer import issue (#5)
1 parent dca9514 commit 7be11e5

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Semantic versioning
22
# MAJOR.MINOR.PATCH
33

4-
__version__ = '0.6.3'
4+
__version__ = '0.6.4'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.6.3'
1+
__version__ = '0.6.4'

assistant_dialog_skill_analysis/inferencing/inferencer.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def inference(conversation, workspace_id, test_data, max_retries=10, max_thread=
2424
attempt = 1
2525
while attempt <= max_retries:
2626
try:
27-
prediction_json = retrieve_classifier_response(
27+
prediction_json = skills_util.retrieve_classifier_response(
2828
conversation, workspace_id, test_example, True)
2929
time.sleep(.3)
3030

@@ -118,25 +118,6 @@ def thread_inference(conversation, workspace_id, test_data,
118118
result_df = pd.DataFrame(data=result)
119119
return result_df
120120

121-
def retrieve_classifier_response(conversation, workspace_id, text_input, alternate_intents=False):
122-
"""
123-
retrieve classifier response
124-
:param conversation: instance
125-
:param workspace_id: workspace or skill id
126-
:param text_input: the input utterance
127-
:param alternate_intents:
128-
:return response:
129-
"""
130-
response = conversation.message(
131-
input={
132-
'message_type': 'text',
133-
'text': text_input
134-
},
135-
workspace_id=workspace_id,
136-
alternate_intents=alternate_intents,
137-
).get_result()
138-
return response
139-
140121
def get_intents_confidences(conversation, workspace_id, text_input):
141122
"""
142123
Retrieve a list of confidence for analysis purpose
@@ -145,7 +126,7 @@ def get_intents_confidences(conversation, workspace_id, text_input):
145126
:param text_input: input utterance
146127
:return intent_conf: intent confidences
147128
"""
148-
response_info = retrieve_classifier_response(
129+
response_info = skills_util.retrieve_classifier_response(
149130
conversation, workspace_id, text_input, True)['intents']
150131
intent_conf = [(r['intent'], r['confidence']) for r in response_info]
151132
return intent_conf

assistant_dialog_skill_analysis/inferencing/multi_thread_inference.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import _thread
44

55
from ..utils import skills_util
6-
from ..inferencing import inferencer
76

87
class InferenceThread(threading.Thread):
98
"""
109
InferenceThread class is used for multi-thread inferencing for faster inference speed
1110
"""
1211
def __init__(self, thread_id, name, que, conversation,
1312
workspace_id, result, max_retries=10, verbose=False):
14-
'''
13+
"""
1514
Initialize inferencer
1615
:param thread_id:
1716
:param name:
@@ -21,7 +20,7 @@ def __init__(self, thread_id, name, que, conversation,
2120
:param result:
2221
:param max_retries:
2322
:param verbose:
24-
'''
23+
"""
2524
threading.Thread.__init__(self)
2625
self.thread_id = thread_id
2726
self.name = name
@@ -34,17 +33,17 @@ def __init__(self, thread_id, name, que, conversation,
3433
self.exitflag = 0
3534

3635
def run(self):
37-
'''
36+
"""
3837
Start thread
39-
'''
38+
"""
4039
print("Starting " + self.name)
4140
self.thread_inference()
4241
print("Exiting " + self.name)
4342

4443
def thread_inference(self):
45-
'''
44+
"""
4645
Define thread run logic
47-
'''
46+
"""
4847
while not self.exitflag:
4948
if not self.que.empty():
5049
attempt = 1
@@ -58,7 +57,7 @@ def thread_inference(self):
5857
break
5958
attempt += 1
6059
try:
61-
response = inferencer.retrieve_classifier_response(
60+
response = skills_util.retrieve_classifier_response(
6261
self.conversation,
6362
self.workspace_id,
6463
query_question,
@@ -100,7 +99,7 @@ def thread_inference(self):
10099
self.exit()
101100

102101
def exit(self):
103-
'''
102+
"""
104103
Exit thread
105-
'''
104+
"""
106105
self.exitflag = 1

assistant_dialog_skill_analysis/utils/skills_util.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,23 @@ def _remove_experimentation(nb):
289289
new_nb_cells.append(cell)
290290
nb.cells = new_nb_cells
291291
return nb
292+
293+
294+
def retrieve_classifier_response(conversation, workspace_id, text_input, alternate_intents=False):
295+
"""
296+
retrieve classifier response
297+
:param conversation: instance
298+
:param workspace_id: workspace or skill id
299+
:param text_input: the input utterance
300+
:param alternate_intents:
301+
:return response:
302+
"""
303+
response = conversation.message(
304+
input={
305+
'message_type': 'text',
306+
'text': text_input
307+
},
308+
workspace_id=workspace_id,
309+
alternate_intents=alternate_intents,
310+
).get_result()
311+
return response

0 commit comments

Comments
 (0)