cryogenic22 commited on
Commit
6a13f3d
·
verified ·
1 Parent(s): 131cc45

Update graph_builder.py

Browse files
Files changed (1) hide show
  1. 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
- # Try to find synopsis or summary section first
75
- for section_name in ["synopsis", "summary", "overview"]:
76
- if section_name.lower() in [s.lower() for s in sections.keys()]:
77
- section_key = next(k for k in sections.keys() if k.lower() == section_name.lower())
78
- text_for_extraction = sections[section_key]
79
- break
80
-
81
- # If no synopsis found, use the beginning of the document
82
- if not text_for_extraction and "document_text" in state:
83
- text_for_extraction = state["document_text"][:20000] # Use first 20k chars
 
 
 
 
 
 
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 {