in src/dfcx_scrapi/core/intents.py [0:0]
def bulk_intent_to_df(
self,
agent_id: str = None,
mode: str = "basic",
intent_subset: List[str] = None,
transpose: bool = False,
language_code: str = None) -> pd.DataFrame:
"""Extracts all Intents and Training Phrases into a Pandas DataFrame.
Args:
agent_id (str):
agent to pull list of intents
mode (str):
"basic" returns display name and training phrase as plain text.
"advanced" returns training phrases broken out by parts
with their parameters included.
intent_subset (List[str]):
A subset of intents to extract the intents from.
transpose (bool):
Return the transposed DataFrame. If this flag passed as True,
mode won't affect the result and the result would be like basic.
language_code (str):
Language code of the intents being uploaded. Ref:
https://cloud.google.com/dialogflow/cx/docs/reference/language
Returns:
In basic mode, a Pandas DataFrame with columns:
display_name, training phrase
In advanced mode, a Pandas DataFrame with columns:
name, display_name, description, priority,
is_fallback, labels, id, repeat_count,
training_phrase_idx, text, text_idx,
parameter_id, entity_type, is_list, redact
"""
if not agent_id:
agent_id = self.agent_id
if transpose:
_, intents_dict = self.intents_to_df_cosine_prep(agent_id)
transposed_df = pd.DataFrame.from_dict(
intents_dict, "index"
).transpose()
if intent_subset:
transposed_df = transposed_df[intent_subset]
return transposed_df
if mode not in ["basic", "advanced"]:
raise ValueError("Mode types: [basic, advanced]")
main_df = pd.DataFrame()
intents = self.list_intents(agent_id, language_code=language_code)
for obj in intents:
if (intent_subset) and (obj.display_name not in intent_subset):
continue
intent_df = self.intent_proto_to_dataframe(obj, mode=mode)
main_df = pd.concat([main_df, intent_df], ignore_index=True)
return main_df