Skip to content

Commit 4fbf515

Browse files
authored
Reformat examples (#2186)
- **Reformatted examples and scripts**
1 parent a97d113 commit 4fbf515

File tree

8 files changed

+8
-16
lines changed

8 files changed

+8
-16
lines changed

examples/gdrive_append_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def append_to_existing_dataset():
5353
print("Existing records:")
5454
for i, record in enumerate(dataset):
5555
print(
56-
f" {i+1}. {record['question'] if isinstance(record, dict) else record.question}"
56+
f" {i + 1}. {record['question'] if isinstance(record, dict) else record.question}"
5757
)
5858

5959
# Add new records
@@ -88,7 +88,7 @@ def append_to_existing_dataset():
8888
print("\nAll records in dataset:")
8989
for i, record in enumerate(dataset):
9090
print(
91-
f" {i+1}. {record['question'] if isinstance(record, dict) else record.question} -> {record['answer'] if isinstance(record, dict) else record.answer}"
91+
f" {i + 1}. {record['question'] if isinstance(record, dict) else record.question} -> {record['answer'] if isinstance(record, dict) else record.answer}"
9292
)
9393

9494
return dataset

examples/gdrive_backend_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
For detailed setup instructions, see the documentation.
2323
"""
2424

25-
import os
2625
from pydantic import BaseModel
2726

2827
from ragas.experimental.dataset import Dataset
@@ -105,7 +104,7 @@ def example_usage():
105104
# Access individual records
106105
for i, record in enumerate(dataset):
107106
print(
108-
f"Record {i+1}: {record['question'] if isinstance(record, dict) else record.question} -> {record['answer'] if isinstance(record, dict) else record.answer} (Score: {record['score'] if isinstance(record, dict) else record.score})"
107+
f"Record {i + 1}: {record['question'] if isinstance(record, dict) else record.question} -> {record['answer'] if isinstance(record, dict) else record.answer} (Score: {record['score'] if isinstance(record, dict) else record.score})"
109108
)
110109

111110
# List all datasets in the backend

examples/prompt_evals/evals.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def my_metric(prediction: str, actual: str):
1818

1919
@experiment()
2020
async def run_experiment(row):
21-
2221
response = run_prompt(row["text"])
2322
score = my_metric.score(prediction=response, actual=row["label"])
2423

@@ -72,7 +71,6 @@ async def main():
7271

7372

7473
if __name__ == "__main__":
75-
7674
import asyncio
7775

7876
asyncio.run(main())

examples/rag_eval/evals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
def load_dataset():
15-
1615
dataset = Dataset(
1716
name="test_dataset",
1817
backend="local/csv",

examples/rag_eval/rag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Dict, Any, Optional, Tuple
1+
from typing import List, Dict, Any, Optional
22
from openai import OpenAI
33
import json
44
import os
@@ -456,7 +456,6 @@ def default_rag_client(llm_client, logdir: str = "logs") -> ExampleRAG:
456456

457457

458458
if __name__ == "__main__":
459-
460459
try:
461460
api_key = os.environ["OPENAI_API_KEY"]
462461
except KeyError:

examples/workflow_eval/evals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
def load_dataset():
15-
1615
dataset_dict = [
1716
{
1817
"email": "Hi, I'm getting error code XYZ-123 when using version 2.1.4 of your software. Please help!",

examples/workflow_eval/workflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def extract(self, email_content: str, category: str) -> Dict[str, Optional[str]]
178178
)
179179
return result
180180

181-
except Exception as e:
181+
except Exception:
182182
return {}
183183

184184
def _get_bug_extraction_prompt(self, email_content: str) -> str:
@@ -362,7 +362,7 @@ def classify_email(self, email_content: str) -> str:
362362
return category
363363

364364
except Exception as e:
365-
print(f" ⚠️ Classification failed, using fallback: Bug Report")
365+
print(" ⚠️ Classification failed, using fallback: Bug Report")
366366
self.traces.append(
367367
TraceEvent(
368368
event_type="error",
@@ -491,7 +491,7 @@ def generate_response(self, category: str, extracted_info: Dict[str, Any]) -> st
491491
return response_text
492492

493493
except Exception as e:
494-
print(f" ⚠️ Response generation failed, using fallback")
494+
print(" ⚠️ Response generation failed, using fallback")
495495
self.traces.append(
496496
TraceEvent(
497497
event_type="error",
@@ -571,7 +571,7 @@ def process_email(
571571
),
572572
}
573573

574-
print(f"✅ Workflow completed successfully")
574+
print("✅ Workflow completed successfully")
575575
print(f"📋 Traces saved to: logs/run_{run_id}_*.json")
576576

577577
self.traces.append(

scripts/process_experimental_notebooks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import os
88
import sys
99
import subprocess
10-
import shutil
1110
from pathlib import Path
12-
import glob
1311

1412
# Path configurations
1513
RAGAS_ROOT = Path(__file__).parent.parent

0 commit comments

Comments
 (0)