Skip to content
Merged

Dev #114

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 44 additions & 72 deletions vectorless/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Vectorless Python SDK
# Vectorless

Python bindings for [vectorless](https://github.com/vectorlessflow/vectorless) — a Document Understanding Engine for AI.
Python bindings for [Vectorless](https://github.com/vectorlessflow/vectorless) — knowing by reasoning, not vectors.

## Installation

```bash
pip install vectorless
pip install -U vectorless
```

## Quick Start
Expand All @@ -15,33 +15,25 @@ import asyncio
from vectorless import Engine

async def main():
# Create engine — api_key and model are required
engine = Engine(
api_key="sk-...",
model="gpt-4o",
)
engine = Engine(api_key="sk-...", model="gpt-4o")

# Understand a document
doc = await engine.ingest("./report.pdf")
print(f"Understood: {doc.name} — {doc.summary}")
# Compile a document
result = await engine.compile(path="./report.pdf")
doc_id = result.doc_id

# Ask a question
answer = await engine.ask(
"What is the total revenue?",
doc_ids=[doc.doc_id],
)
print(f"Answer: {answer.content}")
print(f"Confidence: {answer.confidence:.2f}")
print(f"Evidence: {len(answer.evidence)} pieces")
print(f"Trace: {len(answer.trace.steps)} steps")

# List all understood documents
response = await engine.ask("What is the total revenue?", doc_ids=[doc_id])
print(response.answer)
print(f"Confidence: {response.confidence:.2f}")
print(f"Evidence: {len(response.evidence)} pieces")

# List all documents
docs = await engine.list_documents()
for d in docs:
print(f" - {d.name} ({d.doc_id})")

# Forget a document
await engine.forget(doc.doc_id)
# Remove a document
await engine.remove_document(doc_id)

asyncio.run(main())
```
Expand All @@ -59,40 +51,39 @@ class Engine:
api_key: str | None = None,
model: str | None = None,
endpoint: str | None = None,
config: Config | None = None,
config: EngineConfig | None = None,
): ...

async def ingest(self, path: str) -> DocumentInfo: ...
async def ask(self, question: str, doc_ids: list[str] | None = None) -> Answer: ...
async def forget(self, doc_id: str) -> None: ...
async def list_documents(self) -> list[DocumentInfo]: ...
async def exists(self, doc_id: str) -> bool: ...
async def clear(self) -> int: ...
async def compile(self, path: str | None = None, *, format: str | None = None, mode: str | None = None, force: bool = False) -> IndexResultWrapper: ...
async def compile_batch(self, paths: list[str], *, mode: str | None = None, jobs: int = 4, force: bool = False) -> IndexResultWrapper: ...
async def ask(self, question: str, doc_ids: list[str] | None = None, timeout_secs: int | None = None) -> Output: ...
async def query_stream(self, question: str, doc_ids: list[str] | None = None) -> StreamingQueryResult: ...
async def list_documents(self) -> list[DocCard]: ...
async def remove_document(self, doc_id: str) -> None: ...
async def document_exists(self, doc_id: str) -> bool: ...
async def clear_all(self) -> int: ...
async def get_graph(self) -> DocumentGraph | None: ...
def metrics_report(self) -> MetricsReport: ...
```

### DocumentInfo
### IndexResultWrapper

```python
class DocumentInfo:
doc_id: str
name: str
format: str
summary: str
concepts: list[Concept]
section_count: int
page_count: int | None
class IndexResultWrapper:
doc_id: str | None
items: list[DocCard]
failed: list[FailedItem]
```

### Answer
### Output

```python
class Answer:
content: str
class Output:
answer: str
evidence: list[Evidence]
confidence: float
trace: ReasoningTrace
trace_steps: list[TraceStep]
metrics: QueryMetrics
```

### Evidence
Expand All @@ -101,15 +92,19 @@ class Answer:
class Evidence:
content: str
source_path: str
node_title: str
doc_name: str
relevance: float
```

### ReasoningTrace
### DocCard

```python
class ReasoningTrace:
steps: list[TraceStep]
class DocCard:
doc_id: str
name: str
summary: str
section_count: int
concepts: list[Concept]
```

### TraceStep
Expand All @@ -121,15 +116,6 @@ class TraceStep:
round: int
```

### Concept

```python
class Concept:
name: str
description: str
confidence: float
```

### VectorlessError

```python
Expand All @@ -140,24 +126,10 @@ class VectorlessError(Exception):

## Development

### Building from source

```bash
# Install maturin
pip install maturin

# Build and install (from project root)
maturin develop

# Run tests
pytest
```

### Publishing to PyPI

```bash
maturin build --release
maturin publish
maturin develop # Build and install
pytest # Run tests
```

## License
Expand Down
Loading