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.0a4.tar.gz (23.1 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.0a4-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for elizaos_plugin_knowledge-2.0.0a4.tar.gz
Algorithm Hash digest
SHA256 db85c0c47074c312073a852d09a7852a813cb574696160dcd0edeca7f449e1fb
MD5 f83d4a66a53beaf5f860387f9a81f622
BLAKE2b-256 2783f73516d5e70396e35543a9880f2f86938ce35517a5b5f4c532da4ebcba2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elizaos_plugin_knowledge-2.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 03ac8ad290008b2d45eb4367f8c40259c30eebc00a6b273ae0eefc5ef9f595e1
MD5 b1ad4dc6fd8aef7d06f998398334186a
BLAKE2b-256 2a6fc3d901d8af39b566802e32ee4c5e21d9ff98b3b6a5f60731ac9ca05ce29e

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