rakam-eval-sdk 0.1.15__tar.gz → 0.1.16__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.
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rakam-eval-sdk
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: Evaluation Framework SDK
5
5
  Author: Mohamed Bachar Touil
6
6
  License: MIT
7
7
  Requires-Dist: pydantic>=2.10.6
8
8
  Requires-Dist: requests
9
+ Requires-Dist: typer>=0.20.1
9
10
  Requires-Python: >=3.8
10
11
  Description-Content-Type: text/markdown
11
12
 
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "rakam-eval-sdk"
7
- version = "0.1.15"
7
+ version = "0.1.16"
8
8
  description = "Evaluation Framework SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -15,6 +15,7 @@ authors = [
15
15
  dependencies = [
16
16
  "pydantic>=2.10.6",
17
17
  "requests",
18
+ "typer>=0.20.1",
18
19
  ]
19
20
 
20
21
  [dependency-groups]
@@ -37,3 +38,6 @@ name = "testpypi"
37
38
  url = "https://test.pypi.org/simple/"
38
39
  publish-url = "https://test.pypi.org/legacy/"
39
40
  explicit = true
41
+
42
+ [project.scripts]
43
+ mycli = "rakam_eval_sdk.cli:main"
@@ -0,0 +1,17 @@
1
+ # cli.py
2
+ import typer
3
+ from pathlib import Path
4
+
5
+ app = typer.Typer()
6
+
7
+
8
+ @app.command()
9
+ def read(file: Path):
10
+ """Read a Python file"""
11
+ if file.suffix != ".py":
12
+ raise typer.BadParameter("Must be a .py file")
13
+ typer.echo(file.read_text())
14
+
15
+
16
+ def main():
17
+ app()
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import random
3
- from typing import Any, List, Optional, cast
3
+ from typing import Any, List, Optional, Union, cast
4
+
4
5
  import requests
5
6
 
6
7
  from .schema import (
@@ -79,10 +80,11 @@ class DeepEvalClient:
79
80
  metrics: List[MetricConfig],
80
81
  raise_exception: bool = False,
81
82
  component: str = "unknown",
83
+ version: Union[str, None] = None,
82
84
  ) -> Optional[dict]:
83
85
  """Run synchronous text evaluation."""
84
86
  payload = EvalConfig.model_construct(
85
- data=data, metrics=metrics, component=component
87
+ data=data, metrics=metrics, component=component, version=version
86
88
  ).model_dump()
87
89
  return self._request("/deepeval/text-eval", payload, raise_exception)
88
90
 
@@ -92,10 +94,11 @@ class DeepEvalClient:
92
94
  metrics: List[MetricConfig],
93
95
  raise_exception: bool = False,
94
96
  component: str = "unknown",
97
+ version: Union[str, None] = None,
95
98
  ) -> Optional[dict]:
96
99
  """Run background text evaluation (async job)."""
97
100
  payload = EvalConfig.model_construct(
98
- data=data, metrics=metrics, component=component
101
+ data=data, metrics=metrics, component=component, version=version
99
102
  ).model_dump()
100
103
  return self._request("/deepeval/text-eval/background", payload, raise_exception)
101
104
 
@@ -105,10 +108,11 @@ class DeepEvalClient:
105
108
  metrics: List[SchemaMetricConfig],
106
109
  raise_exception: bool = False,
107
110
  component: str = "unknown",
111
+ version: Union[str, None] = None,
108
112
  ) -> Optional[dict]:
109
113
  """Run synchronous schema evaluation."""
110
114
  payload = SchemaEvalConfig.model_construct(
111
- data=data, metrics=metrics, component=component
115
+ data=data, metrics=metrics, component=component, version=version
112
116
  ).model_dump()
113
117
  return self._request("/deepeval/schema-eval", payload, raise_exception)
114
118
 
@@ -118,10 +122,11 @@ class DeepEvalClient:
118
122
  metrics: List[SchemaMetricConfig],
119
123
  raise_exception: bool = False,
120
124
  component: str = "unknown",
125
+ version: Union[str, None] = None,
121
126
  ) -> Optional[dict]:
122
127
  """Run background schema evaluation (async job)."""
123
128
  payload = SchemaEvalConfig.model_construct(
124
- data=data, metrics=metrics, component=component
129
+ data=data, metrics=metrics, component=component, version=version
125
130
  ).model_dump()
