judgeval 0.0.31__py3-none-any.whl → 0.0.33__py3-none-any.whl

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.
Files changed (54) hide show
  1. judgeval/__init__.py +3 -1
  2. judgeval/common/s3_storage.py +93 -0
  3. judgeval/common/tracer.py +869 -183
  4. judgeval/constants.py +1 -1
  5. judgeval/data/datasets/dataset.py +5 -1
  6. judgeval/data/datasets/eval_dataset_client.py +2 -2
  7. judgeval/data/sequence.py +16 -26
  8. judgeval/data/sequence_run.py +2 -0
  9. judgeval/judgment_client.py +44 -166
  10. judgeval/rules.py +4 -7
  11. judgeval/run_evaluation.py +2 -2
  12. judgeval/scorers/__init__.py +4 -4
  13. judgeval/scorers/judgeval_scorers/__init__.py +0 -176
  14. judgeval/version_check.py +22 -0
  15. {judgeval-0.0.31.dist-info → judgeval-0.0.33.dist-info}/METADATA +15 -2
  16. judgeval-0.0.33.dist-info/RECORD +63 -0
  17. judgeval/scorers/base_scorer.py +0 -58
  18. judgeval/scorers/judgeval_scorers/local_implementations/__init__.py +0 -27
  19. judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/__init__.py +0 -4
  20. judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/answer_correctness_scorer.py +0 -276
  21. judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/prompts.py +0 -169
  22. judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/__init__.py +0 -4
  23. judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/answer_relevancy_scorer.py +0 -298
  24. judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/prompts.py +0 -174
  25. judgeval/scorers/judgeval_scorers/local_implementations/comparison/__init__.py +0 -0
  26. judgeval/scorers/judgeval_scorers/local_implementations/comparison/comparison_scorer.py +0 -161
  27. judgeval/scorers/judgeval_scorers/local_implementations/comparison/prompts.py +0 -222
  28. judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/__init__.py +0 -3
  29. judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/contextual_precision_scorer.py +0 -264
  30. judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/prompts.py +0 -106
  31. judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/__init__.py +0 -3
  32. judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/contextual_recall_scorer.py +0 -254
  33. judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/prompts.py +0 -142
  34. judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/__init__.py +0 -3
  35. judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/contextual_relevancy_scorer.py +0 -245
  36. judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/prompts.py +0 -121
  37. judgeval/scorers/judgeval_scorers/local_implementations/execution_order/__init__.py +0 -3
  38. judgeval/scorers/judgeval_scorers/local_implementations/execution_order/execution_order.py +0 -156
  39. judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/__init__.py +0 -3
  40. judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/faithfulness_scorer.py +0 -318
  41. judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/prompts.py +0 -268
  42. judgeval/scorers/judgeval_scorers/local_implementations/hallucination/__init__.py +0 -3
  43. judgeval/scorers/judgeval_scorers/local_implementations/hallucination/hallucination_scorer.py +0 -264
  44. judgeval/scorers/judgeval_scorers/local_implementations/hallucination/prompts.py +0 -104
  45. judgeval/scorers/judgeval_scorers/local_implementations/instruction_adherence/instruction_adherence.py +0 -232
  46. judgeval/scorers/judgeval_scorers/local_implementations/instruction_adherence/prompt.py +0 -102
  47. judgeval/scorers/judgeval_scorers/local_implementations/json_correctness/__init__.py +0 -5
  48. judgeval/scorers/judgeval_scorers/local_implementations/json_correctness/json_correctness_scorer.py +0 -134
  49. judgeval/scorers/judgeval_scorers/local_implementations/summarization/__init__.py +0 -3
  50. judgeval/scorers/judgeval_scorers/local_implementations/summarization/prompts.py +0 -247
  51. judgeval/scorers/judgeval_scorers/local_implementations/summarization/summarization_scorer.py +0 -551
  52. judgeval-0.0.31.dist-info/RECORD +0 -96
  53. {judgeval-0.0.31.dist-info → judgeval-0.0.33.dist-info}/WHEEL +0 -0
  54. {judgeval-0.0.31.dist-info → judgeval-0.0.33.dist-info}/licenses/LICENSE.md +0 -0
judgeval/__init__.py CHANGED
@@ -1,10 +1,12 @@
1
1
  # Import key components that should be publicly accessible
