Skip to main content

A package for importing knowledge and embedding text.

Project description

Import Knowledge (import-kb)

A utility package for importing distilled knowledge and curriculum files into a ChromaDB-based Long-Term Memory (LTM) system.

Purpose

The import-kb package is designed to bridge the gap between static knowledge files (JSONL, MeTTa) and an active agent's memory. It processes structured knowledge, generates vector embeddings, and upserts them into a ChromaDB collection, enabling semantic search and retrieval for AI agents.

Supported Embedding Models

This package supports two primary embedding modes:

  • OpenAI (Cloud):
    • Default model: text-embedding-3-large
    • High accuracy but requires an internet connection and an API key.
  • SentenceTransformers (Local):
    • Default model: intfloat/e5-large-v2
    • Runs fully offline on your local machine.
    • Can be configured to use any model compatible with the sentence-transformers library (e.g., all-MiniLM-L6-v2).

Installation

You can install the package directly from PyPI:

pip install import-kb

Or install it locally in editable mode:

git clone <repository-url>
cd import-knowledge-package
pip install -e .

Setup

Create a .env file in your project root or set the following environment variables:

  • OPENAI_API_KEY: Required if using OpenAI embeddings.
  • CHROMA_DB_PATH: (Optional) Custom path to your Chroma database. Defaults to looking for /PeTTa/chroma_db or a local chroma_db folder.

How to Run

Command Line Interface (CLI)

After installation, you can run the import via the provided entry point:

# Use OpenAI embeddings (default)
import-knowledge

# Use Local embeddings
import-knowledge --local

# Use a specific local model
import-knowledge --local --model "all-MiniLM-L6-v2"

# Override OpenAI model
import-knowledge --model "text-embedding-3-small"

Alternatively, run it as a module:

python3 -m import_knowledge.import_knowledge --local

Programmatic Usage

You can initialize the embedding system and trigger the import programmatically from your Python scripts:

from import_knowledge import initLocalEmbedding, main

# Initialize for local use
initLocalEmbedding(model_name="intfloat/e5-large-v2")

# Run the import process
main()

Dependencies

  • openai: For cloud-based embeddings.
  • sentence-transformers: For local, offline embeddings.
  • chromadb: Vector database for storage.
  • python-dotenv: Management of environment variables.
  • tqdm: Progress bars for batch processing.

License

MIT License. See the LICENSE file for more 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

import_kb-0.1.5.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

import_kb-0.1.5-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file import_kb-0.1.5.tar.gz.

File metadata

  • Download URL: import_kb-0.1.5.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for import_kb-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2a04f7c76ef4e8afaaecfc73ca0fc0b0ce0bd7bf2d6f0b0f8182b1114159fc44
MD5 c25899205e3b7bb2a89f7de4e0eb56b2
BLAKE2b-256 64479d7f24a3b87c3c0c285adc6cb87a0395559357e17da446e4e7e70f01b870

See more details on using hashes here.

File details

Details for the file import_kb-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: import_kb-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for import_kb-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5457372ef178db30101df1ebc4156fecfabcdeabb811d19f474418c240868e12
MD5 5bffb1190f3762995f28167c6bdcc2de
BLAKE2b-256 08752fba4059ea588a91c785eccf4b132caa1fd87881f84192ccfd31b08b3588

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