langwatch-scenario 0.1.3__py3-none-any.whl → 0.3.0__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.
scenario/result.py DELETED
@@ -1,81 +0,0 @@
1
- """
2
- Result module: defines the class for scenario test results.
3
- """
4
-
5
- from dataclasses import dataclass, field
6
- from typing import List, Dict, Optional
7
-
8
-
9
- @dataclass
10
- class ScenarioResult:
11
- """
12
- Represents the results of a scenario test run.
13
-
14
- Attributes:
15
- success: Whether the scenario passed
16
- conversation: The conversation history
17
- reasoning: Reasoning for the result
18
- met_criteria: List of success criteria that were met
19
- unmet_criteria: List of success criteria that were not met
20
- triggered_failures: List of failure criteria that were triggered
21
- """
22
-
23
- success: bool
24
- conversation: List[Dict[str, str]]
25
- reasoning: Optional[str] = None
26
- met_criteria: List[str] = field(default_factory=list)
27
- unmet_criteria: List[str] = field(default_factory=list)
28
- triggered_failures: List[str] = field(default_factory=list)
29
- total_time: Optional[float] = None
30
- agent_time: Optional[float] = None
31
-
32
- def __post_init__(self) -> None:
33
- """Validate the result after initialization."""
34
- if not self.success and not self.reasoning:
35
- raise ValueError("Failed scenarios must have a reasoning")
36
-
37
- @classmethod
38
- def success_result(
39
- cls,
40
- conversation: List[Dict[str, str]],
41
- reasoning: Optional[str],
42
- met_criteria: List[str],
43
- total_time: Optional[float] = None,
44
- agent_time: Optional[float] = None,
45
- ) -> "ScenarioResult":
46
- """Create a successful result."""
47
- return cls(
48
- success=True,
49
- conversation=conversation,
50
- reasoning=reasoning,
51
- met_criteria=met_criteria,
52
- unmet_criteria=[],
53
- triggered_failures=[],
54
- total_time=total_time,
55
- agent_time=agent_time,
56
- )
57
-
58
- @classmethod
59
- def failure_result(
60
- cls,
61
- conversation: List[Dict[str, str]],
62
- reasoning: str,
63
- met_criteria: Optional[List[str]] = None,
64
- unmet_criteria: Optional[List[str]] = None,
65
- triggered_failures: Optional[List[str]] = None,
66
- total_time: Optional[float] = None,
67
- agent_time: Optional[float] = None,
68
- ) -> "ScenarioResult":
69
- """Create a failed result."""
70
- return cls(
71
- success=False,
72
- conversation=conversation,
73
- reasoning=reasoning,
74
- met_criteria=met_criteria if met_criteria is not None else [],
75
- unmet_criteria=unmet_criteria if unmet_criteria is not None else [],
76
- triggered_failures=(
77
- triggered_failures if triggered_failures is not None else []
78
- ),
79
- total_time=total_time,
80
- agent_time=agent_time,
81
- )