scdl-rag 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: scdl-rag
3
+ Version: 1.0.0
4
+ Summary: SCDL-RAG: Detect and fix RAG hallucinations with 97% recall and 100% precision.
5
+ Author: SCDL-RAG Team
6
+ Classifier: Development Status :: 5 - Production/Stable
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.28.0
14
+ Dynamic: author
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: requires-dist
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # SCDL-RAG Python SDK
23
+ Detect and fix RAG hallucinations.
24
+
25
+ ## Install
26
+ ```bash
27
+ pip install scdl-rag
28
+ ```
29
+
30
+ ## Usage
31
+ ```python
32
+ from scdl_rag import Client
33
+
34
+ client = Client(api_key="sk_live_...")
35
+
36
+ result = client.detect(
37
+ question="What is RL?",
38
+ answer="nodes called neurons",
39
+ documents=[{"id": "doc1", "content": "RL is about..."}],
40
+ )
41
+
42
+ if result.hallucination_detected:
43
+ print(f"Hallucination found: {result.explanation}")
44
+ else:
45
+ print(f"Coherent (score: {result.mu_score})")
46
+ ```
47
+
48
+ ## API
49
+ See https://api.scdl-rag.com/docs for full API reference.
@@ -0,0 +1,28 @@
1
+ # SCDL-RAG Python SDK
2
+ Detect and fix RAG hallucinations.
3
+
4
+ ## Install
5
+ ```bash
6
+ pip install scdl-rag
7
+ ```
8
+
9
+ ## Usage
10
+ ```python
11
+ from scdl_rag import Client
12
+
13
+ client = Client(api_key="sk_live_...")
14
+
15
+ result = client.detect(
16
+ question="What is RL?",
17
+ answer="nodes called neurons",
18
+ documents=[{"id": "doc1", "content": "RL is about..."}],
19
+ )
20
+
21
+ if result.hallucination_detected:
22
+ print(f"Hallucination found: {result.explanation}")
23
+ else:
24
+ print(f"Coherent (score: {result.mu_score})")
25
+ ```
26
+
27
+ ## API
28
+ See https://api.scdl-rag.com/docs for full API reference.
@@ -0,0 +1,124 @@
1
+ """
2
+ SCDL-RAG Python SDK — Enterprise hallucination detection client.
3
+ """
4
+ from typing import List, Optional, Dict, Any
5
+ import requests as _req
6
+
7
+
8
+ class Document:
9
+ def __init__(self, id: str, content: str, title: str = ""):
10
+ self.id = id
11
+ self.content = content
12
+ self.title = title
13
+
14
+ def to_dict(self):
15
+ return {"id": self.id, "content": self.content, "title": self.title}
16
+
17
+
18
+ class DetectResult:
19
+ def __init__(self, data: dict):
20
+ self.request_id = data.get("request_id")
21
+ self.hallucination_detected = data.get("hallucination_detected", False)
22
+ self.mu_score = data.get("mu_score", 0.0)
23
+ self.status = data.get("status", "unknown")
24
+ self.signals = data.get("signals", {})
25
+ self.explanation = data.get("explanation", "")
26
+ self.processing_time_ms = data.get("processing_time_ms", 0)
27
+
28
+
29
+ class DetectAndFixResult:
30
+ def __init__(self, data: dict):
31
+ self.request_id = data.get("request_id")
32
+ self.hallucination_detected = data.get("hallucination_detected", False)
33
+ self.mu_score_initial = data.get("mu_score_initial", 0.0)
34
+ self.status_initial = data.get("status_initial", "unknown")
35
+ self.problem_detected = data.get("problem_detected", {})
36
+ self.fix_attempted = data.get("fix_attempted", False)
37
+ self.fix_success = data.get("fix_success", False)
38
+ self.mu_score_after_fix = data.get("mu_score_after_fix", None)
39
+ self.status_after_fix = data.get("status_after_fix", None)
40
+ self.improved_answer = data.get("improved_answer", "")
41
+ self.evidence_source = data.get("evidence_source", "")
42
+ self.evidence_snippet = data.get("evidence_snippet", "")
43
+ self.confidence = data.get("confidence", 0.0)
44
+ self.processing_time_ms = data.get("processing_time_ms", 0)
45
+
46
+
47
+ class BatchResult:
48
+ def __init__(self, data: dict):
49
+ self.batch_id = data.get("batch_id")
50
+ self.total_cases = data.get("total_cases", 0)
51
+ self.processed = data.get("processed", 0)
52
+ self.results = data.get("results", [])
53
+ self.summary = data.get("summary", {})
54
+ self.processing_time_ms = data.get("processing_time_ms", 0)
55
+
56
+
57
+ class Client:
58
+ """SCDL-RAG API client.
59
+
60
+ Usage:
61
+ client = Client(api_key="sk_live_...")
62
+ result = client.detect(question="...", answer="...", documents=[...])
63
+ if result.hallucination_detected:
64
+ print(result.explanation)
65
+ """
66
+
67
+ def __init__(self, api_key: str, base_url: str = "https://api.scdl-rag.com"):
68
+ self.api_key = api_key
69
+ self.base_url = base_url.rstrip("/")
70
+ self._headers = {
71
+ "Authorization": f"Bearer {api_key}",
72
+ "Content-Type": "application/json",
73
+ }
74
+
75
+ def detect(self, question: str, answer: str, documents: List[Dict],
76
+ model: str = "gpt-4") -> DetectResult:
77
+ """Detect hallucination in a RAG answer."""
78
+ resp = _req.post(f"{self.base_url}/v1/detect",
79
+ headers=self._headers,
80
+ json={
81
+ "question": question,
82
+ "answer": answer,
83
+ "documents": [{"id": d["id"], "content": d["content"], "title": d.get("title", "")}
84
+ for d in documents],
85
+ "model": model,
86
+ }, timeout=30)
87
+ resp.raise_for_status()
88
+ return DetectResult(resp.json())
89
+
90
+ def detect_and_fix(self, question: str, answer: str, documents: List[Dict],
91
+ document_pool: List[Dict] = None, auto_fix: bool = True) -> DetectAndFixResult:
92
+ """Detect hallucination and attempt auto-fix via improved retrieval."""
93
+ resp = _req.post(f"{self.base_url}/v1/detect-and-fix",
94
+ headers=self._headers,
95
+ json={
96
+ "question": question,
97
+ "answer": answer,
98
+ "documents": [{"id": d["id"], "content": d["content"], "title": d.get("title", "")}
99
+ for d in documents],
100
+ "document_pool": [{"id": d["id"], "content": d["content"], "title": d.get("title", "")}
101
+ for d in (document_pool or [])],
102
+ "auto_fix": auto_fix,
103
+ }, timeout=60)
104
+ resp.raise_for_status()
105
+ return DetectAndFixResult(resp.json())
106
+
107
+ def batch_detect_and_fix(self, cases: List[Dict], auto_fix: bool = True,
108
+ batch_id: str = None) -> BatchResult:
109
+ """Batch detect and fix hallucinations."""
110
+ resp = _req.post(f"{self.base_url}/v1/batch/detect-and-fix",
111
+ headers=self._headers,
112
+ json={
113
+ "batch_id": batch_id,
114
+ "cases": [{
115
+ "id": c["id"],
116
+ "question": c["question"],
117
+ "answer": c["answer"],
118
+ "documents": [{"id": d["id"], "content": d["content"], "title": d.get("title", "")}
119
+ for d in c.get("documents", [])],
120
+ } for c in cases],
121
+ "auto_fix": auto_fix,
122
+ }, timeout=120)
123
+ resp.raise_for_status()
124
+ return BatchResult(resp.json())
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: scdl-rag
3
+ Version: 1.0.0
4
+ Summary: SCDL-RAG: Detect and fix RAG hallucinations with 97% recall and 100% precision.
5
+ Author: SCDL-RAG Team
6
+ Classifier: Development Status :: 5 - Production/Stable
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.28.0
14
+ Dynamic: author
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: requires-dist
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # SCDL-RAG Python SDK
23
+ Detect and fix RAG hallucinations.
24
+
25
+ ## Install
26
+ ```bash
27
+ pip install scdl-rag
28
+ ```
29
+
30
+ ## Usage
31
+ ```python
32
+ from scdl_rag import Client
33
+
34
+ client = Client(api_key="sk_live_...")
35
+
36
+ result = client.detect(
37
+ question="What is RL?",
38
+ answer="nodes called neurons",
39
+ documents=[{"id": "doc1", "content": "RL is about..."}],
40
+ )
41
+
42
+ if result.hallucination_detected:
43
+ print(f"Hallucination found: {result.explanation}")
44
+ else:
45
+ print(f"Coherent (score: {result.mu_score})")
46
+ ```
47
+
48
+ ## API
49
+ See https://api.scdl-rag.com/docs for full API reference.
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ scdl_rag/__init__.py
4
+ scdl_rag.egg-info/PKG-INFO
5
+ scdl_rag.egg-info/SOURCES.txt
6
+ scdl_rag.egg-info/dependency_links.txt
7
+ scdl_rag.egg-info/requires.txt
8
+ scdl_rag.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1 @@
1
+ scdl_rag
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="scdl-rag",
5
+ version="1.0.0",
6
+ description="SCDL-RAG: Detect and fix RAG hallucinations with 97% recall and 100% precision.",
7
+ long_description=open("README.md").read() if __import__("os").path.exists("README.md") else "",
8
+ long_description_content_type="text/markdown",
9
+ author="SCDL-RAG Team",
10
+ packages=find_packages(),
11
+ install_requires=["requests>=2.28.0"],
12
+ python_requires=">=3.8",
13
+ classifiers=[
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ ],
20
+ )