Installation
Copy
npm install praisonai
Basic Usage
Copy
import { DeepResearchAgent } from 'praisonai';
const agent = new DeepResearchAgent();
const result = await agent.research('What are the latest advances in AI?');
console.log('Answer:', result.answer);
console.log('Citations:', result.citations.length);
console.log('Confidence:', result.confidence);
With Configuration
Copy
import { DeepResearchAgent } from 'praisonai';
const agent = new DeepResearchAgent({
name: 'Researcher',
llm: 'openai/gpt-4o',
maxIterations: 10,
verbose: true
});
With Search Tool
Copy
import { DeepResearchAgent } from 'praisonai';
const searchTool = async (query: string) => {
// Your search implementation
return [
{ title: 'Result 1', url: 'https://example.com/1', snippet: 'Content...' },
{ title: 'Result 2', url: 'https://example.com/2', snippet: 'More content...' }
];
};
const agent = new DeepResearchAgent({
searchTool
});
const result = await agent.research('Latest AI research');
console.log('Citations found:', result.citations.length);
Research Response
Copy
interface ResearchResponse {
answer: string; // Synthesized answer
citations: Citation[]; // Sources used
reasoning: ReasoningStep[]; // Research process
confidence: number; // 0-1 confidence score
}
interface Citation {
title: string;
url: string;
snippet?: string;
}
interface ReasoningStep {
step: number;
thought: string;
action?: string;
result?: string;
}
View Reasoning Steps
Copy
import { DeepResearchAgent } from 'praisonai';
const agent = new DeepResearchAgent({ verbose: true });
const result = await agent.research('Explain quantum computing');
result.reasoning.forEach(step => {
console.log(`Step ${step.step}: ${step.thought}`);
if (step.action) console.log(` Action: ${step.action}`);
if (step.result) console.log(` Result: ${step.result}`);
});
Set Search Tool Dynamically
Copy
import { DeepResearchAgent } from 'praisonai';
const agent = new DeepResearchAgent();
agent.setSearchTool(async (query) => {
// Custom search logic
return [];
});
Factory Function
Copy
import { createDeepResearchAgent } from 'praisonai';
const agent = createDeepResearchAgent({
name: 'MyResearcher',
maxIterations: 5
});

