UNPKG

@langchain/community

Version:
1 lines • 3.83 kB
{"version":3,"file":"wikipedia_query_run.d.ts","names":["Tool","WikipediaQueryRunParams","UrlParameters","Record","WikipediaQueryRun","P","Promise"],"sources":["../../src/tools/wikipedia_query_run.d.ts"],"sourcesContent":["import { Tool } from \"@langchain/core/tools\";\n/**\n * Interface for the parameters that can be passed to the\n * WikipediaQueryRun constructor.\n */\nexport interface WikipediaQueryRunParams {\n topKResults?: number;\n maxDocContentLength?: number;\n baseUrl?: string;\n}\n/**\n * Type alias for URL parameters. Represents a record where keys are\n * strings and values can be string, number, boolean, undefined, or null.\n */\ntype UrlParameters = Record<string, string | number | boolean | undefined | null>;\n/**\n * Wikipedia query tool integration.\n *\n * Setup:\n * Install `@langchain/community`. You'll also need an API key.\n *\n * ```bash\n * npm install @langchain/community\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_community.tools_wikipedia_query_run.WikipediaQueryRun.html#constructor)\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { WikipediaQueryRun } from \"@langchain/community/tools/wikipedia_query_run\";\n *\n * const tool = new WikipediaQueryRun({\n * topKResults: 3,\n * maxDocContentLength: 4000,\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n *\n * <summary><strong>Invocation</strong></summary>\n *\n * ```typescript\n * await tool.invoke(\"what is the current weather in sf?\");\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n *\n * <summary><strong>Invocation with tool call</strong></summary>\n *\n * ```typescript\n * // This is usually generated by a model, but we'll create a tool call directly for demo purposes.\n * const modelGeneratedToolCall = {\n * args: {\n * input: \"what is the current weather in sf?\",\n * },\n * id: \"tool_call_id\",\n * name: tool.name,\n * type: \"tool_call\",\n * };\n * await tool.invoke(modelGeneratedToolCall);\n * ```\n *\n * ```text\n * ToolMessage {\n * \"content\": \"...\",\n * \"name\": \"wikipedia-api\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {},\n * \"tool_call_id\": \"tool_call_id\"\n * }\n * ```\n * </details>\n */\nexport declare class WikipediaQueryRun extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected topKResults: number;\n protected maxDocContentLength: number;\n protected baseUrl: string;\n constructor(params?: WikipediaQueryRunParams);\n _call(query: string): Promise<string>;\n /**\n * Fetches the content of a specific Wikipedia page. It returns the\n * extracted content as a string.\n * @param page The specific Wikipedia page to fetch its content.\n * @param redirect A boolean value to indicate whether to redirect or not.\n * @returns The extracted content of the specific Wikipedia page as a string.\n */\n content(page: string, redirect?: boolean): Promise<string>;\n /**\n * Builds a URL for the Wikipedia API using the provided parameters.\n * @param parameters The parameters to be used in building the URL.\n * @returns A string representing the built URL.\n */\n protected buildUrl<P extends UrlParameters>(parameters: P): string;\n private _fetchSearchResults;\n private _fetchPage;\n}\nexport {};\n//# sourceMappingURL=wikipedia_query_run.d.ts.map"],"mappings":";;;;;;AAKA;AAIC;AAwEoBI,UA5EJH,uBAAAA,CA4EqB;EAObA,WAAAA,CAAAA,EAAAA,MAAAA;EACCK,mBAAAA,CAAAA,EAAAA,MAAAA;EAQqBA,OAAAA,CAAAA,EAAAA,MAAAA;;;;AAhBI;;KAnE9CJ,aAAAA,GAAgBC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmEAC,iBAAAA,SAA0BJ,IAAAA;;;;;;;uBAOtBC;wBACCK;;;;;;;;6CAQqBA;;;;;;+BAMdJ,2BAA2BG"}