Skip to content

Latest commit

 

History

History

knowledge

README.md

Knowledge Examples

Knowledge-enhanced AI agents examples.

Environment

export OPENAI_BASE_URL=xxx
export OPENAI_API_KEY=xxx
export MODEL_NAME=xxx

Common flags

Most examples accept:

-vectorstore inmemory|pgvector|tcvector|elasticsearch  # default: inmemory

Examples

chunking/

Offline text and interactive web viewers that show each Reader's default strategy, with advanced comparisons for FixedSizeChunking, RecursiveChunking, MarkdownChunking, and JSONChunking.

basic/

Basic example with file source and in-memory vector store.

contextual-retrieval/

Opt-in index-time contextual retrieval using a custom source wrapper. It keeps the original chunk content unchanged, caches generated context locally, and supports paired baseline / contextual trials. This is an evaluation example, not a default recommendation; see its README for evidence, security, and cost boundaries.

sources/

Different data source types:

Case Description
file-source/ Load individual files (Markdown, PDF, DOCX, CSV, JSON)
directory-source/ Recursively load entire directory
url-source/ Fetch and parse web pages
auto-source/ Auto-detect source type from path

vectorstores/

Persistent vector storage options:

Case Description Extra Environment
chroma/ ChromaDB over the Chroma v2 REST API CHROMA_URL, CHROMA_COLLECTION, CHROMA_API_KEY, CHROMA_TENANT, CHROMA_DATABASE
postgres/ PostgreSQL with pgvector extension PGVECTOR_HOST, PGVECTOR_PORT, PGVECTOR_USER, PGVECTOR_PASSWORD, PGVECTOR_DATABASE, PGVECTOR_TABLE
elasticsearch/ Elasticsearch (v7/v8/v9) ELASTICSEARCH_HOSTS, ELASTICSEARCH_USERNAME, ELASTICSEARCH_PASSWORD, ELASTICSEARCH_INDEX_NAME
tcvector/ Tencent VectorDB TCVECTOR_URL, TCVECTOR_USERNAME, TCVECTOR_PASSWORD, TCVECTOR_COLLECTION
milvus/ Milvus vector database MILVUS_ADDRESS, MILVUS_USERNAME, MILVUS_PASSWORD, MILVUS_DB_NAME, MILVUS_COLLECTION

features/

Advanced features:

Case Description
agentic-filter/ LLM automatically generates metadata filter based on user query
metadata-filter/ Programmatic metadata filtering with AND/OR/NOT operations
management/ Dynamic source management: AddSource, RemoveSource, ReloadSource
batch-embedding/ Group documents into multi-input embedding requests with WithEmbeddingBatchSize