Skip to main content

Knowledge and RAG plugin for elizaOS - provides retrieval augmented generation capabilities

Project description

elizaos-plugin-knowledge

Knowledge and RAG (Retrieval Augmented Generation) plugin for elizaOS.

This plugin provides document processing, embedding generation, and semantic search capabilities for elizaOS agents.

Features

  • Document Processing: Extract text from PDF, DOCX, Markdown, and plain text files
  • Text Chunking: Split documents into semantic chunks with configurable overlap
  • Embedding Generation: Generate embeddings using OpenAI, Google, or Anthropic providers
  • Semantic Search: Find relevant knowledge based on query similarity
  • Contextual Retrieval: Optionally enrich chunks with contextual information

Installation

pip install elizaos-plugin-knowledge

Optional Dependencies

# For OpenAI embedding support
pip install elizaos-plugin-knowledge[openai]

# For Anthropic support
pip install elizaos-plugin-knowledge[anthropic]

# For Google AI support
pip install elizaos-plugin-knowledge[google]

# For PDF processing
pip install elizaos-plugin-knowledge[pdf]

# For DOCX processing
pip install elizaos-plugin-knowledge[docx]

# Install all optional dependencies
pip install elizaos-plugin-knowledge[all]

Usage

Basic Usage

from elizaos_plugin_knowledge import KnowledgeService, KnowledgeConfig

# Create configuration
config = KnowledgeConfig(
    embedding_provider="openai",
    embedding_model="text-embedding-3-small",
    embedding_dimension=1536,
)

# Initialize service
service = KnowledgeService(config)

# Add knowledge from text
await service.add_knowledge(
    content="The capital of France is Paris.",
    content_type="text/plain",
    filename="facts.txt",
)

# Search for knowledge
results = await service.search("What is the capital of France?")
for result in results:
    print(f"Score: {result.similarity:.2f} - {result.content}")

With elizaOS Runtime

from elizaos import Plugin
from elizaos_plugin_knowledge import create_knowledge_plugin

# Create the plugin
plugin = create_knowledge_plugin()

# Register with runtime
runtime.register_plugin(plugin)

Configuration

Parameter Type Default Description
embedding_provider str "openai" Provider for embeddings (openai, google)
embedding_model str "text-embedding-3-small" Model name for embeddings
embedding_dimension int 1536 Embedding vector dimension
ctx_knowledge_enabled bool False Enable contextual enrichment
text_provider str None Provider for text generation
text_model str None Model for text generation
chunk_size int 500 Target tokens per chunk
chunk_overlap int 100 Overlap tokens between chunks

API Reference

KnowledgeService

The main service class for knowledge management.

Methods

  • add_knowledge(content, content_type, filename, metadata) - Add a document to the knowledge base
  • search(query, count, threshold) - Search for relevant knowledge
  • get_knowledge(message) - Get knowledge relevant to a message
  • delete_knowledge(knowledge_id) - Delete a knowledge item

KnowledgeProvider

Provider that supplies knowledge context to agent prompts.

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elizaos_plugin_knowledge-2.0.0a5.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elizaos_plugin_knowledge-2.0.0a5-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file elizaos_plugin_knowledge-2.0.0a5.tar.gz.

File metadata

File hashes

Hashes for elizaos_plugin_knowledge-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 2954be842e26d8581b003d870c66260d9452dffdb81fe78459c3e6cbe085815a
MD5 0312c85cc3fcb7acccf219514db7a9d5
BLAKE2b-256 55361ed8c2804e1967c75ce6ac0e00f33756055c5147d0b3d250c69af314848f

See more details on using hashes here.

File details

Details for the file elizaos_plugin_knowledge-2.0.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for elizaos_plugin_knowledge-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 db7c324abf06b706f8ff2d19a22e2d311d264755723c1ebad6f951b342be67f5
MD5 877ac823021f666070bb3dac50eb69ba
BLAKE2b-256 93af1112c350a35fce505949a96a86e04eb8c7465d7be163869dec5f1b6edf11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page