deepeval 3.8.2__py3-none-any.whl → 3.8.4__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.
deepeval/prompt/utils.py CHANGED
@@ -130,7 +130,7 @@ def construct_base_model(
130
130
  if not schema:
131
131
  return None
132
132
  if not schema.fields:
133
- return create_model(schema.name)
133
+ return create_model(schema.name or "EmptySchema")
134
134
 
135
135
  parent_id_map: Dict[Optional[str], List[OutputSchemaField]] = {}
136
136
  for field in schema.fields:
@@ -153,7 +153,7 @@ def construct_base_model(
153
153
  default = ... if field.required else None
154
154
  root_fields[field.name] = (python_type, default)
155
155
 
156
- return create_model(schema.name, **root_fields)
156
+ return create_model(schema.name or "Schema", **root_fields)
157
157
 
158
158
 
159
159
  ###################################
@@ -219,3 +219,73 @@ def construct_output_schema(
219
219
  return None
220
220
  all_fields = _process_model(base_model_class)
221
221
  return OutputSchema(fields=all_fields, name=base_model_class.__name__)
222
+
223
+
224
+ def output_schema_to_json_schema(
225
+ schema: Optional[OutputSchema] = None,
226
+ ) -> Dict[str, Any]:
227
+ if not schema or not schema.fields:
228
+ return {
229
+ "type": "object",
230
+ "properties": {},
231
+ "additionalProperties": False,
232
+ }
233
+
234
+ # Build parent-child mapping
235
+ children_map: Dict[Optional[str], List[OutputSchemaField]] = {}
236
+ for field in schema.fields:
237
+ parent_id = field.parent_id
238
+ children_map.setdefault(parent_id, []).append(field)
239
+
240
+ # Map SchemaDataType to JSON Schema types
241
+ def map_type(dtype: SchemaDataType) -> str:
242
+ return {
243
+ SchemaDataType.STRING: "string",
244
+ SchemaDataType.INTEGER: "integer",
245
+ SchemaDataType.FLOAT: "number",
246
+ SchemaDataType.BOOLEAN: "boolean",
247
+ SchemaDataType.OBJECT: "object",
248
+ SchemaDataType.NULL: "null",
249
+ }.get(dtype, "string")
250
+
251
+ def build_node(field_list: List[OutputSchemaField]) -> Dict[str, Any]:
252
+ properties = {}
253
+ required_fields = []
254
+
255
+ for field in field_list:
256
+ field_type = (
257
+ field.type.value if hasattr(field.type, "value") else field.type
258
+ )
259
+ field_schema = {"type": map_type(field.type)}
260
+
261
+ # Add description if available
262
+ if field.description:
263
+ field_schema["description"] = field.description
264
+
265
+ # Handle nested objects
266
+ if field_type == SchemaDataType.OBJECT.value:
267
+ children = children_map.get(field.id, [])
268
+ if children:
269
+ nested = build_node(children)
270
+ field_schema.update(nested)
271
+ else:
272
+ field_schema["properties"] = {}
273
+ field_schema["additionalProperties"] = False
274
+
275
+ properties[field.name] = field_schema
276
+ if field.required:
277
+ required_fields.append(field.name)
278
+
279
+ schema_dict = {
280
+ "type": "object",
281
+ "properties": properties,
282
+ "additionalProperties": False,
283
+ }
284
+
285
+ if required_fields:
286
+ schema_dict["required"] = required_fields
287
+
288
+ return schema_dict
289
+
290
+ root_fields = children_map.get(None, [])
291
+ return build_node(root_fields)
deepeval/tracing/api.py CHANGED
@@ -126,6 +126,7 @@ class TraceApi(BaseModel):
126
126
  input: Optional[Any] = Field(None)
127
127
  output: Optional[Any] = Field(None)
128
128
  status: Optional[TraceSpanApiStatus] = Field(TraceSpanApiStatus.SUCCESS)
129
+ test_case_id: Optional[str] = Field(None, alias="testCaseId")
129
130
 
130
131
  # additional test case parameters
131
132
  retrieval_context: Optional[List[str]] = Field(
@@ -74,6 +74,7 @@ def update_current_trace(
74
74
  expected_tools: Optional[List[ToolCall]] = None,
75
75
  test_case: Optional[LLMTestCase] = None,
76
76
  confident_api_key: Optional[str] = None,
77
+ test_case_id: Optional[str] = None,
77
78
  ):
78
79
  current_trace = current_trace_context.get()
79
80
  if not current_trace:
@@ -112,6 +113,8 @@ def update_current_trace(
112
113
  current_trace.expected_tools = expected_tools
113
114
  if confident_api_key:
114
115
  current_trace.confident_api_key = confident_api_key
116
+ if test_case_id:
117
+ current_trace.test_case_id = test_case_id
115
118
 
116
119
 
117
120
  def update_llm_span(
@@ -69,9 +69,11 @@ def trace(
69
69
  )
70
70
 
71
71
  current_trace = current_trace_context.get()
72
+ started_new_trace = False
72
73
 
73
74
  if not current_trace:
74
75
  current_trace = trace_manager.start_new_trace()
76
+ started_new_trace = True
75
77
 
76
78
  if metrics:
77
79
  current_trace.metrics = metrics
@@ -103,5 +105,8 @@ def trace(
103
105
  try:
104
106
  yield current_trace
105
107
  finally:
108
+ if started_new_trace:
109
+ trace_manager.end_trace(current_trace.uuid)
110
+
106
111
  current_llm_context.set(LlmSpanContext())
107
112
  current_agent_context.set(AgentSpanContext())
@@ -690,6 +690,7 @@ class TraceManager:
690
690
  expectedOutput=trace.expected_output,
691
691
  toolsCalled=trace.tools_called,
692
692
  expectedTools=trace.expected_tools,
693
+ testCaseId=trace.test_case_id,
693
694
  confident_api_key=trace.confident_api_key,
694
695
  environment=(
695
696
  self.environment if not trace.environment else trace.environment
deepeval/tracing/types.py CHANGED
@@ -157,6 +157,7 @@ class Trace(BaseModel):
157
157
  output: Optional[Any] = None
158
158
  metrics: Optional[List[BaseMetric]] = None
159
159
  metric_collection: Optional[str] = None
160
+ test_case_id: Optional[str] = Field(None, serialization_alias="testCaseId")
160
161
 
161
162
  # Don't serialize these
162
163
  confident_api_key: Optional[str] = Field(None, exclude=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deepeval
3
- Version: 3.8.2
3
+ Version: 3.8.4
4
4
  Summary: The LLM Evaluation Framework
5
5
  Home-page: https://github.com/confident-ai/deepeval
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  deepeval/__init__.py,sha256=tle4lT4FONApg3OeztGPEdrpGMEGLWajyGTu7bEd3s0,2976
2
- deepeval/_version.py,sha256=A8HjzlffHmJot3rBAExqN_D-QxaG8UT8zqiP26xCL2M,27
2
+ deepeval/_version.py,sha256=qRG_MqE6nmuOs8veYUyEqKmn7uxJuYuzR-7hEXJnUEo,27
3
3
  deepeval/annotation/__init__.py,sha256=ZFhUVNNuH_YgQSZJ-m5E9iUb9TkAkEV33a6ouMDZ8EI,111
4
4
  deepeval/annotation/annotation.py,sha256=WLFZRkx6wRJcNzaOMMGXuTfw6Q1_1Mv5A4jpD7Ea4sU,2300
5
5
  deepeval/annotation/api.py,sha256=EYN33ACVzVxsFleRYm60KB4Exvff3rPJKt1VBuuX970,2147
@@ -147,10 +147,10 @@ deepeval/confident/types.py,sha256=9bgePDaU31yY7JGwCLZcc7pev9VGtNDZLbjsVpCLVdc,5
147
147
  deepeval/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
148
  deepeval/config/dotenv_handler.py,sha256=lOosoC7fm9RljriY8EFl5ywSGfSiQsVf_vmYqzpbZ8s,588
149
149
  deepeval/config/logging.py,sha256=ivqmhOSB-oHOOU3MvnhImrZwkkxzxKJgoKxesnWfHjg,1314
150
- deepeval/config/settings.py,sha256=rGigXXW5r50tyWtNhBYL_cZnTRGxsm71A6fBAmHawpk,57117
150
+ deepeval/config/settings.py,sha256=m5VFmEIWOuNo6JniWPqrgIrh-BMCOXyDipAmbPAEsII,57510
151
151
  deepeval/config/settings_manager.py,sha256=Ynebm2BKDrzajc6DEq2eYIwyRAAtUQOkTnl46albxLk,4187
152
152
  deepeval/config/utils.py,sha256=bJGljeAXoEYuUlYSvHSOsUnqINTwo6wOwfFHFpWxiaQ,4238
153
- deepeval/constants.py,sha256=MvwjLC1IHUY35FnnSsWVcHScmdbYBbPr8eTnsLWn40Y,1697
153
+ deepeval/constants.py,sha256=bb6GOTWJog2M992Y91ZwaQjGXChUTuznfx_TXpdaBYY,1743
154
154
  deepeval/contextvars.py,sha256=oqXtuYiKd4Zvc1rNoR1gcRBxzZYCGTMVn7XostwvkRI,524
155
155
  deepeval/dataset/__init__.py,sha256=N2c-rkuxWYiiJSOZArw0H02Cwo7cnfzFuNYJlvsIBEg,249
156
156
  deepeval/dataset/api.py,sha256=bZ95HfIaxYB1IwTnp7x4AaKXWuII17T5uqVkhUXNc7I,1650
@@ -169,26 +169,26 @@ deepeval/evaluate/execute.py,sha256=5RZrTRfe-AnwO5aS16LL-iBqT3fciun9zt3wbXp70v8,
169
169
  deepeval/evaluate/types.py,sha256=jf424xPHgdJcvgG2l_wTMskJBOEe9tl55c3v3B-SLNU,1071
170
170
  deepeval/evaluate/utils.py,sha256=STYyJCvVkewU5iigKnAsUDcVtJuFU_Qefi-aoyv2elA,20740
171
171
  deepeval/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
172
- deepeval/integrations/crewai/__init__.py,sha256=Uu7-MNV6uXnDoXlZJzt69Y73thJXlMM4xfQdv3mrlHw,227
173
- deepeval/integrations/crewai/handler.py,sha256=SbwosamuRQXOSmKPKKV7MMQ9vn-sDFiufCIHw-xxYKk,7882
174
- deepeval/integrations/crewai/subs.py,sha256=UP6aY8Nrl_lHDwxG84aRMNjxzP-X2QWTtOu9DgXMabM,1477
175
- deepeval/integrations/crewai/tool.py,sha256=6Uw3XuJO0STDq3YAL6bp_xh5ZJcza0L4kkuotFYj79s,2558
176
- deepeval/integrations/crewai/wrapper.py,sha256=r4szLNUz1O7U9eMps7czMbHyIEEQ4lfPdBb417gYPfc,3726
172
+ deepeval/integrations/crewai/__init__.py,sha256=8bkOWfzrqETEYWMB9nCKbqMd7nlU-TGvNH0CIrqtlps,316
173
+ deepeval/integrations/crewai/handler.py,sha256=dgzfWwHw94ro28-h8RyYfNQ8cOmnXCwEoWOZatxcbVk,15178
174
+ deepeval/integrations/crewai/subs.py,sha256=wcMJVBNf69dqFO8L1kMTvm4n1GsO2S-nopQn924JdU4,1974
175
+ deepeval/integrations/crewai/tool.py,sha256=thdDXt-dA2B4LmUuQipAcOiR6H19KA7zzqjlsfTyn3s,3210
176
+ deepeval/integrations/crewai/wrapper.py,sha256=w3NsXHe1M4BhjGcpMA7grUCdSAjlu2zBk9daLeTRluc,5615
177
177
  deepeval/integrations/hugging_face/__init__.py,sha256=MuHIf9im9Jypq4VkfLzhklxIrd7vSTGlT74iUNSPgvg,93
178
178
  deepeval/integrations/hugging_face/callback.py,sha256=15QQEzR34Cpdp5kUp5oVA6dEsShtiMNZ03akJWAh7lo,7911
179
179
  deepeval/integrations/hugging_face/rich_manager.py,sha256=WvFtPGpPmGeg2Ftsnojga6yvbBLiZv_tvNbnFcGb6og,3630
180
180
  deepeval/integrations/hugging_face/tests/test_callbacks.py,sha256=88Wyg-aDaXujj9jHeGdFF3ITSl2-y7eaJGWgSyvvDi8,4607
181
181
  deepeval/integrations/hugging_face/utils.py,sha256=HUKdQcTIb76Ct69AS737oPxmlVxk5fw2UbT2pLn-o8k,1817
182
182
  deepeval/integrations/langchain/__init__.py,sha256=G1Qey5WkKou2-PA34KwWgmayQ_TbvXqPyotTbzmD8tw,84
183
- deepeval/integrations/langchain/callback.py,sha256=uZrhmlzw2dcFunqQzNPfMo9vWkHCX7PbGbazKRhBbBY,32687
183
+ deepeval/integrations/langchain/callback.py,sha256=-Ip1PU84YqKbf4j17qV925GHsW5mRJN9b-d7V4fOuP8,32892
184
184
  deepeval/integrations/langchain/patch.py,sha256=fCHfZXU9xX3IJ6SG8GEYzn3qrifyUkT0i_uUABTsmcs,1255
185
185
  deepeval/integrations/langchain/utils.py,sha256=mhv0anU5ZnbBsESMuCooT9FSNPkx2ObrVLlq7QNEZOI,13104
186
186
  deepeval/integrations/llama_index/__init__.py,sha256=Ujs9ZBJFkuCWUDBJOF88UbM1Y-S6QFQhxSo0oQnEWNw,90
187
- deepeval/integrations/llama_index/handler.py,sha256=uTvNXmAF4xBh8t9bBm5sBFX6ETp8SrkOZlFlE_GWdmM,10771
187
+ deepeval/integrations/llama_index/handler.py,sha256=uVfMs9VC2vp5J_A8lxy1OmVtha31wvkJGzkp5GKhf-A,12367
188
188
  deepeval/integrations/llama_index/utils.py,sha256=onmmo1vpn6cpOY5EhfTc0Uui7X6l1M0HD3sq-KVAesg,3380
189
189
  deepeval/integrations/pydantic_ai/__init__.py,sha256=UIkXn_g6h9LTQXG1PaWu1eCFkCssIwG48WSvN46UWgU,202
190
190
  deepeval/integrations/pydantic_ai/agent.py,sha256=-NKvpTUw3AxRNhuxVFcx9mw5BWCujzOwsaC8u7K0ubc,1178
191
- deepeval/integrations/pydantic_ai/instrumentator.py,sha256=COqw4FJsUZacaP4Dfn1aaOXvUTvZOuhcqqQD-_sLD04,13047
191
+ deepeval/integrations/pydantic_ai/instrumentator.py,sha256=PPoGeJzkuoCerrjc-s_Nv8hn9DC54Jp-uXgJU0OI1Ug,13081
192
192
  deepeval/integrations/pydantic_ai/otel.py,sha256=xWYnMT1HwcAmyWdoJa6C1sHwd5frP9_IcR8dj9sKsG0,2386
193
193
  deepeval/integrations/pydantic_ai/test_instrumentator.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
194
194
  deepeval/key_handler.py,sha256=lajMBgF2lCzbQpW4e6Y7cD9FOw0Qk5UOKS4_kIIHj6Y,9562
@@ -459,10 +459,10 @@ deepeval/optimizer/utils.py,sha256=vOC7tFdWSqM62JQjtnEVjmxV8MIOlc83nuRT6ghhRGY,1
459
459
  deepeval/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
460
460
  deepeval/plugins/plugin.py,sha256=_dwsdx4Dg9DbXxK3f7zJY4QWTJQWc7QE1HmIg2Zjjag,1515
461
461
  deepeval/progress_context.py,sha256=ZSKpxrE9sdgt9G3REKnVeXAv7GJXHHVGgLynpG1Pudw,3557
462
- deepeval/prompt/__init__.py,sha256=rDU99KjydxDRKhuQJCBs_bpDJrWb2mpHtvyv6AEwFC8,367
463
- deepeval/prompt/api.py,sha256=DNhKouq3ntEKmN_VegNh5X1gu_2RGJwzBp07rEEyg6s,6359
464
- deepeval/prompt/prompt.py,sha256=Ob1cIR2cLFoVzEpx2iCMDRIRT9rqAd3xQKnnOuZkg2A,31904
465
- deepeval/prompt/utils.py,sha256=knjgPU2066OtYWMb3NqMPChr9zQgKfXo_QTLTtSkmYg,7620
462
+ deepeval/prompt/__init__.py,sha256=NLFORZoGWUV-I-UdzAsDlR_xikAP-uSl0mqngckTOK0,389
463
+ deepeval/prompt/api.py,sha256=uwE0V_gPSuR5ShHdvPR1v7IAF3O4xa2B3xgkiBDt4mE,7698
464
+ deepeval/prompt/prompt.py,sha256=2oPfCQBmgTXSJaIfxm_tp5X4dpD2578eeKPmuYDYyGw,33315
465
+ deepeval/prompt/utils.py,sha256=nhjTHgJEnXlDcLmHb5qleMSCFHiKrYHC1y4gl6MEaLU,9937
466
466
  deepeval/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
467
467
  deepeval/red_teaming/README.md,sha256=BY5rAdpp3-sMMToEKwq0Nsd9ivkGDzPE16DeDb8GY7U,154
468
468
  deepeval/scorer/__init__.py,sha256=hTvtoV3a4l0dSBjERm-jX7jveTtKZXK0c9JerQo0T_w,27
@@ -501,8 +501,8 @@ deepeval/test_run/hooks.py,sha256=Qnd06bk9RJN4WmFUzJrBAi3Xj261hzyzI2iRmG8wbKw,37
501
501
  deepeval/test_run/hyperparameters.py,sha256=4yJkNgwL2y6eyWDTmUV62f5RUlfOui4R22wsJ5uTbto,3874
502
502
  deepeval/test_run/test_run.py,sha256=csbj0KVsp1QDCFKEqthQzPSmxusjNQkoVfsWBnq2Z_s,41549
503
503
  deepeval/tracing/__init__.py,sha256=aSOk_ZgL-K7CZzcyiaIa5peAiaPViDST5GhpHA3Adc8,614
504
- deepeval/tracing/api.py,sha256=GbtpUDdGpchl6rPXtZT6IBKjAhwux6qOlKLdP3dRVHU,4996
505
- deepeval/tracing/context.py,sha256=v4uzd0N2H8mNntPwZvL49ya2kW9FvjqQqWXJFgE5d0c,5469
504
+ deepeval/tracing/api.py,sha256=x6Ze5ruPDbuRsR8rS0524cvUkCQ7CxLoT0up1gMQWMk,5062
505
+ deepeval/tracing/context.py,sha256=KKP0Wp7zpzTzISyDceI7fndpVnehawI8rBMyRYEwb9U,5580
506
506
  deepeval/tracing/offline_evals/__init__.py,sha256=bEniJAl7PmS9u2ksiOTfHtlCPJ9_CJV5R6umrUOX5MM,102
507
507
  deepeval/tracing/offline_evals/api.py,sha256=eBfqh2uWyeRkIeGhjrN1bTQzAEow-XPubs-42WEZ2QQ,510
508
508
  deepeval/tracing/offline_evals/span.py,sha256=pXqTVXs-WnjRVpCYYEbNe0zSM6Wz9GsKHsM5ZcWxrmM,1802
@@ -514,14 +514,14 @@ deepeval/tracing/otel/test_exporter.py,sha256=bezihPGWJpwUEF3ZghxqhhorocVFTO2b43
514
514
  deepeval/tracing/otel/utils.py,sha256=NVMN07JtxuvVPtdyTW7KFdTqQL3TpoCO-JdZeghQJBY,17859
515
515
  deepeval/tracing/patchers.py,sha256=Oi9wao3oDYhcviv7p0KoWBeS9ne7rHLa2gh9AR9EyiU,6882
516
516
  deepeval/tracing/perf_epoch_bridge.py,sha256=iyAPddB6Op7NpMtPHJ29lDm53Btz9yLaN6xSCfTRQm4,1825
517
- deepeval/tracing/trace_context.py,sha256=Z0n0Cu1A5g9dXiZnzTFO5TzeOYHKeNuO6v3_EU_Gi_c,3568
517
+ deepeval/tracing/trace_context.py,sha256=RkXSlAWuMzuRrvepsM0PlGaWwX7QBstkWv_frYn_7CE,3718
518
518
  deepeval/tracing/trace_test_manager.py,sha256=wt4y7EWTRc4Bw938-UFFtXHkdFFOrnx6JaIk7J5Iulw,555
519
- deepeval/tracing/tracing.py,sha256=ge3XXJkxlmCk5KfrqOOjxXIuA1CIXFOKJxhRTmXRSVQ,46849
520
- deepeval/tracing/types.py,sha256=3QkF0toQ6f0fEDARYOUV6Iv9UJFbg14kSpn3dL1H5CE,6040
519
+ deepeval/tracing/tracing.py,sha256=RS3mBV-63_vDyz-WxYPir34u0BF3mPnAJWee1aCc1sc,46892
520
+ deepeval/tracing/types.py,sha256=PUXDC1JZDaAalPc3uUHywkt2GE2hZ-2ocGP0Fe4sB2E,6120
521
521
  deepeval/tracing/utils.py,sha256=mdvhYAxDNsdnusaEXJd-c-_O2Jn6S3xSuzRvLO1Jz4U,5684
522
522
  deepeval/utils.py,sha256=Wsu95g6t1wdttxWIESVwuUxbml7C-9ZTsV7qHCQI3Xg,27259
523
- deepeval-3.8.2.dist-info/LICENSE.md,sha256=0ATkuLv6QgsJTBODUHC5Rak_PArA6gv2t7inJzNTP38,11352
524
- deepeval-3.8.2.dist-info/METADATA,sha256=SUHVBa7pgBKF2XG3L3c_cItJWvuCdAQxzQSctzeAezQ,18752
525
- deepeval-3.8.2.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
526
- deepeval-3.8.2.dist-info/entry_points.txt,sha256=NoismUQfwLOojSGZmBrdcpwfaoFRAzUhBvZD3UwOKog,95
527
- deepeval-3.8.2.dist-info/RECORD,,
523
+ deepeval-3.8.4.dist-info/LICENSE.md,sha256=0ATkuLv6QgsJTBODUHC5Rak_PArA6gv2t7inJzNTP38,11352
524
+ deepeval-3.8.4.dist-info/METADATA,sha256=F1ZXkRUVi1Ntr1SLLXe-sife_qdnHofOJmSiTFVzIsk,18752
525
+ deepeval-3.8.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
526
+ deepeval-3.8.4.dist-info/entry_points.txt,sha256=NoismUQfwLOojSGZmBrdcpwfaoFRAzUhBvZD3UwOKog,95
527
+ deepeval-3.8.4.dist-info/RECORD,,