rchrdgwr commited on
Commit
0460aec
1 Parent(s): 8370241

hit/miss, remove conclusion

Browse files
__pycache__/utils_chain_parameters.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils_chain_parameters.cpython-311.pyc and b/__pycache__/utils_chain_parameters.cpython-311.pyc differ
 
__pycache__/utils_evaluate_objections.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils_evaluate_objections.cpython-311.pyc and b/__pycache__/utils_evaluate_objections.cpython-311.pyc differ
 
__pycache__/utils_output.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils_output.cpython-311.pyc and b/__pycache__/utils_output.cpython-311.pyc differ
 
__pycache__/utils_prompt.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils_prompt.cpython-311.pyc and b/__pycache__/utils_prompt.cpython-311.pyc differ
 
utils_chain_parameters.py CHANGED
@@ -21,9 +21,8 @@ def prepare_chain_parameters(session_state, message, history):
21
  ground_truth = session_state.questions[session_state.current_question_index - 1]["ground_truth"]
22
  for response in session_state.responses:
23
  all_questions_answers += f"Question: {response['question']}\nAnswer: {response['response']}\n\n"
24
- command = """Thank the customer, offer a comment on the answer and overall performance.
25
- Conclude the conversation with a conclusion based on all of the questions and answers.
26
- Give a polite farewell.
27
  """
28
  else:
29
  previous_question = session_state.questions[session_state.current_question_index - 1]["question"]
 
21
  ground_truth = session_state.questions[session_state.current_question_index - 1]["ground_truth"]
22
  for response in session_state.responses:
23
  all_questions_answers += f"Question: {response['question']}\nAnswer: {response['response']}\n\n"
24
+ command = """Offer a comment on their last answer. Then conclude the conversation with a polite farewell
25
+ and a suggestion for the next step.
 
26
  """
27
  else:
28
  previous_question = session_state.questions[session_state.current_question_index - 1]["question"]
