ArchitSharma commited on
Commit
0e7bbcc
·
1 Parent(s): e67c48b

Fix RAGForge v1.5.2 citation helper runtime import

Browse files
README.md CHANGED
@@ -10,21 +10,19 @@ pinned: false
10
 
11
  # RAGForge
12
 
13
- **RAGForge v1.5.1 - a production-style, portfolio-ready agentic RAG system for Hugging Face Spaces.**
14
 
15
  RAGForge combines hybrid document retrieval, source-level/hierarchical retrieval, semantic query planning, corrective RAG, Self-RAG-style verification, Text2SQL and an “Ask-the-Web” research path in one CPU-friendly application. The default LLM is **Google Gemini 3.5 Flash-Lite**; the UI also exposes Gemini 3.1 Flash-Lite and stronger Flash models.
16
 
17
 
18
- ## What is new in v1.5.1
19
 
20
- v1.5.1 is a focused stabilization release built from real v1.5 benchmark feedback.
21
 
22
- - **Stable saved-report JSON** - fresh and restored evaluation reports are normalized to plain JSON before rendering or API return. The Raw evaluation report uses a copy-ready JSON code view, so switching Quick/Standard/Deep no longer produces `root={...}` representations.
23
- - **Copy/export for every evaluation table** - Focused QA, Semantic planner, Corpus overview, Text2SQL, Retrieval ablation, Abstention and Compare saved runs can all be exported as CSV, TSV or Markdown and downloaded directly.
24
- - **Citation syntax normalization** - grouped model citations such as `[D1, D2]` are normalized consistently, and deterministic citation metrics recognize both grouped and single-ID syntax.
25
- - **Safer zero-call citation repair** - list/preamble lines ending in `:` are no longer auto-cited, preventing broad introductory claims from inheriting an unrelated high-overlap source.
26
- - **Citation-tail cleanup** - repeated trailing citation sets are deduplicated to reduce output such as `[D3, D6]. [D6] [D3]`.
27
- - **v1.5 evaluation/retrieval improvements retained** - typed Text2SQL checks, adaptive reranking, saved evaluation history and incremental Deep reuse remain unchanged.
28
 
29
  ## What is new in v1.5
30
 
 
10
 
11
  # RAGForge
12
 
13
+ **RAGForge v1.5.2 - a production-style, portfolio-ready agentic RAG system for Hugging Face Spaces.**
14
 
15
  RAGForge combines hybrid document retrieval, source-level/hierarchical retrieval, semantic query planning, corrective RAG, Self-RAG-style verification, Text2SQL and an “Ask-the-Web” research path in one CPU-friendly application. The default LLM is **Google Gemini 3.5 Flash-Lite**; the UI also exposes Gemini 3.1 Flash-Lite and stronger Flash models.
16
 
17
 
18
+ ## What is new in v1.5.2
19
 
20
+ v1.5.2 is a narrow runtime hotfix over v1.5.1. It does not change retrieval, evaluation semantics, dependency pins or the demo benchmark.
21
 
22
+ - **Quick/Standard/Deep evaluation crash fixed** - `pipeline.py` now explicitly imports the citation normalization and repair helpers introduced in v1.5.1. This fixes `NameError: name 'repair_missing_citations' is not defined` during generated-answer evaluation.
23
+ - **Packaging regression coverage** - a dependency-free test now verifies the citation helpers are imported into the pipeline namespace, and the LangGraph-backed helper test invokes the repair path directly when optional runtime dependencies are available.
24
+ - **v1.5.1 behavior retained** - saved-report JSON, table export, grouped-citation parsing and conservative citation repair are unchanged.
25
+ - **Benchmark compatibility retained** - the benchmark remains `1.5.1` because this hotfix changes runtime wiring only, not benchmark questions or scoring semantics.
 
 
26
 
27
  ## What is new in v1.5
28
 
