cjber commited on
Commit
d09089c
·
1 Parent(s): 7e9928e

remove low rated or neutral responses

Browse files
Files changed (1) hide show
  1. planning_ai/nodes/reduce_node.py +15 -1
planning_ai/nodes/reduce_node.py CHANGED
@@ -4,7 +4,12 @@ from planning_ai.states import OverallState
4
 
5
  def generate_final_summary(state: OverallState):
6
  if len(state["documents"]) == len(state["summaries_fixed"]):
7
- response = reduce_chain.invoke({"context": state["summaries_fixed"]})
 
 
 
 
 
8
  return {
9
  "final_summary": response,
10
  "summaries_fixed": state["summaries_fixed"],
@@ -12,3 +17,12 @@ def generate_final_summary(state: OverallState):
12
  "hallucinations": state["hallucinations"],
13
  "documents": state["documents"],
14
  }
 
 
 
 
 
 
 
 
 
 
4
 
5
  def generate_final_summary(state: OverallState):
6
  if len(state["documents"]) == len(state["summaries_fixed"]):
7
+ summaries = [
8
+ summary["summary"].summary
9
+ for summary in state["summaries_fixed"]
10
+ if summary["summary"].stance != "NEUTRAL" and summary["summary"].rating >= 5
11
+ ]
12
+ response = reduce_chain.invoke({"context": summaries})
13
  return {
14
  "final_summary": response,
15
  "summaries_fixed": state["summaries_fixed"],
 
17
  "hallucinations": state["hallucinations"],
18
  "documents": state["documents"],
19
  }
20
+
21
+
22
+ def add_snippets(state: OverallState):
23
+ final_summary = state["final_summary"]
24
+ summaries = state["summaries_fixed"]
25
+
26
+ response = snippet_chain.invoke(
27
+ {"final_summary": final_summary, "summaries": summaries}
28
+ )