└── main.py /main.py: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | import java.nio.file.*; 3 | import java.util.*; 4 | 5 | public class ResearchAgent { 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | 9 | System.out.print("What would you like to research? "); 10 | String initialQuery = scanner.nextLine(); 11 | 12 | System.out.print("Enter research breadth (2-10, default 4): "); 13 | int breadth = scanner.hasNextInt() ? scanner.nextInt() : 4; 14 | scanner.nextLine(); 15 | 16 | System.out.print("Enter research depth (1-5, default 2): "); 17 | int depth = scanner.hasNextInt() ? scanner.nextInt() : 2; 18 | scanner.nextLine(); 19 | 20 | List followUpQuestions = FeedbackGenerator.generateFeedback(initialQuery); 21 | List answers = new ArrayList<>(); 22 | 23 | for (String question : followUpQuestions) { 24 | System.out.println("\n" + question); 25 | answers.add(scanner.nextLine()); 26 | } 27 | 28 | String combinedQuery = "Initial Query: " + initialQuery + "\n"; 29 | for (int i = 0; i < followUpQuestions.size(); i++) { 30 | combinedQuery += "Q: " + followUpQuestions.get(i) + "\nA: " + answers.get(i) + "\n"; 31 | } 32 | 33 | ResearchResult result = Researcher.deepResearch(combinedQuery, breadth, depth); 34 | 35 | System.out.println("\nLearnings:"); 36 | result.learnings.forEach(System.out::println); 37 | 38 | System.out.println("\nVisited URLs:"); 39 | result.visitedUrls.forEach(System.out::println); 40 | 41 | String report = ReportWriter.writeReport(combinedQuery, result); 42 | 43 | try { 44 | Files.write(Paths.get("output.md"), report.getBytes()); 45 | System.out.println("\nReport has been saved to output.md"); 46 | } catch (IOException e) { 47 | e.printStackTrace(); 48 | } 49 | 50 | scanner.close(); 51 | } 52 | } 53 | --------------------------------------------------------------------------------