utils_evaluate_objections.py CHANGED
@@ -72,6 +72,7 @@ def process_salesbud_file(file_path: str) -> List[Tuple[ObjectionInput, Objectio
72
  class ObjectionlPrompt(PydanticPrompt[ObjectionInput, ObjectionOutput]):
73
  instruction = "You are an expert technology sales rep that is tasked with judging if response satisfies potential customer's objection (user input). \
74
  Given an user input and sales rep response, output True if the response satisfies the objection by the potential customer"
 
75
  input_model = ObjectionInput
76
  output_model = ObjectionOutput
77
  examples = process_salesbud_file('salesbud_examples.csv')
@@ -94,6 +95,8 @@ class SatisfyRate(MetricWithLLM, SingleTurnMetric):
94
  prompt_response = await self.objection_prompt.generate(
95
  data=prompt_input, llm=self.llm
96
  )
 
 
97
  return int(prompt_response.satisfy)
98
 
99
  async def generate_objection_score(question_answer):
 
72
  class ObjectionlPrompt(PydanticPrompt[ObjectionInput, ObjectionOutput]):
73
  instruction = "You are an expert technology sales rep that is tasked with judging if response satisfies potential customer's objection (user input). \
74
  Given an user input and sales rep response, output True if the response satisfies the objection by the potential customer"
75
+
76
  input_model = ObjectionInput
77
  output_model = ObjectionOutput
78
  examples = process_salesbud_file('salesbud_examples.csv')
 
95
  prompt_response = await self.objection_prompt.generate(
96
  data=prompt_input, llm=self.llm
97
  )
98
+ print("prompt_response")
99
+ print(prompt_response)
100
  return int(prompt_response.satisfy)
101
 
102
  async def generate_objection_score(question_answer):
utils_output.py CHANGED
@@ -63,10 +63,17 @@ async def display_evaluation_results(cl, session_state):
63
  print("Checking evaluation and objection flags")
64
  print(session_state.do_evaluation)
65
  print(session_state.add_objections_to_analysis)
 
 
66
  if session_state.do_evaluation:
67
  evaluate_answers(session_state)
68
  elif session_state.add_objections_to_analysis:
69
  await evaluate_objections(session_state)
 
 
 
 
 
70
  await asyncio.sleep(1)
71
 
72
  output = f"**Session Summary**"
@@ -84,9 +91,10 @@ async def display_evaluation_results(cl, session_state):
84
  averages = results_df[columns_to_average].mean()
85
 
86
  await cl.Message(content="**Overall Summary (By SalesBuddy)**").send()
87
- output = f"**SalesBuddy Score (1-10):** {session_state.responses[-1]['overall_score']} \n"
88
  output = output + f"**SalesBuddy Evaluation:** {session_state.responses[-1]['overall_evaluation']} \n"
89
  output = output + f"**SalesBuddy Final Mood Score (1-10):** {session_state.responses[-1]['mood_score']} \n"
 
90
  await cl.Message(content=output).send()
91
 
92
  if session_state.do_ragas_evaluation:
@@ -98,12 +106,20 @@ async def display_evaluation_results(cl, session_state):
98
  await cl.Message(content="**Individual Question Scores**").send()
99
 
100
  for index, resp in enumerate(session_state.responses):
101
-
 
 
 
 
 
 
 
 
102
  output = f"""
103
  **Question:** {resp.get('question', 'N/A')}
104
  **Answer:** {resp.get('response', 'N/A')}
105
  **SalesBuddy Evaluation:** {resp.get('response_evaluation', 'N/A')}
106
- **Evaluation Score:** {resp.get('evaluation_score', 'N/A')}
107
  """
108
  if session_state.do_ragas_evaluation:
109
  scores = session_state.scores[index]
 
63
  print("Checking evaluation and objection flags")
64
  print(session_state.do_evaluation)
65
  print(session_state.add_objections_to_analysis)
66
+ hit_miss_ratio = "N/A"
67
+ hit_miss_score = 0
68
  if session_state.do_evaluation:
69
  evaluate_answers(session_state)
70
  elif session_state.add_objections_to_analysis:
71
  await evaluate_objections(session_state)
72
+ for resp in session_state.responses:
73
+ if resp.get('evaluation_score', 'N/A') == 1 or resp.get('evaluation_score', 'N/A') == 0:
74
+ hit_miss = resp.get('evaluation_score', 0)
75
+ hit_miss_score += hit_miss
76
+ hit_miss_ratio = (hit_miss_score / len(session_state.responses)) * 100
77
  await asyncio.sleep(1)
78
 
79
  output = f"**Session Summary**"
 
91
  averages = results_df[columns_to_average].mean()
92
 
93
  await cl.Message(content="**Overall Summary (By SalesBuddy)**").send()
94
+ output = f"**SalesBuddy Grade (1-10):** {session_state.responses[-1]['overall_score']} \n"
95
  output = output + f"**SalesBuddy Evaluation:** {session_state.responses[-1]['overall_evaluation']} \n"
96
  output = output + f"**SalesBuddy Final Mood Score (1-10):** {session_state.responses[-1]['mood_score']} \n"
97
+ output = output + f"**Hit/Miss Ratio:** {hit_miss_ratio:.1f}% \n"
98
  await cl.Message(content=output).send()
99
 
100
  if session_state.do_ragas_evaluation:
 
106
  await cl.Message(content="**Individual Question Scores**").send()
107
 
108
  for index, resp in enumerate(session_state.responses):
109
+ eval_score = resp.get('evaluation_score', 0)
110
+ print(eval_score)
111
+ print(type(eval_score))
112
+ if eval_score == 1:
113
+ eval_output = "Hit"
114
+ elif eval_score == 0:
115
+ eval_output = "Miss"
116
+ else:
117
+ eval_output = "N/A"
118
  output = f"""
119
  **Question:** {resp.get('question', 'N/A')}
120
  **Answer:** {resp.get('response', 'N/A')}
121
  **SalesBuddy Evaluation:** {resp.get('response_evaluation', 'N/A')}
122
+ **Hit/Miss:** {eval_output}
123
  """
124
  if session_state.do_ragas_evaluation:
125
  scores = session_state.scores[index]