Quick Query Example
This example demonstrates the basic compile-and-ask workflow.
import asyncio
from vectorless import Engine
async def main():
# 1. Create engine
engine = Engine(
api_key="sk-...",
model="gpt-4o",
)
# 2. Compile a document
result = await engine.compile(path="./report.pdf")
doc_id = result.doc_id
print(f"Compiled document: {doc_id}")
# 3. Simple keyword query
response = await engine.ask("revenue", doc_ids=[doc_id])
print(f"Result: {response.single().content[:200]}")
# 4. Complex reasoning query
response = await engine.ask(
"What are the main factors affecting performance?",
doc_ids=[doc_id],
)
print(f"Confidence: {response.single().confidence:.2f}")
print(f"Result: {response.single().content[:200]}")
# 5. Cleanup
await engine.remove_document(doc_id)
asyncio.run(main())