Files
Emil e196593c84
CI / Lint & Type Check (push) Canceled after 0s
CI / Test (push) Canceled after 0s
Add Pi Research Agent package
Autonomous research agent with web search, source analysis, and report synthesis.
Built on Pi agent core. Available as CLI, programmatic API, and MCP server.

Features:
- 4 built-in tools: web_search, read_url, save_note, synthesize_report
- CLI with TUI and print modes
- Programmatic API via ResearchAgent class
- MCP server with 3 tools: research, quick_search, read_url
- Skills system for custom research behavior
- Automatic .env file loading for API keys
- Configurable max turns, output formats (markdown/JSON/bullet)
- Automatic report saving to research-output/
2026-06-04 18:12:11 +03:00

41 lines
962 B
TypeScript

/**
* Custom Model Example
*
* Demonstrates how to use a custom model with the ResearchAgent.
*
* Run with:
* TAVILY_API_KEY=*** \
* OPENROUTER_API_KEY=*** \
* npx tsx examples/custom-model.ts
*/
import { getModels } from "@earendil-works/pi-ai";
import { ResearchAgent } from "../src/index.ts";
const models = getModels("openrouter");
const gpt4o = models.find((m) => m.id === "openai/gpt-4o");
if (!gpt4o) {
console.error("GPT-4o model not found");
process.exit(1);
}
const agent = new ResearchAgent({
model: gpt4o,
thinkingLevel: "high",
maxTurns: 15,
});
agent.subscribe((event) => {
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
process.stdout.write(event.assistantMessageEvent.delta);
}
});
const topic = "Comparison of renewable energy storage solutions";
console.log(`Researching: ${topic}\n`);
const result = await agent.research(topic);
console.log("\n\n" + result.report);