Skip to content

Commit

Permalink
Made review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshsattala committed Oct 4, 2023
1 parent 84de1b4 commit f99c3da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
18 changes: 6 additions & 12 deletions kairon/api/app/routers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ async def visitor_hit_fallback(
Fetches the number of times the agent hit a fallback (ie. not able to answer) to user queries
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/metrics/fallback?from_date={from_date}'
f'&to_date={to_date}&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&to_date={to_date}&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down Expand Up @@ -164,11 +163,10 @@ async def complete_conversations(
Fetches the number of successful conversations of the bot, which had no fallback
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/metrics/conversation/success?from_date={from_date}'
f'&to_date={to_date}&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&to_date={to_date}&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down Expand Up @@ -233,11 +231,10 @@ async def complete_conversation_trend(
Fetches the counts of successful conversations of the bot for previous months
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/trends/conversations/success?from_date={from_date}&to_date={to_date}'
f'&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down Expand Up @@ -267,11 +264,10 @@ async def fallback_trend(
Fetches the fallback count of the bot for previous months
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/trends/fallback?from_date={from_date}'
f'&to_date={to_date}&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&to_date={to_date}&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down Expand Up @@ -437,11 +433,10 @@ async def fallback_dropoff(
Fetches the list of users that dropped off after encountering fallback
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/metrics/fallback/dropoff?from_date={from_date}&to_date={to_date}'
f'&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down Expand Up @@ -469,11 +464,10 @@ async def unsuccessful_session_count(
Fetches the count of sessions that encountered a fallback for a particular user.
"""
Utility.validate_from_date_and_to_date(from_date, to_date)
fallback_action = DataUtility.load_fallback_actions(current_user.get_bot())
return Utility.trigger_history_server_request(
current_user.get_bot(),
f'/api/history/{current_user.get_bot()}/metrics/sessions/unsuccessful?from_date={from_date}&to_date={to_date}'
f'&action_fallback={fallback_action}&nlu_fallback=utter_please_rephrase'
f'&action_fallback=action_default_fallback&nlu_fallback=utter_please_rephrase'
)


Expand Down
9 changes: 0 additions & 9 deletions kairon/shared/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,6 @@ def validate_flow_events(events, event_type, name):
raise ValidationError(
f"""Found rules '{name}' that contain more than user event.\nPlease use stories for this case""")

@staticmethod
def load_fallback_actions(bot: Text):
from .processor import MongoProcessor

mongo_processor = MongoProcessor()
config = mongo_processor.load_config(bot)
fallback_action = DataUtility.parse_fallback_action(config)
return fallback_action

@staticmethod
def parse_fallback_action(config: Dict):
fallback_action = "action_default_fallback"
Expand Down

0 comments on commit f99c3da

Please sign in to comment.