Knowledge Tools
KnowledgeTools provide intelligent search and analysis capabilities over knowledge bases with reasoning integration.
Example
The following agent can search and analyze knowledge bases:
1from kern.agent import Agent2from kern.tools.knowledge import KnowledgeTools3from kern.knowledge import Knowledge45# Initialize knowledge base6knowledge = Knowledge()7knowledge.load_documents("./docs/")89agent = Agent(10 instructions=[11 "You are a knowledge assistant that helps find and analyze information",12 "Search through the knowledge base to answer questions",13 "Provide detailed analysis and reasoning about the information found",14 "Always cite your sources and explain your reasoning",15 ],16 tools=[KnowledgeTools(knowledge=knowledge)],17)1819agent.print_response("What are the best practices for API design?", stream=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
knowledge | Knowledge | None | Knowledge base instance (required). |
enable_think | bool | True | Enable reasoning capabilities. |
enable_search | bool | True | Enable knowledge search functionality. |
enable_analyze | bool | True | Enable knowledge analysis capabilities. |
instructions | Optional[str] | None | Custom instructions for knowledge operations. |
add_instructions | bool | True | Whether to add instructions to the agent. |
add_few_shot | bool | False | Whether to include few-shot examples. |
few_shot_examples | Optional[str] | None | Custom few-shot examples. |
Toolkit Functions
| Function | Description |
|---|---|
think | Apply reasoning to knowledge-based problems and questions. |
search | Search the knowledge base for relevant information. |
analyze | Perform detailed analysis of knowledge base content. |