UNPKG

@openai/agents-openai

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

165 lines (164 loc) • 6.39 kB
import { HostedTool, type ClientToolSearchExecutor, type ToolAllowedCallers } from '@openai/agents-core'; import type OpenAI from 'openai'; import * as ProviderData from './types/providerData'; /** * The built-in Web search tool * * see https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses */ export type WebSearchTool = { type: 'web_search'; name?: 'web_search' | 'web_search_preview' | (string & {}); /** * Optional location for the search. Lets you customize results to be relevant to a location. */ userLocation?: OpenAI.Responses.WebSearchTool.UserLocation; /** * Optional filters for the search. */ filters?: { allowedDomains?: Array<string> | null; }; /** * High level guidance for the amount of context window space to use for the * search. One of `low`, `medium`, or `high`. `medium` is the default. */ searchContextSize: 'low' | 'medium' | 'high'; /** * Whether the tool may fetch live internet content. When omitted, the API * default is used. */ externalWebAccess?: boolean; /** * The kinds of search results to return. When omitted, the API default is used. * Including `image` also requests raw results, available on web search call * items in `providerData.results`. */ searchContentTypes?: ProviderData.WebSearchTool['search_content_types']; /** * Image result settings when `searchContentTypes` includes `image`. */ imageSettings?: { /** * The positive number of image results to request. */ maxResults?: number; /** * Whether to request a short caption for each image when available. */ caption?: boolean; }; }; /** * Adds web search abilities to your agent * @param options Additional configuration for the web search like specifying the location of your agent * @returns a web search tool definition */ export declare function webSearchTool(options?: Partial<Omit<WebSearchTool, 'type'>>): HostedTool; /** * The built-in File search (backed by vector stores) tool */ export type FileSearchTool = { type: 'file_search'; name?: 'file_search' | (string & {}); /** * The IDs of the vector stores to search. */ vectorStoreId: string[]; /** * The maximum number of results to return. */ maxNumResults?: number; /** * Whether to include the search results in the output produced by the LLM. */ includeSearchResults?: boolean; /** * Ranking options for search. */ rankingOptions?: OpenAI.Responses.FileSearchTool.RankingOptions; /** * A filter to apply based on file attributes. */ filters?: OpenAI.ComparisonFilter | OpenAI.CompoundFilter; }; /** * Adds file search abilities to your agent * @param vectorStoreIds The IDs of the vector stores to search. * @param options Additional configuration for the file search like specifying the maximum number of results to return. * @returns a file search tool definition */ export declare function fileSearchTool(vectorStoreIds: string | string[], options?: Partial<Omit<FileSearchTool, 'type' | 'vectorStoreId'>>): HostedTool; export type CodeInterpreterTool = { type: 'code_interpreter'; name?: 'code_interpreter' | (string & {}); /** * Whether to include code interpreter outputs in the response. */ includeOutputs?: boolean; container?: string | OpenAI.Responses.Tool.CodeInterpreter.CodeInterpreterToolAuto; /** * Execution contexts allowed to invoke code interpreter. */ allowedCallers?: ToolAllowedCallers; }; export type ProgrammaticToolCallingTool = HostedTool & { type: 'hosted_tool'; name: 'programmatic_tool_calling'; providerData: ProviderData.ProgrammaticToolCallingTool; }; export type ToolSearchTool<Context = unknown> = { type: 'tool_search'; name?: 'tool_search'; execution?: OpenAI.Responses.ToolSearchTool['execution']; description?: string | null; parameters?: unknown | null; execute?: ClientToolSearchExecutor<Context>; }; /** * Adds code interpreter abilities to your agent * @param options Additional configuration for the code interpreter * @returns a code interpreter tool definition */ export declare function codeInterpreterTool(options?: Partial<Omit<CodeInterpreterTool, 'type'>>): HostedTool; /** * Enables Programmatic Tool Calling for eligible Responses API tools. */ export declare function programmaticToolCallingTool(): ProgrammaticToolCallingTool; /** * Adds tool_search capabilities to your agent. * * This lets the model search deferred function tools and load them into context on demand. * By default, tool search is executed by OpenAI. Set `execution: 'client'` to * use a custom loop that receives `tool_search_call` / `tool_search_output` * items. The standard runner only supports the default built-in client schema * (leave `parameters` unset) and auto-executes `{ paths: string[] }` searches * over deferred top-level function tools and deferred namespace members. * * @returns a hosted tool_search definition. */ export declare function toolSearchTool<Context = unknown>(options?: Partial<Omit<ToolSearchTool<Context>, 'type'>>): HostedTool; /** * The built-in Image generation tool */ export type ImageGenerationTool = { type: 'image_generation'; name?: 'image_generation' | (string & {}); action?: OpenAI.Responses.Tool.ImageGeneration['action']; background?: 'transparent' | 'opaque' | 'auto' | (string & {}); inputFidelity?: 'high' | 'low' | null; inputImageMask?: OpenAI.Responses.Tool.ImageGeneration.InputImageMask; model?: 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | (string & {}); moderation?: 'auto' | 'low' | (string & {}); outputCompression?: number; outputFormat?: 'png' | 'webp' | 'jpeg' | (string & {}); partialImages?: number; quality?: 'low' | 'medium' | 'high' | 'auto' | (string & {}); size?: '1024x1024' | '1024x1536' | '1536x1024' | 'auto' | (string & {}); }; /** * Adds image generation abilities to your agent * @param options Additional configuration for the image generation * @returns an image generation tool definition */ export declare function imageGenerationTool(options?: Partial<Omit<ImageGenerationTool, 'type'>>): HostedTool;