コンテンツにスキップ

ディープリサーチ

DeepResearch は、複数回のウェブ検索を実行します。クエリを生成し、検索し、十分な情報が得られたかを評価し、クエリを洗練し、満足するまで繰り返します。その後、レポートを統合します。

Question -> Generate queries -> Search -> Sufficient?
|
No -> Refine queries -> Search -> ...
Yes -> Synthesize report
import { DeepResearch } from "@schift-io/sdk";
const research = new DeepResearch(
{
maxIterations: 5,
resultsPerSearch: 10,
queriesPerIteration: 3,
synthesisModel: "gpt-4o",
webSearch: {
provider: "tavily",
providerApiKey: "tvly-xxx",
},
},
llmFn,
);
const report = await research.run("AI agent framework trends 2026");
console.log(report.answer); // 統合されたレポート
console.log(report.sources.length); // ソースの数
console.log(report.iterations); // 使用された反復回数
console.log(report.totalQueries); // 実行された総クエリ数

llmFn パラメータは、任意のチャット完了APIを呼び出す関数です:

const llmFn = async (messages: Array<{ role: string; content: string }>) => {
const resp = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ model: "gpt-4o-mini", messages }),
});
const data = await resp.json();
return data.choices[0].message.content;
};
const agent = new Agent({
tools: [research.asTool()],
...
});

deep_research として登録されます。エージェントは、徹底的なマルチソースリサーチが必要な質問に対してこれを呼び出します。

オプションデフォルト説明
maxIterationsnumber3最大リサーチラウンド
resultsPerSearchnumber5クエリごとの結果数
queriesPerIterationnumber2ラウンドごとに生成されるクエリ
queryModelModelId | string"gpt-4o-mini"クエリ生成用モデル
synthesisModelModelId | string"gpt-4o-mini"最終レポート用モデル
webSearchWebSearchConfigウェブ検索プロバイダー設定