in src/dfcx_scrapi/core/conversation.py [0:0]
def _get_intent_detection(self, test_set: pd.DataFrame):
"""Gets the results of a subset of Intent Detection tests.
NOTE - This is an internal method used by run_intent_detection to
manage parallel intent detection requests and should not be used as a
standalone function.
"""
self._page_id_mapper()
test_set_mapped = pd.merge(
test_set,
self.agent_pages_map,
on=["flow_display_name", "page_display_name"],
how="left",
)
utterances = list(test_set_mapped["utterance"])
page_ids = list(test_set_mapped["page_id"])
self._validate_test_set_input(test_set_mapped)
threads = [None] * len(test_set_mapped)
results = {
"target_page": [None] * len(test_set_mapped),
"match":[None] * len(test_set_mapped),
}
for i, (utterance, page_id) in enumerate(zip(utterances, page_ids)):
threads[i] = Thread(
target=self._get_reply_results,
args=(utterance, page_id, results, i),
)
threads[i].start()
for _, thread in enumerate(threads):
thread.join()
test_set_mapped["target_page"] = results["target_page"]
test_set_mapped["match"] = results["match"]
test_set_mapped = test_set_mapped.drop(columns=["page_id"])
intent_detection = test_set_mapped.copy()
return intent_detection