@plust/datasleuth
Version:
Build LLM-powered research pipelines and output structured data.
102 lines (101 loc) • 3.3 kB
TypeScript
/**
* Web search step for the research pipeline
* Uses @plust/search-sdk to perform web searches
*/
import { SearchProvider as SDKSearchProvider } from '@plust/search-sdk';
import { createStep } from '../utils/steps.js';
import { z } from 'zod';
declare const searchResultSchema: z.ZodObject<{
url: z.ZodString;
title: z.ZodString;
snippet: z.ZodOptional<z.ZodString>;
domain: z.ZodOptional<z.ZodString>;
publishedDate: z.ZodOptional<z.ZodString>;
provider: z.ZodOptional<z.ZodString>;
raw: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
url: string;
title: string;
snippet?: string | undefined;
domain?: string | undefined;
publishedDate?: string | undefined;
provider?: string | undefined;
raw?: any;
}, {
url: string;
title: string;
snippet?: string | undefined;
domain?: string | undefined;
publishedDate?: string | undefined;
provider?: string | undefined;
raw?: any;
}>;
export type SearchResult = z.infer<typeof searchResultSchema>;
/**
* Interface for our search provider configuration
* This is a subset of the SDK's SearchProvider interface
*/
export interface SearchProviderConfig {
name: string;
apiKey: string;
cx?: string;
baseUrl?: string;
parameters?: Record<string, string | number | boolean>;
[key: string]: any;
}
/**
* Options for the web search step
*/
export interface WebSearchOptions {
/** Search provider configured from @plust/search-sdk */
provider?: SDKSearchProvider | SearchProviderConfig;
/** Optional custom query override (if not provided, will use the main research query) */
query?: string;
/** Maximum number of results to return */
maxResults?: number;
/** Language code for results (e.g., 'en') */
language?: string;
/** Country/region code (e.g., 'US') */
region?: string;
/** Content filtering level */
safeSearch?: 'off' | 'moderate' | 'strict';
/** Whether to use search queries from the research plan if available */
useQueriesFromPlan?: boolean;
/** Whether to include raw results in the state */
includeRawResults?: boolean;
/** Whether to include search results in the final results */
includeInResults?: boolean;
/** Maximum retry attempts for search requests */
maxRetries?: number;
/** Whether to require at least one successful search */
requireResults?: boolean;
}
/**
* Creates a web search step for the research pipeline
*
* This step will use either the provider specified in options or fall back to the defaultSearchProvider
* from the research state. At least one of these must be provided for the step to work.
*
* @param options Configuration options for the web search
* @returns A web search step for the research pipeline
*
* @example
* ```typescript
* // Using a specific provider in options
* searchWeb({
* provider: google.configure({
* apiKey: process.env.GOOGLE_API_KEY,
* cx: process.env.GOOGLE_CX
* }),
* maxResults: 10
* })
*
* // Or relying on the defaultSearchProvider from the research function
* searchWeb({
* maxResults: 10,
* useQueriesFromPlan: true
* })
* ```
*/
export declare function searchWeb(options: WebSearchOptions): ReturnType<typeof createStep>;
export {};