cocoindex-io/ cocoindex
View on GitHubIncremental engine for long horizon agents 🌟 Star if you like it!
Incremental engine for long horizon agents 🌟 Star if you like it!
Deutsch | English | Español | français | 日本語 | 한국어 | Português | Русский | 中文
pip install -U cocoindex
Declare what should be in your target — CocoIndex keeps it in sync forever, recomputing only the Δ.
import cocoindex as coco
from cocoindex.connectors import localfs, postgres
from cocoindex.ops.text import RecursiveSplitter
@coco.fn(memo=True) # ← cached by hash(input) + hash(code)
async def index_file(file, table):
for chunk in RecursiveSplitter().split(await file.read_text()):
table.declare_row(text=chunk.text, embedding=embed(chunk.text))
@coco.fn
async def main(src):
table = await postgres.mount_table_target(PG, table_name="docs")
table.declare_vector_index(column="embedding")
await coco.mount_each(index_file, localfs.walk_dir(src).items(), table)
coco.App(coco.AppConfig(name="docs"), main, src="./docs").update_blocking()
No comments yet. Set the tone — say what you would want to know.