Spaces:
Build error
Build error
fix: catch errors with themes chain
Browse files
planning_ai/nodes/map_node.py
CHANGED
@@ -13,15 +13,18 @@ anonymizer = AnonymizerEngine()
|
|
13 |
|
14 |
nlp = spacy.load("en_core_web_lg")
|
15 |
|
16 |
-
CUTOFF = 10_000
|
17 |
|
18 |
|
19 |
def retrieve_themes(state: DocumentState) -> DocumentState:
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
state["themes"] = set(themes)
|
27 |
return state
|
|
|
13 |
|
14 |
nlp = spacy.load("en_core_web_lg")
|
15 |
|
|
|
16 |
|
17 |
|
18 |
def retrieve_themes(state: DocumentState) -> DocumentState:
|
19 |
+
try:
|
20 |
+
result = themes_chain.invoke({"document": state["document"].page_content})
|
21 |
+
if not result.themes:
|
22 |
+
state["themes"] = set()
|
23 |
+
return state
|
24 |
+
themes = [theme.value for theme in result.themes]
|
25 |
+
except Exception as e:
|
26 |
+
logger.error(f"Theme selection error: {e}")
|
27 |
+
themes = []
|
28 |
|
29 |
state["themes"] = set(themes)
|
30 |
return state
|