Spaces:
Runtime error
Runtime error
Update graph_builder.py
Browse files- graph_builder.py +16 -10
graph_builder.py
CHANGED
|
@@ -71,16 +71,22 @@ def extract_study_info(state: DocumentExtractionState) -> DocumentExtractionStat
|
|
| 71 |
text_for_extraction = ""
|
| 72 |
sections = state.get("sections", {})
|
| 73 |
|
| 74 |
-
#
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
text_for_extraction =
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
if not text_for_extraction:
|
| 86 |
return {
|
|
|
|
| 71 |
text_for_extraction = ""
|
| 72 |
sections = state.get("sections", {})
|
| 73 |
|
| 74 |
+
# Check if sections is a list (section names only) or a dict (section name -> content)
|
| 75 |
+
if isinstance(sections, list):
|
| 76 |
+
# Just use the document text since we don't have section content
|
| 77 |
+
if "document_text" in state:
|
| 78 |
+
text_for_extraction = state["document_text"][:20000] # Use first 20k chars
|
| 79 |
+
else:
|
| 80 |
+
# Try to find synopsis or summary section first
|
| 81 |
+
for section_name in ["synopsis", "summary", "overview"]:
|
| 82 |
+
if section_name.lower() in [s.lower() for s in sections.keys()]:
|
| 83 |
+
section_key = next(k for k in sections.keys() if k.lower() == section_name.lower())
|
| 84 |
+
text_for_extraction = sections[section_key]
|
| 85 |
+
break
|
| 86 |
+
|
| 87 |
+
# If no synopsis found, use the beginning of the document
|
| 88 |
+
if not text_for_extraction and "document_text" in state:
|
| 89 |
+
text_for_extraction = state["document_text"][:20000] # Use first 20k chars
|
| 90 |
|
| 91 |
if not text_for_extraction:
|
| 92 |
return {
|