Feature
Knowledge
Memory
When Used
Pre-loaded before agent execution
Created and updated during runtime
Purpose
Provide static reference information
Store dynamic context and interactions
Storage
Read-only knowledge base
Read-write memory store
Persistence
Permanent until explicitly changed
Can be temporary (STM) or persistent (LTM)
Updates
Manual updates through knowledge files
Automatic updates during agent execution
Quick Start
Install Package
Install Praison Labs Agents with knowledge support:
pip install "praisonaiagents[knowledge]"
Set API Key
Set your OpenAI API key:
export OPENAI_API_KEY = xxxxx
Create Script
Create a new file app.py
:
from praisonaiagents import Agent
agent = Agent(
name = "Knowledge Agent" ,
instructions = "You answer questions based on the provided knowledge." ,
knowledge = [ "small.pdf" ]
)
agent.start( "What is KAG in one line?" )
Basic Usage
The simplest way to create a knowledge-based agent is without
any configuration:
from praisonaiagents import Agent
agent = Agent(
name = "Knowledge Agent" ,
instructions = "You answer questions based on the provided knowledge." ,
knowledge = [ "small.pdf" ]
)
agent.start( "What is KAG in one line?" )
Advanced Configuration
For more control over the knowledge base, you can specify a
configuration:
from praisonaiagents import Agent
config = {
"vector_store" : {
"provider" : "chroma" ,
"config" : {
"collection_name" : "custom_knowledge" ,
"path" : ".praison" ,
}
}
}
agent = Agent(
name = "Knowledge Agent" ,
instructions = "You answer questions based on the provided knowledge." ,
knowledge = [ "small.pdf" ],
knowledge_config = config
)
agent.start( "What is KAG in one line?" )
Multi-Agent Knowledge System
For more complex scenarios, you can create a knowledge-based
system with multiple agents:
from praisonaiagents import Agent, Task, Praison LabsAgents
import logging
import os
# Configure logging
logging.basicConfig( level = logging. INFO , format = ' %(asctime)s - %(levelname)s - %(message)s ' )
logger = logging.getLogger( __name__ )
# Define the configuration for the Knowledge instance
config = {
"vector_store" : {
"provider" : "chroma" ,
"config" : {
"collection_name" : "knowledge_test" ,
"path" : ".praison" ,
}
}
}
# Create an agent with knowledge capabilities
knowledge_agent = Agent(
name = "KnowledgeAgent" ,
role = "Information Specialist" ,
goal = "Store and retrieve knowledge efficiently" ,
backstory = "Expert in managing and utilizing stored knowledge" ,
knowledge = [ "sample.pdf" ],
knowledge_config = config,
verbose = True
)
# Define a task for the agent
knowledge_task = Task(
name = "knowledge_task" ,
description = "Who is Mervin Praison?" ,
expected_output = "Answer to the question" ,
agent = knowledge_agent
)
# Create and start the agents
agents = Praison LabsAgents(
agents = [knowledge_agent],
tasks = [knowledge_task],
process = "sequential" ,
user_id = "user1"
)
# Start execution
result = agents.start()
Understanding Knowledge Configuration
Provider : Choose between different
vector store backends (e.g., “chroma”)
Collection Name : Name for your
knowledge collection
Path : Location to store the vector
database
PDF documents (*.pdf)
Text files (*.txt)
Markdown files (*.md, *.mdx)
And more…
Role : Define specialized roles for
knowledge agents
Goal : Set specific knowledge
management objectives
Process : Choose between sequential or
parallel execution
Features
Custom Knowledge
Import your own documents and data as knowledge
sources
Vector Storage
Efficient storage and retrieval of knowledge
embeddings
Multiple Sources
Combine multiple documents and file types
Persistent Storage
Save and reuse knowledge bases across sessions
Best Practices
Document Preparation
Clean and well-formatted documents work best
Break large documents into smaller chunks
Use consistent formatting
Knowledge Organization
Group related documents together
Use meaningful file names
Keep knowledge bases focused and relevant
Performance Optimization
Monitor vector store size
Clean up unused collections
Use appropriate chunk sizes
Multi-Agent Coordination
Define clear roles and responsibilities
Set appropriate logging levels for debugging
Use unique collection names for different agent groups
Next Steps
Responses are generated using AI and may contain
mistakes.