UNPKG

@smythos/sdk

Version:
91 lines (77 loc) 2.75 kB
//!!! DO NOT EDIT THIS FILE, IT IS AUTO-GENERATED !!!// import { Agent } from '../../Agent/Agent.class'; import { createSafeAccessor } from '../utils'; import { ComponentWrapper } from '../ComponentWrapper.class'; import { InputSettings, ComponentInput } from '../../types/SDKTypes'; export interface TTavilyWebSearchSettings { name?: string; /** Include Image Results */ includeImages?: boolean; /** Sources Limit */ sourcesLimit?: number; /** Search Topic */ searchTopic?: 'general' | 'news'; /** Include QAs */ includeQAs?: boolean; /** Time Range */ timeRange?: 'None' | 'day' | 'week' | 'month' | 'year'; /** Include Raw Content */ includeRawContent?: boolean; /** Exclude Domains */ excludeDomains?: string; } export type TTavilyWebSearchInputs = { /** The search query to get the web search results of */ SearchQuery?: string; [key: string]: any; }; export type TTavilyWebSearchOutputs = { /** The web search results */ Results: any; [key: string]: any; }; /** * Use this component to generate a responses from an LLM */ export function TavilyWebSearch(settings?: TTavilyWebSearchSettings, agent?: Agent) { //const { name, ...settingsWithoutName } = settings || {}; const dataObject: any = { name: /*settings?.name || */'TavilyWebSearch', settings: { //...settingsWithoutName ...settings } }; const component = new ComponentWrapper(dataObject, agent); if (agent) { (agent.structure.components as ComponentWrapper[]).push(component); agent.sync(); } const _out: TTavilyWebSearchOutputs = createSafeAccessor({ Results: createSafeAccessor({}, component, 'Results', {"type":"Array","description":"The web search results","default":true}), }, component, ''); const _in: { [key: string]: ComponentInput } = { SearchQuery: { component, type: 'Text', optional: false, default: true, }, }; dataObject.outputs = _out; dataObject.inputs = _in; component.inputs(_in); const wrapper = { /** Component outputs - access via .out.OutputName */ out: _out, /** * Create or Connect the component inputs * if the input does not exist, it will be created * @examples * - component.in({ Input: source.out.data }) * - component.in({ Input: { type: 'string', source:source.out.data } }) */ in: component.inputs.bind(component) as (inputs: TTavilyWebSearchInputs) => void, }; return wrapper; }