ragas-examples 0.4.0__tar.gz → 0.4.2__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.
- {ragas_examples-0.4.0/ragas_examples.egg-info → ragas_examples-0.4.2}/PKG-INFO +1 -1
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/_version.py +3 -3
- ragas_examples-0.4.2/ragas_examples/ag_ui_agent_experiments/README.md +339 -0
- ragas_examples-0.4.2/ragas_examples/ag_ui_agent_experiments/__init__.py +54 -0
- ragas_examples-0.4.2/ragas_examples/ag_ui_agent_experiments/experiments.py +398 -0
- ragas_examples-0.4.2/ragas_examples/ag_ui_agent_experiments/test_data/datasets/scientist_biographies.csv +6 -0
- ragas_examples-0.4.2/ragas_examples/ag_ui_agent_experiments/test_data/datasets/weather_tool_calls.csv +6 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/improve_rag/evals.py +17 -14
- ragas_examples-0.4.2/ragas_examples/improve_rag/pyproject.toml +34 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/improve_rag/rag.py +37 -16
- {ragas_examples-0.4.0 → ragas_examples-0.4.2/ragas_examples.egg-info}/PKG-INFO +1 -1
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples.egg-info/SOURCES.txt +12 -2
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/LICENSE +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/README.md +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/gdrive_append_example.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/gdrive_backend_example.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/datasets/support_triage.csv +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/promptv1.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/promptv2_fewshot.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/iterate_prompt/run_prompt.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/oci_genai_example.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/pyproject.toml +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/agent_evals/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/agent_evals/agent.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/agent_evals/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/benchmark_llm/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/benchmark_llm/datasets/discount_benchmark.csv +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/benchmark_llm/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/benchmark_llm/prompt.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/improve_rag/__init__.py +0 -0
- {ragas_examples-0.4.0/ragas_examples/improve_rag → ragas_examples-0.4.2/ragas_examples/improve_rag/evals}/datasets/hf_doc_qa_eval.csv +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/judge_alignment/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/judge_alignment/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/contexts/ambiguous_removal_request.json +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/contexts/duplicate_addition.json +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/contexts/repeated_removal.json +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/llamaIndex_agent_evals/llamaindex_agent.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/prompt_evals/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/prompt_evals/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/prompt_evals/prompt.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/rag_eval/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/rag_eval/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/rag_eval/pyproject.toml +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/rag_eval/rag.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/analyze_errors.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/data_utils.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/datasets/booksql_sample.csv +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/db_utils.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/prompt.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/prompt_v2.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/prompt_v3.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/text2sql_agent.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/text2sql/validate_sql_dataset.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/workflow_eval/__init__.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/workflow_eval/evals.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples/workflow_eval/workflow.py +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples.egg-info/dependency_links.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples.egg-info/entry_points.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples.egg-info/requires.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/ragas_examples.egg-info/top_level.txt +0 -0
- {ragas_examples-0.4.0 → ragas_examples-0.4.2}/setup.cfg +0 -0
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.4.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 4,
|
|
31
|
+
__version__ = version = '0.4.2'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 4, 2)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'gbf6117889'
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# AG-UI Agent Evaluation Examples
|
|
2
|
+
|
|
3
|
+
This example demonstrates how to evaluate agents built with the **AG-UI protocol** using Ragas metrics.
|
|
4
|
+
|
|
5
|
+
## What is AG-UI?
|
|
6
|
+
|
|
7
|
+
AG-UI (Agent-User Interaction) is a protocol for streaming agent events from backend to frontend. It defines a standardized event format for agent-to-UI communication, enabling real-time streaming of agent actions, tool calls, and responses.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
Before running these examples, you need to have an AG-UI compatible agent running. Follow the [AG-UI Quickstart Guide](https://docs.ag-ui.com/quickstart/applications) to set up your agent.
|
|
12
|
+
|
|
13
|
+
### Popular AG-UI Compatible Frameworks
|
|
14
|
+
|
|
15
|
+
- **Google ADK (Agent Development Kit)** - Google's framework for building AI agents
|
|
16
|
+
- **Pydantic AI** - Type-safe agent framework using Pydantic
|
|
17
|
+
- **Mastra** - Modular, TypeScript-based agentic AI framework
|
|
18
|
+
- **Crew.ai** - Python framework for orchestrating collaborative, specialized AI agent teams
|
|
19
|
+
- And more...
|
|
20
|
+
|
|
21
|
+
### Example Setup
|
|
22
|
+
|
|
23
|
+
Here's a quick overview of setting up an AG-UI agent (refer to the [official documentation](https://docs.ag-ui.com/quickstart/applications) for detailed instructions):u
|
|
24
|
+
|
|
25
|
+
1. Choose your agent framework (e.g., Google ADK, Pydantic AI)
|
|
26
|
+
2. Implement your agent with the required tools
|
|
27
|
+
3. Start the AG-UI server (typically runs at `http://localhost:8000/chat` or `http://localhost:8000/agentic_chat`)
|
|
28
|
+
4. Verify the endpoint is accessible
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Install the required dependencies:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# From the ragas repository root
|
|
36
|
+
uv pip install -e ".[dev]"
|
|
37
|
+
|
|
38
|
+
# Or install specific dependencies
|
|
39
|
+
pip install ragas openai
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Evaluation Scenarios
|
|
43
|
+
|
|
44
|
+
This example includes two evaluation scenarios:
|
|
45
|
+
|
|
46
|
+
### 1. Scientist Biographies (Factuality & Grounding)
|
|
47
|
+
|
|
48
|
+
Tests the agent's ability to provide factually correct information about famous scientists and keep responses concise. The evaluation uses the modern collections portfolio plus a discrete conciseness check implemented with `DiscreteMetric`.
|
|
49
|
+
|
|
50
|
+
- **Metrics**: Collections metrics — `FactualCorrectness` (mode `f1`, atomicity `high`, coverage `high`), `AnswerRelevancy` (strictness `2`), and a custom `conciseness` metric (DiscreteMetric)
|
|
51
|
+
- **Dataset**: `test_data/scientist_biographies.csv` - 5 questions about scientists (Einstein, Fleming, Newton, etc.)
|
|
52
|
+
- **Sample Type**: `SingleTurnSample` - Simple question-answer pairs
|
|
53
|
+
|
|
54
|
+
### 2. Weather Tool Usage (Tool Call F1)
|
|
55
|
+
|
|
56
|
+
Tests the agent's ability to correctly invoke the weather tool when appropriate.
|
|
57
|
+
|
|
58
|
+
- **Metric**: `ToolCallF1` - F1 score measuring precision and recall of tool invocations
|
|
59
|
+
- **Dataset**: `test_data/weather_tool_calls.csv` - 5 queries requiring weather tool calls
|
|
60
|
+
- **Sample Type**: `MultiTurnSample` - Multi-turn conversations with tool call expectations
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Basic Usage
|
|
65
|
+
|
|
66
|
+
Run both evaluation scenarios:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd examples/ragas_examples/ag_ui_agent_evals
|
|
70
|
+
python evals.py --endpoint-url http://localhost:8000/agentic_chat
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Command Line Options
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Specify a different endpoint
|
|
77
|
+
python evals.py --endpoint-url http://localhost:8010/chat
|
|
78
|
+
|
|
79
|
+
# Use a different evaluator model
|
|
80
|
+
python evals.py --evaluator-model gpt-4o
|
|
81
|
+
|
|
82
|
+
# Skip the factual correctness evaluation
|
|
83
|
+
python evals.py --skip-factual
|
|
84
|
+
|
|
85
|
+
# Skip the tool call evaluation
|
|
86
|
+
python evals.py --skip-tool-eval
|
|
87
|
+
|
|
88
|
+
# Specify output directory for results
|
|
89
|
+
python evals.py --output-dir ./results
|
|
90
|
+
|
|
91
|
+
# Combine options
|
|
92
|
+
python evals.py \
|
|
93
|
+
--endpoint-url http://localhost:8000/agentic_chat \
|
|
94
|
+
--evaluator-model gpt-4o-mini \
|
|
95
|
+
--output-dir ./my_results
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Using uv (Recommended)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Run with uv from the examples directory
|
|
102
|
+
cd examples
|
|
103
|
+
uv run python ragas_examples/ag_ui_agent_evals/evals.py --endpoint-url http://localhost:8000/agentic_chat
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Environment variables
|
|
107
|
+
|
|
108
|
+
The script loads `.env` from the repository root, so configure your evaluator credentials there:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
echo "OPENAI_API_KEY=sk-..." > .env
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Expected Output
|
|
115
|
+
|
|
116
|
+
### Console Output
|
|
117
|
+
|
|
118
|
+
The script will print detailed evaluation results:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
================================================================================
|
|
122
|
+
Starting Scientist Biographies Evaluation
|
|
123
|
+
================================================================================
|
|
124
|
+
Loading scientist biographies dataset from .../test_data/scientist_biographies.csv
|
|
125
|
+
Loaded 5 scientist biography samples
|
|
126
|
+
Evaluating against endpoint: http://localhost:8000/agentic_chat
|
|
127
|
+
|
|
128
|
+
================================================================================
|
|
129
|
+
Scientist Biographies Evaluation Results
|
|
130
|
+
================================================================================
|
|
131
|
+
user_input ... conciseness
|
|
132
|
+
0 Who originated the theory of relativity... ... concise
|
|
133
|
+
1 Who discovered penicillin and when... ... verbose
|
|
134
|
+
...
|
|
135
|
+
|
|
136
|
+
Average Factual Correctness: 0.7160
|
|
137
|
+
Average Answer Relevancy: 0.8120
|
|
138
|
+
Concise responses: 60.00%
|
|
139
|
+
Perfect factual scores (1.0): 2/5
|
|
140
|
+
|
|
141
|
+
Results saved to: .../scientist_biographies_results_20250101_143022.csv
|
|
142
|
+
|
|
143
|
+
================================================================================
|
|
144
|
+
Starting Weather Tool Usage Evaluation
|
|
145
|
+
================================================================================
|
|
146
|
+
...
|
|
147
|
+
Average Tool Call F1: 1.0000
|
|
148
|
+
Perfect scores (F1=1.0): 5/5
|
|
149
|
+
Failed scores (F1=0.0): 0/5
|
|
150
|
+
|
|
151
|
+
Results saved to: .../weather_tool_calls_results_20250101_143045.csv
|
|
152
|
+
|
|
153
|
+
================================================================================
|
|
154
|
+
All evaluations completed successfully!
|
|
155
|
+
================================================================================
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### CSV Output Files
|
|
159
|
+
|
|
160
|
+
Results are saved as timestamped CSV files:
|
|
161
|
+
|
|
162
|
+
- `scientist_biographies_results_YYYYMMDD_HHMMSS.csv`
|
|
163
|
+
- `weather_tool_calls_results_YYYYMMDD_HHMMSS.csv`
|
|
164
|
+
|
|
165
|
+
Example CSV structure:
|
|
166
|
+
|
|
167
|
+
```csv
|
|
168
|
+
user_input,response,reference,factual_correctness(mode=f1),answer_relevancy,conciseness
|
|
169
|
+
"Who originated the theory of relativity...","Albert Einstein...","Albert Einstein originated...",0.75,0.82,concise
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Customizing the Evaluation
|
|
173
|
+
|
|
174
|
+
### Adding New Test Cases
|
|
175
|
+
|
|
176
|
+
#### For Factual Correctness
|
|
177
|
+
|
|
178
|
+
Edit `test_data/scientist_biographies.csv`:
|
|
179
|
+
|
|
180
|
+
```csv
|
|
181
|
+
user_input,reference
|
|
182
|
+
"Your question here","Your reference answer here"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### For Tool Call Evaluation
|
|
186
|
+
|
|
187
|
+
Edit `test_data/weather_tool_calls.csv`:
|
|
188
|
+
|
|
189
|
+
```csv
|
|
190
|
+
user_input,reference_tool_calls
|
|
191
|
+
"What's the weather in Paris?","[{\"name\": \"weatherTool\", \"args\": {\"location\": \"Paris\"}}]"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Using Different Metrics
|
|
195
|
+
|
|
196
|
+
Modify `evals.py` to include additional collections metrics:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from ragas.metrics.collections import AnswerRelevancy, ContextPrecisionWithoutReference
|
|
200
|
+
|
|
201
|
+
# In evaluate_scientist_biographies function:
|
|
202
|
+
metrics = [
|
|
203
|
+
AnswerRelevancy(llm=evaluator_llm),
|
|
204
|
+
ContextPrecisionWithoutReference(llm=evaluator_llm),
|
|
205
|
+
ResponseGroundedness(llm=evaluator_llm),
|
|
206
|
+
]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Evaluating Your Own Agent
|
|
210
|
+
|
|
211
|
+
1. **Ensure your agent supports AG-UI protocol**
|
|
212
|
+
- Agent must expose an endpoint that accepts AG-UI messages
|
|
213
|
+
- Agent must return Server-Sent Events (SSE) with AG-UI event format
|
|
214
|
+
|
|
215
|
+
2. **Update the endpoint URL**
|
|
216
|
+
```bash
|
|
217
|
+
python evals.py --endpoint-url http://your-agent:port/your-endpoint
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
3. **Customize test data**
|
|
221
|
+
- Create new CSV files with your test cases
|
|
222
|
+
- Update the loader functions in `evals.py` if needed
|
|
223
|
+
|
|
224
|
+
## Troubleshooting
|
|
225
|
+
|
|
226
|
+
### Connection Errors
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
Error: Connection refused at http://localhost:8000/agentic_chat
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Solution**: Ensure your AG-UI agent is running and accessible at the specified endpoint.
|
|
233
|
+
|
|
234
|
+
### Import Errors
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
ImportError: No module named 'ragas'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Solution**: Install ragas and its dependencies:
|
|
241
|
+
```bash
|
|
242
|
+
pip install ragas langchain-openai
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### API Key Errors
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
Error: OpenAI API key not found
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Solution**: Set your OpenAI API key:
|
|
252
|
+
```bash
|
|
253
|
+
export OPENAI_API_KEY='your-api-key-here'
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Agent Timeout
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
Error: Request timeout after 60.0 seconds
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Solution**: Your agent may be slow to respond. You can increase the timeout in the code or optimize your agent's performance.
|
|
263
|
+
|
|
264
|
+
## Understanding the Results
|
|
265
|
+
|
|
266
|
+
### Factual Correctness Metric
|
|
267
|
+
|
|
268
|
+
- **Range**: 0.0 to 1.0
|
|
269
|
+
- **1.0**: Perfect match between response and reference
|
|
270
|
+
- **0.5-0.9**: Partially correct with some missing or incorrect information
|
|
271
|
+
- **<0.5**: Significant discrepancies with the reference
|
|
272
|
+
|
|
273
|
+
### Answer Relevancy Metric
|
|
274
|
+
|
|
275
|
+
- **Range**: 0.0 to 1.0
|
|
276
|
+
- **1.0**: All generated follow-up questions align tightly with the original user input
|
|
277
|
+
- **0.5-0.9**: Mostly relevant answers with minor drift or non-committal language
|
|
278
|
+
- **<0.5**: Response is largely unrelated or evasive compared to the user query
|
|
279
|
+
|
|
280
|
+
### Conciseness Metric
|
|
281
|
+
|
|
282
|
+
- **Values**: `concise` or `verbose`
|
|
283
|
+
- **concise**: The evaluator judged the answer as efficient and to the point
|
|
284
|
+
- **verbose**: The answer included unnecessary repetition or tangents
|
|
285
|
+
|
|
286
|
+
### Tool Call F1 Metric
|
|
287
|
+
|
|
288
|
+
- **Range**: 0.0 to 1.0
|
|
289
|
+
- **1.0**: Perfect tool call accuracy (correct tools with correct arguments)
|
|
290
|
+
- **0.5-0.9**: Some correct tools but missing some or calling extra tools
|
|
291
|
+
- **0.0**: Incorrect tool usage or no tool calls when expected
|
|
292
|
+
|
|
293
|
+
## Integration with Your Workflow
|
|
294
|
+
|
|
295
|
+
### CI/CD Integration
|
|
296
|
+
|
|
297
|
+
You can integrate these evaluations into your CI/CD pipeline:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# In your CI script
|
|
301
|
+
python evals.py \
|
|
302
|
+
--endpoint-url http://staging-agent:8000/chat \
|
|
303
|
+
--output-dir ./test-results \
|
|
304
|
+
|| exit 1
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Tracking Performance Over Time
|
|
308
|
+
|
|
309
|
+
Save results with timestamps to track improvements:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Run evaluations regularly
|
|
313
|
+
python evals.py --output-dir ./historical-results/$(date +%Y%m%d)
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Automated Testing
|
|
317
|
+
|
|
318
|
+
Create a simple test harness:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
import subprocess
|
|
322
|
+
import sys
|
|
323
|
+
|
|
324
|
+
result = subprocess.run(
|
|
325
|
+
["python", "evals.py", "--endpoint-url", "http://localhost:8000/chat"],
|
|
326
|
+
capture_output=True
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
if result.returncode != 0:
|
|
330
|
+
print("Evaluation failed!")
|
|
331
|
+
sys.exit(1)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Additional Resources
|
|
335
|
+
|
|
336
|
+
- [AG-UI Documentation](https://docs.ag-ui.com)
|
|
337
|
+
- [AG-UI Quickstart](https://docs.ag-ui.com/quickstart/applications)
|
|
338
|
+
- [Ragas Documentation](https://docs.ragas.io)
|
|
339
|
+
- [Ragas AG-UI Integration Guide](https://docs.ragas.io/integrations/ag-ui)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AG-UI Agent Evaluation Examples
|
|
3
|
+
|
|
4
|
+
This package demonstrates how to evaluate agents built with the AG-UI protocol
|
|
5
|
+
using Ragas metrics.
|
|
6
|
+
|
|
7
|
+
## What is AG-UI?
|
|
8
|
+
|
|
9
|
+
AG-UI (Agent-to-UI) is a protocol for streaming agent events from backend to frontend.
|
|
10
|
+
It defines a standardized event format for agent-to-UI communication.
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
Before running these examples, you'll need to have an AG-UI compatible agent running.
|
|
15
|
+
Follow the AG-UI quickstart guide to set up your agent:
|
|
16
|
+
|
|
17
|
+
https://docs.ag-ui.com/quickstart/applications
|
|
18
|
+
|
|
19
|
+
Popular agent frameworks that support AG-UI include:
|
|
20
|
+
- Google ADK (Agent Development Kit)
|
|
21
|
+
- Pydantic AI
|
|
22
|
+
- And more...
|
|
23
|
+
|
|
24
|
+
## Running the Examples
|
|
25
|
+
|
|
26
|
+
Once you have your AG-UI agent endpoint running (typically at
|
|
27
|
+
http://localhost:8000/chat or http://localhost:8000/agentic_chat), you can run
|
|
28
|
+
the evaluation examples:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# From the examples directory
|
|
32
|
+
cd ragas_examples/ag_ui_agent_evals
|
|
33
|
+
uv run python evals.py --endpoint-url http://localhost:8000/agentic_chat
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Evaluation Scenarios
|
|
37
|
+
|
|
38
|
+
This package includes two evaluation scenarios:
|
|
39
|
+
|
|
40
|
+
1. **Scientist Biographies** - Uses the modern collections metrics
|
|
41
|
+
(`FactualCorrectness`, `ContextPrecisionWithReference`, `ContextRecall`,
|
|
42
|
+
`ResponseGroundedness`) with `SingleTurnSample` datasets to score factuality
|
|
43
|
+
and grounding in one pass.
|
|
44
|
+
|
|
45
|
+
2. **Weather Tool Usage** - Tests tool calling accuracy using the `ToolCallF1`
|
|
46
|
+
metric with `MultiTurnSample` datasets.
|
|
47
|
+
|
|
48
|
+
## Results
|
|
49
|
+
|
|
50
|
+
Evaluation results are saved as CSV files with timestamps for tracking performance
|
|
51
|
+
over time.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
__version__ = "0.1.0"
|