2
2
  from judgeval.clients import client, together_client
3
3
  from judgeval.judgment_client import JudgmentClient
4
+ from judgeval.version_check import check_latest_version
5
+ check_latest_version()
4
6
 
5
7
  __all__ = [
6
8
  # Clients
7
9
  'client',
8
10
  'together_client',
9
11
  'JudgmentClient',
10
- ]
12
+ ]
@@ -0,0 +1,93 @@
1
+ import os
2
+ import json
3
+ import boto3
4
+ from typing import Optional
5
+ from datetime import datetime, UTC
6
+ from botocore.exceptions import ClientError
7
+ from judgeval.common.logger import warning, info
8
+
9
+ class S3Storage:
10
+ """Utility class for storing and retrieving trace data from S3."""
11
+
12
+ def __init__(
13
+ self,
14
+ bucket_name: str,
15
+ aws_access_key_id: Optional[str] = None,
16
+ aws_secret_access_key: Optional[str] = None,
17
+ region_name: Optional[str] = None
18
+ ):
19
+ """Initialize S3 storage with credentials and bucket name.
20
+
21
+ Args:
22
+ bucket_name: Name of the S3 bucket to store traces in
23
+ aws_access_key_id: AWS access key ID (optional, will use environment variables if not provided)
24
+ aws_secret_access_key: AWS secret access key (optional, will use environment variables if not provided)
25
+ region_name: AWS region name (optional, will use environment variables if not provided)
26
+ """
27
+ self.bucket_name = bucket_name
28
+ self.s3_client = boto3.client(
29
+ 's3',
30
+ aws_access_key_id=aws_access_key_id or os.getenv('AWS_ACCESS_KEY_ID'),
31
+ aws_secret_access_key=aws_secret_access_key or os.getenv('AWS_SECRET_ACCESS_KEY'),
32
+ region_name=region_name or os.getenv('AWS_REGION', 'us-west-1')
33
+ )
34
+
35
+ def _ensure_bucket_exists(self):
36
+ """Ensure the S3 bucket exists, creating it if necessary."""
37
+ try:
38
+ self.s3_client.head_bucket(Bucket=self.bucket_name)
39
+ except ClientError as e:
40
+ error_code = e.response['Error']['Code']
41
+ if error_code == '404':
42
+ # Bucket doesn't exist, create it
43
+ info(f"Bucket {self.bucket_name} doesn't exist, creating it ...")
44
+ try:
45
+ self.s3_client.create_bucket(
46
+ Bucket=self.bucket_name,
47
+ CreateBucketConfiguration={
48
+ 'LocationConstraint': self.s3_client.meta.region_name
49
+ }
50
+ )
51
+ info(f"Created S3 bucket: {self.bucket_name}")
52
+ except ClientError as create_error:
53
+ if create_error.response['Error']['Code'] == 'BucketAlreadyOwnedByYou':
54
+ # Bucket was just created by another process
55
+ warning(f"Bucket {self.bucket_name} was just created by another process")
56
+ pass
57
+ else:
58
+ raise create_error
59
+ else:
60
+ # Some other error occurred
61
+ raise e
62
+
63
+ def save_trace(self, trace_data: dict, trace_id: str, project_name: str) -> str:
64
+ """Save trace data to S3.
65
+
66
+ Args:
67
+ trace_data: The trace data to save
68
+ trace_id: Unique identifier for the trace
69
+ project_name: Name of the project the trace belongs to
70
+
71
+ Returns:
72
+ str: S3 key where the trace was saved
73
+ """
74
+ # Ensure bucket exists before saving
75
+ self._ensure_bucket_exists()
76
+
77
+ # Create a timestamped key for the trace
78
+ timestamp = datetime.now(UTC).strftime('%Y%m%d_%H%M%S')
79
+ s3_key = f"traces/{project_name}/{trace_id}_{timestamp}.json"
80
+
81
+ # Convert trace data to JSON string
82
+ trace_json = json.dumps(trace_data)
83
+
84
+ # Upload to S3
85
+ info(f"Uploading trace to S3 at key {s3_key}, in bucket {self.bucket_name} ...")
86
+ self.s3_client.put_object(
87
+ Bucket=self.bucket_name,
88
+ Key=s3_key,
89
+ Body=trace_json,
90
+ ContentType='application/json'
91
+ )
92
+
93
+ return s3_key