|
1 | 1 | """Node definitions for Online Research Agent.""" |
| 2 | + |
2 | 3 | from framework.graph import NodeSpec |
3 | 4 |
|
4 | 5 | # Node 1: Parse Query |
|
10 | 11 | input_keys=["topic"], |
11 | 12 | output_keys=["search_queries", "research_focus", "key_aspects"], |
12 | 13 | output_schema={ |
13 | | - "research_focus": {"type": "string", "required": True, "description": "Brief statement of what we're researching"}, |
14 | | - "key_aspects": {"type": "array", "required": True, "description": "List of 3-5 key aspects to investigate"}, |
15 | | - "search_queries": {"type": "array", "required": True, "description": "List of 3-5 search queries"}, |
| 14 | + "research_focus": { |
| 15 | + "type": "string", |
| 16 | + "required": True, |
| 17 | + "description": "Brief statement of what we're researching", |
| 18 | + }, |
| 19 | + "key_aspects": { |
| 20 | + "type": "array", |
| 21 | + "required": True, |
| 22 | + "description": "List of 3-5 key aspects to investigate", |
| 23 | + }, |
| 24 | + "search_queries": { |
| 25 | + "type": "array", |
| 26 | + "required": True, |
| 27 | + "description": "List of 3-5 search queries", |
| 28 | + }, |
16 | 29 | }, |
17 | 30 | system_prompt="""\ |
18 | 31 | You are a research query strategist. Given a research topic, analyze it and generate search queries. |
|
50 | 63 | input_keys=["search_queries", "research_focus"], |
51 | 64 | output_keys=["source_urls", "search_results_summary"], |
52 | 65 | output_schema={ |
53 | | - "source_urls": {"type": "array", "required": True, "description": "List of source URLs found"}, |
54 | | - "search_results_summary": {"type": "string", "required": True, "description": "Brief summary of what was found"}, |
| 66 | + "source_urls": { |
| 67 | + "type": "array", |
| 68 | + "required": True, |
| 69 | + "description": "List of source URLs found", |
| 70 | + }, |
| 71 | + "search_results_summary": { |
| 72 | + "type": "string", |
| 73 | + "required": True, |
| 74 | + "description": "Brief summary of what was found", |
| 75 | + }, |
55 | 76 | }, |
56 | 77 | system_prompt="""\ |
57 | 78 | You are a research assistant executing web searches. Use the web_search tool to find sources. |
|
80 | 101 | input_keys=["source_urls", "research_focus"], |
81 | 102 | output_keys=["fetched_sources", "fetch_errors"], |
82 | 103 | output_schema={ |
83 | | - "fetched_sources": {"type": "array", "required": True, "description": "List of fetched source objects with url, title, content"}, |
84 | | - "fetch_errors": {"type": "array", "required": True, "description": "List of URLs that failed to fetch"}, |
| 104 | + "fetched_sources": { |
| 105 | + "type": "array", |
| 106 | + "required": True, |
| 107 | + "description": "List of fetched source objects with url, title, content", |
| 108 | + }, |
| 109 | + "fetch_errors": { |
| 110 | + "type": "array", |
| 111 | + "required": True, |
| 112 | + "description": "List of URLs that failed to fetch", |
| 113 | + }, |
85 | 114 | }, |
86 | 115 | system_prompt="""\ |
87 | 116 | You are a content fetcher. Use web_scrape tool to retrieve content from URLs. |
|
113 | 142 | input_keys=["fetched_sources", "research_focus", "key_aspects"], |
114 | 143 | output_keys=["ranked_sources", "source_analysis"], |
115 | 144 | output_schema={ |
116 | | - "ranked_sources": {"type": "array", "required": True, "description": "List of ranked sources with scores"}, |
117 | | - "source_analysis": {"type": "string", "required": True, "description": "Overview of source quality and coverage"}, |
| 145 | + "ranked_sources": { |
| 146 | + "type": "array", |
| 147 | + "required": True, |
| 148 | + "description": "List of ranked sources with scores", |
| 149 | + }, |
| 150 | + "source_analysis": { |
| 151 | + "type": "string", |
| 152 | + "required": True, |
| 153 | + "description": "Overview of source quality and coverage", |
| 154 | + }, |
118 | 155 | }, |
119 | 156 | system_prompt="""\ |
120 | 157 | You are a source evaluator. Assess each source for quality and relevance. |
|
153 | 190 | input_keys=["ranked_sources", "research_focus", "key_aspects"], |
154 | 191 | output_keys=["key_findings", "themes", "source_citations"], |
155 | 192 | output_schema={ |
156 | | - "key_findings": {"type": "array", "required": True, "description": "List of key findings with sources and confidence"}, |
157 | | - "themes": {"type": "array", "required": True, "description": "List of themes with descriptions and supporting sources"}, |
158 | | - "source_citations": {"type": "object", "required": True, "description": "Map of facts to supporting URLs"}, |
| 193 | + "key_findings": { |
| 194 | + "type": "array", |
| 195 | + "required": True, |
| 196 | + "description": "List of key findings with sources and confidence", |
| 197 | + }, |
| 198 | + "themes": { |
| 199 | + "type": "array", |
| 200 | + "required": True, |
| 201 | + "description": "List of themes with descriptions and supporting sources", |
| 202 | + }, |
| 203 | + "source_citations": { |
| 204 | + "type": "object", |
| 205 | + "required": True, |
| 206 | + "description": "Map of facts to supporting URLs", |
| 207 | + }, |
159 | 208 | }, |
160 | 209 | system_prompt="""\ |
161 | 210 | You are a research synthesizer. Analyze multiple sources to extract insights. |
|
192 | 241 | name="Write Report", |
193 | 242 | description="Generate a narrative report with proper citations", |
194 | 243 | node_type="llm_generate", |
195 | | - input_keys=["key_findings", "themes", "source_citations", "research_focus", "ranked_sources"], |
| 244 | + input_keys=[ |
| 245 | + "key_findings", |
| 246 | + "themes", |
| 247 | + "source_citations", |
| 248 | + "research_focus", |
| 249 | + "ranked_sources", |
| 250 | + ], |
196 | 251 | output_keys=["report_content", "references"], |
197 | 252 | output_schema={ |
198 | | - "report_content": {"type": "string", "required": True, "description": "Full markdown report text with citations"}, |
199 | | - "references": {"type": "array", "required": True, "description": "List of reference objects with number, url, title"}, |
| 253 | + "report_content": { |
| 254 | + "type": "string", |
| 255 | + "required": True, |
| 256 | + "description": "Full markdown report text with citations", |
| 257 | + }, |
| 258 | + "references": { |
| 259 | + "type": "array", |
| 260 | + "required": True, |
| 261 | + "description": "List of reference objects with number, url, title", |
| 262 | + }, |
200 | 263 | }, |
201 | 264 | system_prompt="""\ |
202 | 265 | You are a research report writer. Create a well-structured narrative report. |
|
239 | 302 | input_keys=["report_content", "references", "source_citations"], |
240 | 303 | output_keys=["quality_score", "issues", "final_report"], |
241 | 304 | output_schema={ |
242 | | - "quality_score": {"type": "number", "required": True, "description": "Quality score 0-1"}, |
243 | | - "issues": {"type": "array", "required": True, "description": "List of issues found and fixed"}, |
244 | | - "final_report": {"type": "string", "required": True, "description": "Corrected full report"}, |
| 305 | + "quality_score": { |
| 306 | + "type": "number", |
| 307 | + "required": True, |
| 308 | + "description": "Quality score 0-1", |
| 309 | + }, |
| 310 | + "issues": { |
| 311 | + "type": "array", |
| 312 | + "required": True, |
| 313 | + "description": "List of issues found and fixed", |
| 314 | + }, |
| 315 | + "final_report": { |
| 316 | + "type": "string", |
| 317 | + "required": True, |
| 318 | + "description": "Corrected full report", |
| 319 | + }, |
245 | 320 | }, |
246 | 321 | system_prompt="""\ |
247 | 322 | You are a quality assurance reviewer. Check the research report for issues. |
|
278 | 353 | input_keys=["final_report", "references", "research_focus"], |
279 | 354 | output_keys=["file_path", "save_status"], |
280 | 355 | output_schema={ |
281 | | - "file_path": {"type": "string", "required": True, "description": "Path where report was saved"}, |
282 | | - "save_status": {"type": "string", "required": True, "description": "Status of save operation"}, |
| 356 | + "file_path": { |
| 357 | + "type": "string", |
| 358 | + "required": True, |
| 359 | + "description": "Path where report was saved", |
| 360 | + }, |
| 361 | + "save_status": { |
| 362 | + "type": "string", |
| 363 | + "required": True, |
| 364 | + "description": "Status of save operation", |
| 365 | + }, |
283 | 366 | }, |
284 | 367 | system_prompt="""\ |
285 | 368 | You are a file manager. Save the research report to disk. |
|
0 commit comments