Skip to content

Commit

Permalink
fix: add lang_code support for DataLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaphoenix committed Nov 26, 2024
1 parent 100fb39 commit 3f3aa86
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dfcx_scrapi/tools/evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def run_detect_intent_queries(self, df: pd.DataFrame) -> pd.DataFrame:
if "session_parameters" in row:
session_parameters = self.str_to_dict(row["session_parameters"])

res = self.s.detect_intent(
res = self.sessions_client.detect_intent(
agent_id=self.agent_id,
session_id=self.session_id,
text=row["action_input"],
Expand Down Expand Up @@ -498,6 +498,7 @@ def __init__(
creds: service_account.Credentials = None,
agent_id: str = None,
sheet_name: str = None,
language_code: str = "en"
):

self.agent_id = agent_id
Expand All @@ -511,6 +512,7 @@ def __init__(
"action_type",
"action_input",
]
self.language_code = language_code

@staticmethod
def get_matching_list_idx(a, b):
Expand Down Expand Up @@ -728,9 +730,10 @@ def build_report_summary(self, df: pd.DataFrame) -> pd.DataFrame:
self.agent_id = self.get_agent_id_from_results(df)

# Get Generative Settings for report data
a = Agents()
a = Agents(language_code=self.language_code)
agent = a.get_agent(self.agent_id)
gen_settings = a.get_generative_settings(self.agent_id)
gen_settings = a.get_generative_settings(
self.agent_id, language_code=self.language_code)
model_name = self.get_model_name(gen_settings)

current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
Expand All @@ -753,6 +756,8 @@ def build_report_summary(self, df: pd.DataFrame) -> pd.DataFrame:
insert_index = eval_results_summary.columns.get_loc(
"total_conversations") + 1
for metric, value in metrics_info.items():
if (isinstance(value, float) and np.isnan(value)):
value = "-"
eval_results_summary.insert(insert_index, metric, [value])
insert_index += 1

Expand Down

0 comments on commit 3f3aa86

Please sign in to comment.