@plust/datasleuth - v0.2.0
    Preparing search index...

    Function orchestrate

    • Creates an orchestration step that uses agents to make decisions

      This step uses an LLM to dynamically select and execute research tools based on the current state. It can handle an entire research process from start to finish by adaptively choosing the right tools.

      Parameters

      • options: OrchestrateOptions

        Configuration for the orchestration

        Options for the orchestration step

        • model: LanguageModelV1

          LLM model to use for orchestration (from the AI library)

        • OptionalsearchProvider?: any

          Default search provider to use for search-dependent steps

        • Optionaltools?: Record<string, ResearchStep>

          Map of tool names to step functions that can be used by the agent

        • OptionalcustomPrompt?: string

          Custom prompt for the orchestration agent

        • OptionalmaxIterations?: number

          Maximum number of iterations

        • OptionalexitCriteria?: (state: ResearchState) => boolean | Promise<boolean>

          Optional function that determines when to exit orchestration

        • OptionalincludeInResults?: boolean

          Whether to include the orchestration results in the final output

        • OptionalcontinueOnError?: boolean

          Whether to continue if a tool execution fails

        • OptionaltoolSelectorFn?: (
              state: ResearchState,
              availableTools: string[],
          ) => Promise<{ toolName: string; reasoning: string }>

          Custom tool selection function (if provided, uses this instead of LLM)

        • Optionalretry?: { maxRetries?: number; baseDelay?: number }

          Retry configuration

          • OptionalmaxRetries?: number

            Maximum number of retries

          • OptionalbaseDelay?: number

            Base delay between retries in ms

      Returns ResearchStep

      An orchestration step for the research pipeline

      import { research, orchestrate } from '@plust/datasleuth';
      import { openai } from '@ai-sdk/openai';
      import { google } from '@plust/search-sdk';

      const results = await research({
      query: 'Impact of climate change on agriculture',
      outputSchema: schema,
      steps: [
      orchestrate({
      model: openai('gpt-4o'),
      searchProvider: google.configure({ apiKey: process.env.GOOGLE_API_KEY }),
      maxIterations: 15,
      continueOnError: true,
      exitCriteria: (state) => state.data.summary !== undefined
      })
      ]
      });