UNPKG

@plust/datasleuth

Version:

Build LLM-powered research pipelines and output structured data.

61 lines (60 loc) 2.43 kB
import { ResearchInput, ResearchResult } from '../types/pipeline.js'; /** * Main research function - the primary API for the @plust/datasleuth package * * This function orchestrates the entire research process from query to results. * It takes a research query, an output schema for validation, and optional * configuration parameters to customize the research process. * * @param input The research configuration object * @param input.query The research query string (e.g., "Latest advancements in quantum computing") * @param input.outputSchema A Zod schema defining the structure of the expected output * @param input.steps Optional array of research steps to use (defaults to standard pipeline if not provided) * @param input.config Optional configuration for the research pipeline (error handling, timeout, etc.) * @param input.defaultLLM Optional default language model to use for AI-dependent steps (required if using default steps) * @param input.defaultSearchProvider Optional default search provider to use for search-dependent steps (required if using default steps) * * @returns The research results matching the structure defined by outputSchema * * @throws {ConfigurationError} When configuration is invalid (missing required parameters, etc.) * @throws {ValidationError} When output doesn't match the provided schema * @throws {BaseResearchError} For other research-related errors * * @example * ```typescript * import { research } from '@plust/datasleuth'; * import { z } from 'zod'; * import { openai } from '@ai-sdk/openai'; * import { google } from '@plust/search-sdk'; * * // Define your output schema * const outputSchema = z.object({ * summary: z.string(), * keyFindings: z.array(z.string()), * sources: z.array(z.string().url()) * }); * * // Configure your search provider * const searchProvider = google.configure({ * apiKey: process.env.GOOGLE_API_KEY, * cx: process.env.GOOGLE_CX * }); * * // Execute research * const results = await research({ * query: "Latest advancements in quantum computing", * outputSchema, * defaultLLM: openai('gpt-4o'), * defaultSearchProvider: searchProvider * }); * ``` */ export declare function research(input: ResearchInput): Promise<ResearchResult>; /** * Interface for a mock search provider */ export interface MockSearchProvider { name: string; apiKey: string; [key: string]: string; }