class WikipediaQueryRunSerializableWikipedia query tool integration.
Setup:
Install @langchain/community. You'll also need an API key.
npm install @langchain/community
import { WikipediaQueryRun } from "@langchain/community/tools/wikipedia_query_run";
const tool = new WikipediaQueryRun({
topKResults: 3,
maxDocContentLength: 4000,
});
await tool.invoke("what is the current weather in sf?");
// This is usually generated by a model, but we'll create a tool call directly for demo purposes.
const modelGeneratedToolCall = {
args: {
input: "what is the current weather in sf?",
},
id: "tool_call_id",
name: tool.name,
type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);
ToolMessage {
"content": "...",
"name": "wikipedia-api",
"additional_kwargs": {},
"response_metadata": {},
"tool_call_id": "tool_call_id"
}