126
131
  return self._request(
127
132
  "/deepeval/schema-eval/background", payload, raise_exception
@@ -134,11 +139,14 @@ class DeepEvalClient:
134
139
  chance: float,
135
140
  raise_exception: bool = False,
136
141
  component: str = "unknown",
142
+ version: Union[str, None] = None,
137
143
  ) -> Optional[dict]:
138
144
  """Randomly run text_eval based on a probability between 0 and 1."""
139
145
  self._validate_chance(chance)
140
146
  return (
141
- self.text_eval(data, metrics, raise_exception, component=component)
147
+ self.text_eval(
148
+ data, metrics, raise_exception, component=component, version=version
149
+ )
142
150
  if random.random() <= chance
143
151
  else None
144
152
  )
@@ -150,12 +158,13 @@ class DeepEvalClient:
150
158
  chance: float,
151
159
  raise_exception: bool = False,
152
160
  component: str = "unknown",
161
+ version: Union[str, None] = None,
153
162
  ) -> Optional[dict]:
154
163
  """Randomly run text_eval_background based on a probability between 0 and 1."""
155
164
  self._validate_chance(chance)
156
165
  return (
157
166
  self.text_eval_background(
158
- data, metrics, raise_exception, component=component
167
+ data, metrics, raise_exception, component=component, version=version
159
168
  )
160
169
  if random.random() <= chance
161
170
  else None
@@ -168,11 +177,14 @@ class DeepEvalClient:
168
177
  chance: float,
169
178
  raise_exception: bool = False,
170
179
  component: str = "unknown",
180
+ version: Union[str, None] = None,
171
181
  ) -> Optional[dict]:
172
182
  """Randomly run schema_eval based on a probability between 0 and 1."""
173
183
  self._validate_chance(chance)
174
184
  return (
175
- self.schema_eval(data, metrics, raise_exception, component=component)
185
+ self.schema_eval(
186
+ data, metrics, raise_exception, component=component, version=version
187
+ )
176
188
  if random.random() <= chance
177
189
  else None
178
190
  )
@@ -184,12 +196,13 @@ class DeepEvalClient:
184
196
  chance: float,
185
197
  raise_exception: bool = False,
186
198
  component: str = "unknown",
199
+ version: Union[str, None] = None,
187
200
  ) -> Optional[dict]:
188
201
  """Randomly run text_eval_background based on a probability between 0 and 1."""
189
202
  self._validate_chance(chance)
190
203
  return (
191
204
  self.schema_eval_background(
192
- data, metrics, raise_exception, component=component
205
+ data, metrics, raise_exception, component=component, version=version
193
206
  )
194
207
  if random.random() <= chance
195
208
  else None
@@ -39,7 +39,7 @@ class CorrectnessConfig(MetricConfigBase):
39
39
  "Minor formatting differences like '$1,250.00' vs '$1250.00' are acceptable."
40
40
  ]
41
41
  )
42
- criteria: Optional[str] = None,
42
+ criteria: Optional[str] = (None,)
43
43
  params: List[Literal["actual_output", "expected_output"]] = Field(
44
44
  default=["actual_output", "expected_output"]
45
45
  )
@@ -94,8 +94,7 @@ MetricConfig = Annotated[
94
94
  ]
95
95
 
96
96
  SchemaMetricConfig = Annotated[
97
- Union[JsonCorrectnessConfig, FieldsPresenceConfig], Field(
98
- discriminator="type")
97
+ Union[JsonCorrectnessConfig, FieldsPresenceConfig], Field(discriminator="type")
99
98
  ]
100
99
 
101
100
 
@@ -118,11 +117,13 @@ class SchemaInputItem(InputItem):
118
117
 
119
118
  class EvalConfig(BaseModel):
120
119
  component: str = "unknown"
120
+ version: Union[str, None] = None
121
121
  data: List[TextInputItem]
122
122
  metrics: List[MetricConfig] = Field(default_factory=list)
123
123
 
124
124
 
125
125
  class SchemaEvalConfig(BaseModel):
126
126
  component: str = "unknown"
127
+ version: Union[str, None] = None
127
128
  data: List[SchemaInputItem]
128
129
  metrics: List[SchemaMetricConfig] = Field(default_factory=list)