Skip to content

Commit

Permalink
return propmts_goals formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoIsALie committed Jul 24, 2023
1 parent 648a31e commit 6641df7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions state_formatters/dp_formatters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from copy import deepcopy
from typing import Dict, List, Any

from common.utils import get_entities
Expand Down Expand Up @@ -876,3 +877,13 @@ def hypotheses_list_last_uttr(dialog: Dict) -> List[Dict]:
hypots = [h["text"] for h in hypotheses]
last_human_utterances = [dialog["human_utterances"][-1]["text"] for _ in hypotheses]
return [{"sentences": hypots, "last_human_utterances": last_human_utterances}]


def prompts_goals_collector_formatter(dialog: Dict) -> List[Dict]:
prompts_goals = {}
if len(dialog["human_utterances"]) > 1:
hypotheses = dialog["human_utterances"][-2].get("hypotheses", [])
for prompts_goals_dict in [hyp.get("prompts_goals", None) for hyp in hypotheses]:
if prompts_goals_dict:
prompts_goals.update(deepcopy(prompts_goals_dict))
return [{"prompts_goals": [prompts_goals], "human_attributes": [dialog["human"]["attributes"]]}]

0 comments on commit 6641df7

Please sign in to comment.