Loading repository data…
Loading repository data…
j0sh162 / repository
A sophisticated Java-based research agent that leverages multiple search providers and AI to conduct in-depth research on topics, answer questions, and synthesize information from diverse sources.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A sophisticated Java-based research agent that leverages multiple search providers and AI to conduct in-depth research on topics, answer questions, and synthesize information from diverse sources.
The Deep Research Agent is designed to automate the process of researching topics by:
The agent can determine when research is needed, conduct targeted searches, and combine results from multiple search engines for thorough analysis.
The project follows a modular, interface-based design:
SearchProvider: Interface for different search engines
DuckDuckGoSearchProvider: Web scraping implementationGoogleSearchProvider: API-based implementationResearchAgent: Core class that orchestrates the research processSearchResult: Model class for search resultsResearchResponse: Comprehensive response with metadata<dependencies>
<!-- OpenAI API Client -->
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java-client</artifactId>
<version>0.8.1</version>
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.3</version>
</dependency>
<!-- JSON Processing -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>
</dependencies>
OpenAI API Key:
Google Custom Search:
// Initialize providers
SearchProvider duckDuckGo = new DuckDuckGoSearchProvider();
SearchProvider google = new GoogleSearchProvider(googleApiKey, searchEngineId);
// Create a research agent with multiple providers
List<SearchProvider> providers = List.of(google, duckDuckGo);
ResearchAgent agent = new ResearchAgent(openAiApiKey, providers);
// Simple research
String result = agent.research("Quantum computing applications in medicine");
System.out.println(result);
// Deep dive with multiple iterations
String deepResult = agent.deepDive("Climate change mitigation technologies", 3);
System.out.println(deepResult);
// Question answering with self-assessment
ResearchResponse response = agent.answerQuestion("What were the latest developments in quantum computing as of 2025?");
System.out.println(response);
// Use only DuckDuckGo
ResearchAgent ddgAgent = new ResearchAgent(openAiApiKey, List.of(new DuckDuckGoSearchProvider()));
// Use only Google
ResearchAgent googleAgent = new ResearchAgent(openAiApiKey, List.of(
new GoogleSearchProvider(googleApiKey, searchEngineId)
));
// Use multiple search providers with equal priority
ResearchAgent multiAgent = new ResearchAgent(openAiApiKey,
List.of(new DuckDuckGoSearchProvider(), new GoogleSearchProvider(googleApiKey, searchEngineId))
);
The agent can determine if it already has sufficient knowledge to answer a question:
ResearchResponse response = agent.answerQuestion("What is the capital of France?");
if (!response.getNeededResearch()) {
System.out.println("Answered without research: " + response.getAnswer());
} else {
System.out.println("Research was required.");
}
For comprehensive exploration of a topic with follow-up questions:
String deepResult = agent.deepDive("Renewable energy storage solutions", 3);
This will:
Implement the SearchProvider interface to add new search engines:
class BingSearchProvider implements SearchProvider {
@Override
public List<SearchResult> search(String query) {
// Implementation
}
@Override
public String getName() {
return "Bing";
}
}
Extend the project to extract full content from search results:
private String extractContentFromUrl(String url) {
try {
Document doc = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")
.get();
// Extract main content
Elements content = doc.select("article, .content, main");
if (!content.isEmpty()) {
return content.first().text();
}
return doc.body().text();
} catch (Exception e) {
return "Failed to extract content: " + e.getMessage();
}
}
This project is licensed under the MIT License - see the LICENSE file for details.