ragaeval 0.1.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.
ragaeval-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ragaeval contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ include setup.py
5
+ recursive-include ragaeval *.py
6
+ global-exclude __pycache__
7
+ global-exclude *.py[co]
8
+ global-exclude .DS_Store
@@ -0,0 +1,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: ragaeval
3
+ Version: 0.1.0
4
+ Summary: A pip-installable Python library providing drop-in RAG evaluation capabilities using RAGAS
5
+ Home-page: https://github.com/Vamsi1113/ragaeval
6
+ Author: Vamsi Kasireddy
7
+ Author-email: Vamsi Kasireddy <vamsikasireddy@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/Vamsi1113/ragaeval
10
+ Project-URL: Bug Reports, https://github.com/Vamsi1113/ragaeval/issues
11
+ Project-URL: Source, https://github.com/Vamsi1113/ragaeval
12
+ Keywords: rag,evaluation,ragas,llm,ai,azure,openai
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: ragas==0.2.15
27
+ Requires-Dist: langchain-openai==0.1.23
28
+ Requires-Dist: langchain-core==0.2.40
29
+ Requires-Dist: sentence-transformers==3.3.1
30
+ Requires-Dist: python-dotenv
31
+ Requires-Dist: pandas
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
35
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
36
+ Requires-Dist: hypothesis>=6.0.0; extra == "dev"
37
+ Dynamic: author
38
+ Dynamic: home-page
39
+ Dynamic: license-file
40
+ Dynamic: requires-python
41
+
42
+ # ragaeval
43
+
44
+ A pip-installable Python library providing drop-in RAG (Retrieval-Augmented Generation) evaluation capabilities using the RAGAS framework (version 0.2.15).
45
+
46
+ ## Features
47
+
48
+ - **Three Integration Patterns**: Choose from decorator, context manager, or manual logging
49
+ - **Secure Credential Management**: Multiple sources with precedence (args > env vars > .env > config file)
50
+ - **Cross-Platform**: Works on Windows, Mac, and Linux
51
+ - **Automatic Field Normalization**: Supports common field name aliases
52
+ - **CLI Tools**: Configuration, execution, and status commands
53
+ - **Rich Reports**: Terminal output with visual indicators and CSV export
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install ragaeval
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ ### 1. Configure API Credentials
64
+
65
+ Run the interactive configuration wizard:
66
+
67
+ ```bash
68
+ ragaeval configure
69
+ ```
70
+
71
+ Or set environment variables:
72
+
73
+ ```bash
74
+ export AZURE_OPENAI_API_KEY="your-api-key"
75
+ export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
76
+ export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o"
77
+ export AZURE_OPENAI_API_VERSION="2024-02-15-preview"
78
+ ```
79
+
80
+ ### 2. Log Evaluation Data
81
+
82
+ #### Option A: Decorator Pattern
83
+
84
+ ```python
85
+ from ragaeval import evaluate_rag
86
+
87
+ @evaluate_rag
88
+ def my_rag_pipeline(query: str, contexts: list) -> str:
89
+ # Your RAG logic here
90
+ response = generate_answer(query, contexts)
91
+ return response
92
+
93
+ # Use your function normally - data is captured automatically
94
+ result = my_rag_pipeline(
95
+ query="What is the refund policy?",
96
+ contexts=["Returns accepted within 30 days", "Refunds processed in 5-7 days"]
97
+ )
98
+ ```
99
+
100
+ #### Option B: Context Manager Pattern
101
+
102
+ ```python
103
+ from ragaeval import EvalSession
104
+
105
+ with EvalSession() as session:
106
+ query = "What is the refund policy?"
107
+ contexts = retrieve_documents(query)
108
+ response = generate_answer(query, contexts)
109
+
110
+ session.log(query=query, contexts=contexts, response=response)
111
+ ```
112
+
113
+ #### Option C: Manual Logging
114
+
115
+ ```python
116
+ import ragaeval
117
+
118
+ query = "What is the refund policy?"
119
+ contexts = retrieve_documents(query)
120
+ response = generate_answer(query, contexts)
121
+
122
+ ragaeval.log(query=query, contexts=contexts, response=response)
123
+ ```
124
+
125
+ ### 3. Run Evaluation
126
+
127
+ ```bash
128
+ ragaeval run
129
+ ```
130
+
131
+ This will:
132
+ - Read logged data from `.ragaeval_log.jsonl`
133
+ - Execute RAGAS evaluation using Azure OpenAI
134
+ - Display results in terminal with visual indicators
135
+ - Export results to `eval_results.csv`
136
+
137
+ ## CLI Commands
138
+
139
+ ### `ragaeval run`
140
+
141
+ Execute evaluation on logged data.
142
+
143
+ ```bash
144
+ ragaeval run # Use defaults
145
+ ragaeval run --model gpt-4o # Specify Azure deployment
146
+ ragaeval run --output results.csv # Custom output path
147
+ ```
148
+
149
+ ### `ragaeval configure`
150
+
151
+ Interactive credential setup.
152
+
153
+ ```bash
154
+ ragaeval configure
155
+ ```
156
+
157
+ ### `ragaeval status`
158
+
159
+ Display configuration and log status.
160
+
161
+ ```bash
162
+ ragaeval status
163
+ ```
164
+
165
+ ### `ragaeval clear`
166
+
167
+ Clear evaluation logs.
168
+
169
+ ```bash
170
+ ragaeval clear # Prompts for confirmation
171
+ ragaeval clear --force # Skip confirmation
172
+ ```
173
+
174
+ ### `ragaeval --version`
175
+
176
+ Display package version.
177
+
178
+ ```bash
179
+ ragaeval --version
180
+ ```
181
+
182
+ ## Field Name Aliases
183
+
184
+ The package supports common field name variations:
185
+
186
+ - **Query**: `query`, `question`, `input`, `user_input`
187
+ - **Response**: `response`, `answer`, `llm_response`, `output`, `actual_output`
188
+ - **Contexts**: `contexts`, `context`, `retrieved_contexts`, `source_documents`
189
+ - **Reference**: `reference`, `ground_truth`, `expected`
190
+
191
+ ## Evaluation Metrics
192
+
193
+ ### Always Evaluated (Group A)
194
+ - **Faithfulness**: Response consistency with retrieved contexts
195
+ - **Response Relevancy**: Relevance of response to query
196
+ - **Aspect Critic**: Harmfulness detection
197
+
198
+ ### Evaluated When Reference Available (Group B)
199
+ - **Factual Correctness**: Accuracy against ground truth
200
+ - **Semantic Similarity**: Semantic closeness to reference
201
+ - **BLEU Score**: N-gram overlap
202
+ - **ROUGE Score**: Recall-oriented overlap
203
+ - **String Presence**: Exact string matching
204
+ - **Exact Match**: Perfect match detection
205
+
206
+ ## Configuration Sources
207
+
208
+ Credentials are resolved in this order (highest to lowest precedence):
209
+
210
+ 1. **Explicit function arguments**
211
+ 2. **Environment variables** (`AZURE_OPENAI_API_KEY`, etc.)
212
+ 3. **`.env` file** in current directory
213
+ 4. **Config file** at `~/.ragaeval/config.json`
214
+
215
+ ## Cross-Platform Notes
216
+
217
+ - Config file location: `~/.ragaeval/config.json` (user home directory)
218
+ - Log file location: `.ragaeval_log.jsonl` (current working directory)
219
+ - File permissions: Config file is created with user-only access (0o600)
220
+
221
+ ## Requirements
222
+
223
+ - Python >= 3.8
224
+ - Azure OpenAI API access (for LLM evaluation)
225
+ - Optional: OpenAI API key (for embeddings, otherwise uses local models)
226
+
227
+ ## Development
228
+
229
+ ### Install in Development Mode
230
+
231
+ ```bash
232
+ pip install -e .[dev]
233
+ ```
234
+
235
+ ### Run Tests
236
+
237
+ ```bash
238
+ pytest
239
+ pytest --cov=ragaeval # With coverage
240
+ ```
241
+
242
+ ## License
243
+
244
+ MIT License - see LICENSE file for details.
245
+
246
+ ## Version
247
+
248
+ Current version: 0.1.0
249
+
250
+ Check installed version:
251
+
252
+ ```python
253
+ import ragaeval
254
+ print(ragaeval.__version__)
255
+ ```
256
+
257
+ Or via CLI:
258
+
259
+ ```bash
260
+ ragaeval --version
261
+ ```
262
+
263
+ ## Support
264
+
265
+ For issues and questions, please file an issue on the GitHub repository.
@@ -0,0 +1,224 @@
1
+ # ragaeval
2
+
3
+ A pip-installable Python library providing drop-in RAG (Retrieval-Augmented Generation) evaluation capabilities using the RAGAS framework (version 0.2.15).
4
+
5
+ ## Features
6
+
7
+ - **Three Integration Patterns**: Choose from decorator, context manager, or manual logging
8
+ - **Secure Credential Management**: Multiple sources with precedence (args > env vars > .env > config file)
9
+ - **Cross-Platform**: Works on Windows, Mac, and Linux
10
+ - **Automatic Field Normalization**: Supports common field name aliases
11
+ - **CLI Tools**: Configuration, execution, and status commands
12
+ - **Rich Reports**: Terminal output with visual indicators and CSV export
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install ragaeval
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Configure API Credentials
23
+
24
+ Run the interactive configuration wizard:
25
+
26
+ ```bash
27
+ ragaeval configure
28
+ ```
29
+
30
+ Or set environment variables:
31
+
32
+ ```bash
33
+ export AZURE_OPENAI_API_KEY="your-api-key"
34
+ export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
35
+ export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o"
36
+ export AZURE_OPENAI_API_VERSION="2024-02-15-preview"
37
+ ```
38
+
39
+ ### 2. Log Evaluation Data
40
+
41
+ #### Option A: Decorator Pattern
42
+
43
+ ```python
44
+ from ragaeval import evaluate_rag
45
+
46
+ @evaluate_rag
47
+ def my_rag_pipeline(query: str, contexts: list) -> str:
48
+ # Your RAG logic here
49
+ response = generate_answer(query, contexts)
50
+ return response
51
+
52
+ # Use your function normally - data is captured automatically
53
+ result = my_rag_pipeline(
54
+ query="What is the refund policy?",
55
+ contexts=["Returns accepted within 30 days", "Refunds processed in 5-7 days"]
56
+ )
57
+ ```
58
+
59
+ #### Option B: Context Manager Pattern
60
+
61
+ ```python
62
+ from ragaeval import EvalSession
63
+
64
+ with EvalSession() as session:
65
+ query = "What is the refund policy?"
66
+ contexts = retrieve_documents(query)
67
+ response = generate_answer(query, contexts)
68
+
69
+ session.log(query=query, contexts=contexts, response=response)
70
+ ```
71
+
72
+ #### Option C: Manual Logging
73
+
74
+ ```python
75
+ import ragaeval
76
+
77
+ query = "What is the refund policy?"
78
+ contexts = retrieve_documents(query)
79
+ response = generate_answer(query, contexts)
80
+
81
+ ragaeval.log(query=query, contexts=contexts, response=response)
82
+ ```
83
+
84
+ ### 3. Run Evaluation
85
+
86
+ ```bash
87
+ ragaeval run
88
+ ```
89
+
90
+ This will:
91
+ - Read logged data from `.ragaeval_log.jsonl`
92
+ - Execute RAGAS evaluation using Azure OpenAI
93
+ - Display results in terminal with visual indicators
94
+ - Export results to `eval_results.csv`
95
+
96
+ ## CLI Commands
97
+
98
+ ### `ragaeval run`
99
+
100
+ Execute evaluation on logged data.
101
+
102
+ ```bash
103
+ ragaeval run # Use defaults
104
+ ragaeval run --model gpt-4o # Specify Azure deployment
105
+ ragaeval run --output results.csv # Custom output path
106
+ ```
107
+
108
+ ### `ragaeval configure`
109
+
110
+ Interactive credential setup.
111
+
112
+ ```bash
113
+ ragaeval configure
114
+ ```
115
+
116
+ ### `ragaeval status`
117
+
118
+ Display configuration and log status.
119
+
120
+ ```bash
121
+ ragaeval status
122
+ ```
123
+
124
+ ### `ragaeval clear`
125
+
126
+ Clear evaluation logs.
127
+
128
+ ```bash
129
+ ragaeval clear # Prompts for confirmation
130
+ ragaeval clear --force # Skip confirmation
131
+ ```
132
+
133
+ ### `ragaeval --version`
134
+
135
+ Display package version.
136
+
137
+ ```bash
138
+ ragaeval --version
139
+ ```
140
+
141
+ ## Field Name Aliases
142
+
143
+ The package supports common field name variations:
144
+
145
+ - **Query**: `query`, `question`, `input`, `user_input`
146
+ - **Response**: `response`, `answer`, `llm_response`, `output`, `actual_output`
147
+ - **Contexts**: `contexts`, `context`, `retrieved_contexts`, `source_documents`
148
+ - **Reference**: `reference`, `ground_truth`, `expected`
149
+
150
+ ## Evaluation Metrics
151
+
152
+ ### Always Evaluated (Group A)
153
+ - **Faithfulness**: Response consistency with retrieved contexts
154
+ - **Response Relevancy**: Relevance of response to query
155
+ - **Aspect Critic**: Harmfulness detection
156
+
157
+ ### Evaluated When Reference Available (Group B)
158
+ - **Factual Correctness**: Accuracy against ground truth
159
+ - **Semantic Similarity**: Semantic closeness to reference
160
+ - **BLEU Score**: N-gram overlap
161
+ - **ROUGE Score**: Recall-oriented overlap
162
+ - **String Presence**: Exact string matching
163
+ - **Exact Match**: Perfect match detection
164
+
165
+ ## Configuration Sources
166
+
167
+ Credentials are resolved in this order (highest to lowest precedence):
168
+
169
+ 1. **Explicit function arguments**
170
+ 2. **Environment variables** (`AZURE_OPENAI_API_KEY`, etc.)
171
+ 3. **`.env` file** in current directory
172
+ 4. **Config file** at `~/.ragaeval/config.json`
173
+
174
+ ## Cross-Platform Notes
175
+
176
+ - Config file location: `~/.ragaeval/config.json` (user home directory)
177
+ - Log file location: `.ragaeval_log.jsonl` (current working directory)
178
+ - File permissions: Config file is created with user-only access (0o600)
179
+
180
+ ## Requirements
181
+
182
+ - Python >= 3.8
183
+ - Azure OpenAI API access (for LLM evaluation)
184
+ - Optional: OpenAI API key (for embeddings, otherwise uses local models)
185
+
186
+ ## Development
187
+
188
+ ### Install in Development Mode
189
+
190
+ ```bash
191
+ pip install -e .[dev]
192
+ ```
193
+
194
+ ### Run Tests
195
+
196
+ ```bash
197
+ pytest
198
+ pytest --cov=ragaeval # With coverage
199
+ ```
200
+
201
+ ## License
202
+
203
+ MIT License - see LICENSE file for details.
204
+
205
+ ## Version
206
+
207
+ Current version: 0.1.0
208
+
209
+ Check installed version:
210
+
211
+ ```python
212
+ import ragaeval
213
+ print(ragaeval.__version__)
214
+ ```
215
+
216
+ Or via CLI:
217
+
218
+ ```bash
219
+ ragaeval --version
220
+ ```
221
+
222
+ ## Support
223
+
224
+ For issues and questions, please file an issue on the GitHub repository.
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ragaeval"
7
+ version = "0.1.0"
8
+ description = "A pip-installable Python library providing drop-in RAG evaluation capabilities using RAGAS"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Vamsi Kasireddy", email = "vamsikasireddy@example.com"}
14
+ ]
15
+ keywords = ["rag", "evaluation", "ragas", "llm", "ai", "azure", "openai"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
27
+ ]
28
+ dependencies = [
29
+ "ragas==0.2.15",
30
+ "langchain-openai==0.1.23",
31
+ "langchain-core==0.2.40",
32
+ "sentence-transformers==3.3.1",
33
+ "python-dotenv",
34
+ "pandas",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=7.0.0",
40
+ "pytest-cov>=4.0.0",
41
+ "pytest-mock>=3.10.0",
42
+ "hypothesis>=6.0.0",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/Vamsi1113/ragaeval"
47
+ "Bug Reports" = "https://github.com/Vamsi1113/ragaeval/issues"
48
+ Source = "https://github.com/Vamsi1113/ragaeval"
49
+
50
+ [project.scripts]
51
+ ragaeval = "ragaeval.cli:main"
52
+
53
+ [tool.setuptools.packages.find]
54
+ exclude = ["tests*", "venv*", "dist*", "build*", "*.egg-info*"]
55
+ include = ["ragaeval*"]
@@ -0,0 +1,34 @@
1
+ """
2
+ ragaeval - RAG Evaluation Package
3
+
4
+ A pip-installable Python library providing drop-in RAG evaluation capabilities using RAGAS.
5
+ """
6
+
7
+ import sys
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ # Setup VertexAI mock before other imports
12
+ from .mock_setup import setup_vertexai_mock
13
+ setup_vertexai_mock()
14
+
15
+ # Set UTF-8 encoding on Windows
16
+ if sys.platform == 'win32':
17
+ try:
18
+ sys.stdout.reconfigure(encoding='utf-8')
19
+ sys.stderr.reconfigure(encoding='utf-8')
20
+ except Exception:
21
+ pass
22
+
23
+ # Import public API components
24
+ from .interceptors import evaluate_rag, EvalSession, log
25
+ from .config import ConfigManager
26
+
27
+ # Public API exports
28
+ __all__ = [
29
+ "__version__",
30
+ "evaluate_rag",
31
+ "EvalSession",
32
+ "log",
33
+ "ConfigManager",
34
+ ]