cjber commited on
Commit
ea59777
·
1 Parent(s): 3a57990

fix: remove score from state

Browse files
planning_ai/nodes/map_node.py CHANGED
@@ -25,10 +25,9 @@ def retrieve_themes(state: DocumentState) -> DocumentState:
25
  except Exception as e:
26
  logger.error(f"Theme selection error: {e}")
27
  themes = []
28
- state["themes"] = themes
29
- state["themes"] = [d for d in state["themes"] if d["score"] > 2]
30
- state["score"] = np.mean([theme["score"] for theme in state["themes"]])
31
- if state["score"] < 3:
32
  state["processed"] = True
33
  state["failed"] = True
34
 
 
25
  except Exception as e:
26
  logger.error(f"Theme selection error: {e}")
27
  themes = []
28
+ state["themes"] = [d for d in themes if d["score"] > 2]
29
+ score = np.mean([theme["score"] for theme in state["themes"]])
30
+ if score < 3:
 
31
  state["processed"] = True
32
  state["failed"] = True
33
 
planning_ai/states.py CHANGED
@@ -6,6 +6,7 @@ from langchain_core.documents import Document
6
  from pydantic import BaseModel
7
 
8
  from planning_ai.chains.hallucination_chain import HallucinationChecker
 
9
  from planning_ai.common.utils import filename_reducer
10
 
11
 
@@ -14,7 +15,7 @@ class DocumentState(TypedDict):
14
  filename: int
15
 
16
  entities: list[dict]
17
- themes: set[str]
18
 
19
  summary: BaseModel
20
  hallucination: HallucinationChecker
 
6
  from pydantic import BaseModel
7
 
8
  from planning_ai.chains.hallucination_chain import HallucinationChecker
9
+ from planning_ai.chains.themes_chain import ThemeScore
10
  from planning_ai.common.utils import filename_reducer
11
 
12
 
 
15
  filename: int
16
 
17
  entities: list[dict]
18
+ themes: set[ThemeScore]
19
 
20
  summary: BaseModel
21
  hallucination: HallucinationChecker