File size: 5,696 Bytes
b0af996
f4b92b8
 
 
 
 
 
 
 
 
 
 
 
 
b0af996
27716f7
f4b92b8
 
 
 
 
 
 
 
 
 
27716f7
 
f4b92b8
 
 
 
 
 
 
 
 
 
27716f7
f4b92b8
 
27716f7
f4b92b8
 
 
 
 
 
 
 
 
 
 
 
 
27716f7
 
b0af996
f4b92b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bb5d2bb
27716f7
b0af996
 
f4b92b8
 
 
27716f7
 
 
 
 
 
 
 
 
f4b92b8
 
 
bb5d2bb
27716f7
 
bb5d2bb
 
 
e67c48b
 
 
 
 
 
 
 
 
 
b0af996
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Architecture and API - v1.6

## Runtime architecture

RAGForge uses one FastAPI application with a mounted Gradio UI. Each browser/API session maps to an isolated in-process `Workspace` containing document units, chunk/source indexes, DuckDB tables, history and corpus version.

### LangGraph path

```text
request
  -> guard
  -> semantic route
  -> workspace preflight
  -> plan
  -> semantic/global/hierarchical/analytical/table/web retrieval
  -> adaptive reranker policy (skip or cross-encoder)
  -> evidence grade
  -> optional correction + retry
  -> conditional web augmentation
  -> grounded generation
  -> verification / bounded revision
  -> cited response or abstention
```

The Architecture + API tab exposes the responsibilities of each graph node in a live DataFrame.

The adaptive reranker decision is recorded in the retrieval trace as `reranker_used` and `reranker_reason`. Standard/Deep evaluation still runs an explicit on/off ablation so the runtime decision remains measurable.

## Live workspace snapshot

`Refresh runtime view` reports:

- app version,
- workspace status/version,
- source count,
- chunk count,
- source-profile count,
- table count,
- saved evaluation depths,
- configured generation/embedding/reranker/search models.

It also generates curl examples using the current browser workspace ID and reports saved evaluation inventory through workspace stats.

## REST surface

| Method | Path | Purpose |
|---|---|---|
| GET | `/api/health` | health check |
| GET | `/api/v1/info` | service/model/features metadata |
| POST | `/api/v1/session` | create session |
| GET | `/api/v1/session/{session_id}` | inspect workspace status |
| POST | `/api/v1/ingest` | multipart document ingestion |
| POST | `/api/v1/query` | execute RAG query |
| POST | `/api/v1/evaluate/demo` | Quick/Standard/Deep benchmark |
| GET | `/api/v1/evaluation/benchmark` | benchmark metadata/counts |
| GET | `/api/v1/evaluation/saved/{session_id}` | list saved Quick/Standard/Deep runs |
| GET | `/api/v1/evaluation/saved/{session_id}/{level}` | retrieve one saved evaluation report |
| GET | `/api/v1/evaluation/history/{session_id}` | list timestamped evaluation history and deltas |
| GET | `/docs` | Swagger UI |
| GET | `/openapi.json` | OpenAPI schema |
| GET | `/metrics` | Prometheus metrics |

When `APP_API_TOKEN` is set, protected endpoints require a Bearer token.

## Query example

```bash
curl -X POST http://localhost:7860/api/v1/query \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "SESSION_ID",
    "query": "What is the collection about?",
    "config": {
      "mode": "Auto",
      "profile": "Balanced",
      "model": "gemini-3.5-flash-lite"
    }
  }'
```

## Evaluation example

```bash
curl -X POST http://localhost:7860/api/v1/evaluate/demo \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "SESSION_ID",
    "level": "Standard",
    "model": "gemini-3.5-flash-lite",
    "target_rpm": 12,
    "reuse_saved": true,
    "include_profile_benchmark": false
  }'
```

When `reuse_saved=true`, a compatible saved report can be returned with zero Gemini requests. For Deep, a compatible saved Standard report can be reused as the deterministic baseline so only the sampled judge layer is added.

Saved evaluations can be inspected without rerunning:

```bash
curl http://localhost:7860/api/v1/evaluation/saved/SESSION_ID
curl http://localhost:7860/api/v1/evaluation/saved/SESSION_ID/Standard
```

## Storage lifecycle

Standard Hugging Face Space disk is ephemeral for this deployment design. Browser state stores only the opaque workspace ID. A normal refresh can reconnect while the process lives; a container restart removes in-memory indexes and custom uploads must be re-indexed. Bundled demo data can be lazily rebuilt.

Evaluation reports are stored inside the same ephemeral workspace. They survive a normal browser refresh while the workspace/container lives, but are not durable production storage. Reports include model/benchmark/corpus-version metadata so stale runs are visible rather than silently reused after corpus changes.

## Evaluation quota controls

`POST /api/v1/evaluate/demo` accepts `target_rpm`. The UI defaults to 12 RPM for quota-safe portfolio/free-tier runs. The benchmark uses one shared rolling request budget across planner, generation, Text2SQL and Deep-judge calls, and the raw report exposes request/pacing telemetry.


## Evaluation report portability in v1.5.1

Saved Quick, Standard and Deep reports are converted to plain JSON before persistence and API
return. This keeps `GET /api/v1/evaluation/saved/{session_id}/{level}` structurally identical to a
fresh evaluation response and avoids UI-framework wrapper representations.

The Gradio Evaluation tab also exposes a table export panel. This is a UI convenience rather than a
new network API: it materializes CSV/TSV/Markdown files inside the current ephemeral workspace.


## v1.6 analytical evidence path

`insight_synthesis` requests use the `analytical` strategy. Source-balanced original document chunks remain `[D#]` evidence. DuckDB contributes deterministic schema, bounded rows and descriptive signals as `[T#]` evidence. One grounded generation call synthesizes patterns, quantitative signals, contrasts and caveats. The table context is not an LLM-generated summary, so no additional API request is spent preparing it.

## v1.6 evaluation observability

The UI exposes Hard Mode, optional profile comparison, node-latency summaries and timestamped evaluation history. `GET /api/v1/evaluation/history/{session_id}` exposes the same archived-run metadata to API clients. The normal latest-run endpoints remain unchanged.