docs/MIGRATION_1.5.2.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Migration to RAGForge v1.5.2
2
+
3
+ v1.5.2 is a narrow hotfix over v1.5.1.
4
+
5
+ ## Fixed
6
+
7
+ Quick, Standard and Deep evaluation could fail while processing generated answers with:
8
+
9
+ ```text
10
+ NameError: name 'repair_missing_citations' is not defined
11
+ ```
12
+
13
+ `src/ragforge/pipeline.py` called citation helpers moved into `src/ragforge/citations.py`, but the v1.5.1 package omitted the explicit module import. v1.5.2 restores:
14
+
15
+ ```python
16
+ from .citations import normalize_citation_syntax, repair_missing_citations
17
+ ```
18
+
19
+ ## Compatibility
20
+
21
+ - No dependency changes.
22
+ - No corpus/index format changes.
23
+ - No retrieval-policy changes.
24
+ - No evaluation-scoring changes.
25
+ - The demo benchmark remains version `1.5.1`, so saved reports are semantically compatible while the same server-side workspace exists.
26
+
27
+ ## Regression coverage
28
+
29
+ The test suite now checks the import wiring without optional dependencies and invokes the citation-repair pipeline helper when LangGraph is available.
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
 
5
  [project]
6
  name = "ragforge"
7
- version = "1.5.1"
8
  description = "Production-style agentic RAG demo for Hugging Face Spaces"
9
  requires-python = ">=3.11"
10
  dependencies = []
 
4
 
5
  [project]
6
  name = "ragforge"
7
+ version = "1.5.2"
8
  description = "Production-style agentic RAG demo for Hugging Face Spaces"
9
  requires-python = ">=3.11"
10
  dependencies = []
src/ragforge/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
  """RAGForge: production-style agentic retrieval augmented generation demo."""
2
 
3
- __version__ = "1.5.1"
 
1
  """RAGForge: production-style agentic retrieval augmented generation demo."""
2
 
3
+ __version__ = "1.5.2"
src/ragforge/api.py CHANGED
@@ -29,7 +29,7 @@ def _auth(authorization: Annotated[str | None, Header()] = None) -> None:
29
 
30
 
31
  def create_api() -> FastAPI:
32
- app = FastAPI(title="RAGForge API", version="1.5.1")
33
 
34
  @app.get("/api/health")
35
  def health():
 
29
 
30
 
31
  def create_api() -> FastAPI:
32
+ app = FastAPI(title="RAGForge API", version="1.5.2")
33
 
34
  @app.get("/api/health")
35
  def health():
src/ragforge/pipeline.py CHANGED
@@ -11,6 +11,7 @@ from typing import Any, Callable, TypedDict
11
  from cachetools import TTLCache
12
  from langgraph.graph import END, START, StateGraph
13
 
 
14
  from .config import get_settings
15
  from .llm import GeminiGateway, RequestPacer
16
  from .schemas import EvidenceAssessment, PipelineConfig, QueryPlan, QueryResponse, SearchHit
 
11
  from cachetools import TTLCache
12
  from langgraph.graph import END, START, StateGraph
13
 
14
+ from .citations import normalize_citation_syntax, repair_missing_citations
15
  from .config import get_settings
16
  from .llm import GeminiGateway, RequestPacer
17
  from .schemas import EvidenceAssessment, PipelineConfig, QueryPlan, QueryResponse, SearchHit
