Class: Langchain::Tool::Wikipedia
- Inherits:
-
Object
- Object
- Langchain::Tool::Wikipedia
- Extended by:
- Langchain::ToolDefinition
- Includes:
- DependencyHelper
- Defined in:
- lib/langchain/tool/wikipedia.rb
Overview
Instance Method Summary collapse
-
#execute(input:) ⇒ String
Executes Wikipedia API search and returns the answer.
-
#initialize ⇒ Wikipedia
constructor
Initializes the Wikipedia tool.
Methods included from Langchain::ToolDefinition
define_function, function_schemas, tool_name
Methods included from DependencyHelper
Constructor Details
#initialize ⇒ Wikipedia
Initializes the Wikipedia tool
23 24 25 |
# File 'lib/langchain/tool/wikipedia.rb', line 23 def initialize depends_on "wikipedia-client", req: "wikipedia" end |
Instance Method Details
#execute(input:) ⇒ String
Executes Wikipedia API search and returns the answer
31 32 33 34 35 36 37 |
# File 'lib/langchain/tool/wikipedia.rb', line 31 def execute(input:) Langchain.logger.debug("#{self.class} - Executing \"#{input}\"") page = ::Wikipedia.find(input) # It would be nice to figure out a way to provide page.content but the LLM token limit is an issue page.summary end |