From bcf74726ba8bc6a4b01cf45c006e9d200aeb8ffa Mon Sep 17 00:00:00 2001 From: zTgx <747674262@qq.com> Date: Wed, 15 Apr 2026 16:01:57 +0800 Subject: [PATCH] refactor(docs): update API usage examples with new QueryContext and from_path methods - Replace IndexContext.from_file() with IndexContext.from_path() in documentation examples - Update query method to use QueryContext with with_doc_ids() instead of direct doc_id parameter - Add QueryContext import to code examples --- README.md | 8 +++++--- docs/blog/2026-04-12-welcome/index.mdx | 2 +- docs/docs/intro.mdx | 2 +- docs/src/pages/index.tsx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d74ea257..6da319d7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ pip install vectorless ```python import asyncio -from vectorless import Engine, IndexContext +from vectorless import Engine, IndexContext, QueryContext async def main(): # Create engine — api_key and model are required @@ -38,11 +38,13 @@ async def main(): ) # Index a document (PDF or Markdown) - result = await engine.index(IndexContext.from_file("./report.pdf")) + result = await engine.index(IndexContext.from_path("./report.pdf")) doc_id = result.doc_id # Query - result = await engine.query(doc_id, "What is the total revenue?") + result = await engine.query( + QueryContext("What is the total revenue?").with_doc_ids([doc_id]) + ) print(result.single().content) asyncio.run(main()) diff --git a/docs/blog/2026-04-12-welcome/index.mdx b/docs/blog/2026-04-12-welcome/index.mdx index 686655cd..aa6e8a95 100644 --- a/docs/blog/2026-04-12-welcome/index.mdx +++ b/docs/blog/2026-04-12-welcome/index.mdx @@ -34,7 +34,7 @@ async def main(): ) # Index a document - result = await engine.index(IndexContext.from_file("./report.pdf")) + result = await engine.index(IndexContext.from_path("./report.pdf")) doc_id = result.doc_id # Query diff --git a/docs/docs/intro.mdx b/docs/docs/intro.mdx index 88fa23fb..fcaed058 100644 --- a/docs/docs/intro.mdx +++ b/docs/docs/intro.mdx @@ -32,7 +32,7 @@ async def main(): model="gpt-4o", ) - result = await engine.index(IndexContext.from_file("./report.pdf")) + result = await engine.index(IndexContext.from_path("./report.pdf")) doc_id = result.doc_id answer = await engine.query(doc_id, "What is the total revenue?") diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index 3ecc47c7..83e3d697 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -55,7 +55,7 @@ async def main(): # Index a document result = await engine.index( - IndexContext.from_file("./report.pdf") + IndexContext.from_path("./report.pdf") ) doc_id = result.doc_id