src/ragforge/ui.py CHANGED
@@ -243,7 +243,7 @@ def _architecture_snapshot(session_id: str | None) -> tuple[str, str, str, dict[
243
  settings = get_settings()
244
  stats = ws.stats()
245
  runtime_json = {
246
- "ragforge_version": "1.5.1",
247
  "workspace": stats,
248
  "models": {
249
  "generation": settings.default_model,
@@ -264,7 +264,7 @@ def _architecture_snapshot(session_id: str | None) -> tuple[str, str, str, dict[
264
  }
265
  runtime = (
266
  "### Live runtime\n"
267
- f"**RAGForge:** `v1.5.1` - **workspace:** `{sid[:12]}...` - **status:** `{stats['status']}`\n\n"
268
  f"**Corpus:** `{stats['sources']}` sources - `{stats['chunks']}` chunks - "
269
  f"`{stats['source_profiles']}` source profiles - `{stats['tables']}` tables - "
270
  f"corpus version `{stats['version']}`\n\n"
 
243
  settings = get_settings()
244
  stats = ws.stats()
245
  runtime_json = {
246
+ "ragforge_version": "1.5.2",
247
  "workspace": stats,
248
  "models": {
249
  "generation": settings.default_model,
 
264
  }
265
  runtime = (
266
  "### Live runtime\n"
267
+ f"**RAGForge:** `v1.5.2` - **workspace:** `{sid[:12]}...` - **status:** `{stats['status']}`\n\n"
268
  f"**Corpus:** `{stats['sources']}` sources - `{stats['chunks']}` chunks - "
269
  f"`{stats['source_profiles']}` source profiles - `{stats['tables']}` tables - "
270
  f"corpus version `{stats['version']}`\n\n"
tests/test_evaluation_assets.py CHANGED
@@ -49,7 +49,7 @@ def test_demo_evaluation_and_introspection_are_available_through_api():
49
  assert "/api/v1/session/{session_id}" in text
50
  assert "/api/v1/evaluation/saved/{session_id}" in text
51
  assert "/api/v1/evaluation/saved/{session_id}/{level}" in text
52
- assert 'version="1.5.1"' in text
53
 
54
 
55
  def test_v15_evaluation_cache_and_incremental_deep_are_present():
@@ -110,3 +110,9 @@ def test_v151_citation_repair_skips_preamble_colons_and_normalizes_groups():
110
  assert "_normalize_citation_syntax" in pipeline_text
111
  assert 'stripped.endswith(":")' in citation_text
112
  assert "group_re" in citation_text
 
 
 
 
 
 
 
49
  assert "/api/v1/session/{session_id}" in text
50
  assert "/api/v1/evaluation/saved/{session_id}" in text
51
  assert "/api/v1/evaluation/saved/{session_id}/{level}" in text
52
+ assert 'version="1.5.2"' in text
53
 
54
 
55
  def test_v15_evaluation_cache_and_incremental_deep_are_present():
 
110
  assert "_normalize_citation_syntax" in pipeline_text
111
  assert 'stripped.endswith(":")' in citation_text
112
  assert "group_re" in citation_text
113
+
114
+
115
+ def test_v152_pipeline_imports_citation_helpers_into_runtime_namespace():
116
+ text = Path("src/ragforge/pipeline.py").read_text(encoding="utf-8")
117
+ assert "from .citations import normalize_citation_syntax, repair_missing_citations" in text
118
+ assert "return repair_missing_citations(answer, sources)" in text
tests/test_pipeline_helpers.py CHANGED
@@ -17,3 +17,19 @@ def test_evidence_strength_does_not_treat_rrf_rank_as_calibrated_relevance():
17
  # A top RRF result may have score=1.0 purely because it ranked first.
18
  weak = SearchHit(Chunk("1", "unrelated", "file.md"), score=1.0, dense_score=0.08, sparse_score=0.0)
19
  assert RAGEngine._evidence_strength([weak], []) < 0.30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # A top RRF result may have score=1.0 purely because it ranked first.
18
  weak = SearchHit(Chunk("1", "unrelated", "file.md"), score=1.0, dense_score=0.08, sparse_score=0.0)
19
  assert RAGEngine._evidence_strength([weak], []) < 0.30
20
+
21
+
22
+ def test_pipeline_citation_repair_helper_is_runtime_bound():
23
+ sources = [
24
+ {
25
+ "id": "D1",
26
+ "title": "policy.txt",
27
+ "snippet": "Refunds usually appear within 5 to 10 business days after confirmation.",
28
+ }
29
+ ]
30
+ repaired, count = RAGEngine._repair_missing_citations(
31
+ "Refunds usually appear within 5 to 10 business days after confirmation.",
32
+ sources,
33
+ )
34
+ assert count >= 1
35
+ assert "[D1]" in repaired
tests/test_ui_copy.py CHANGED
@@ -54,7 +54,7 @@ def test_ui_has_quota_safe_evaluation_controls_and_score_card_spacing():
54
 
55
  def test_architecture_snapshot_returns_complete_runtime_payload():
56
  text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
57
- assert '"ragforge_version": "1.5.1"' in text
58
  assert "return sid, runtime, curl, runtime_json" in text
59
  assert "curl = f\ndef _eval_frame" not in text
60
 
 
54
 
55
  def test_architecture_snapshot_returns_complete_runtime_payload():
56
  text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
57
+ assert '"ragforge_version": "1.5.2"' in text
58
  assert "return sid, runtime, curl, runtime_json" in text
59
  assert "curl = f\ndef _eval_frame" not in text
60