@arizeai/phoenix-evals 2.7.0 → 2.7.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-evals",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "A library for running evaluations for AI use cases",
5
5
  "keywords": [
6
6
  "arize",
@@ -66,19 +66,19 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "@ai-sdk/otel": "1.0.137",
70
- "@arizeai/openinference-core": "^2.8.0",
71
- "@opentelemetry/api": "^1.9.1",
72
- "ai": "7.0.137",
69
+ "@ai-sdk/otel": "1.0.152",
70
+ "@arizeai/openinference-core": "^2.8.1",
71
+ "@opentelemetry/api": "^1.10.0",
72
+ "ai": "7.0.152",
73
73
  "jsonpath-plus": "^10.4.0",
74
74
  "mustache": "^4.2.0",
75
75
  "zod": "^4.6.7"
76
76
  },
77
77
  "devDependencies": {
78
- "@ai-sdk/google": "^4.0.99",
79
- "@ai-sdk/openai": "^4.0.96",
80
- "@ai-sdk/typesafe-ai": "^3.0.21",
81
- "@arizeai/openinference-instrumentation-openai": "^4.4.1",
78
+ "@ai-sdk/google": "^4.0.104",
79
+ "@ai-sdk/openai": "^4.0.101",
80
+ "@ai-sdk/typesafe-ai": "^3.0.26",
81
+ "@arizeai/openinference-instrumentation-openai": "^4.4.2",
82
82
  "@opentelemetry/sdk-trace-node": "^2.12.0",
83
83
  "@types/mustache": "^4.2.6",
84
84
  "@types/node": "^26.6.5",
@@ -53,6 +53,27 @@ function resultHasExplanation(
53
53
  );
54
54
  }
55
55
 
56
+ /**
57
+ * Type guard to check if a value has a metadata property.
58
+ *
59
+ * @param result - The value to check
60
+ * @returns True if the value is an object with a metadata record
61
+ *
62
+ * @internal
63
+ */
64
+ function resultHasMetadata(
65
+ result: unknown
66
+ ): result is { metadata: Record<string, unknown> } {
67
+ return (
68
+ typeof result === "object" &&
69
+ result !== null &&
70
+ "metadata" in result &&
71
+ typeof result.metadata === "object" &&
72
+ result.metadata !== null &&
73
+ !Array.isArray(result.metadata)
74
+ );
75
+ }
76
+
56
77
  /**
57
78
  * Converts an unknown value to an {@link EvaluationResult}.
58
79
  *
@@ -62,7 +83,7 @@ function resultHasExplanation(
62
83
  *
63
84
  * - **Numbers**: Converted to `{ score: number }`
64
85
  * - **Strings**: Converted to `{ label: string }`
65
- * - **Objects**: Extracts `score`, `label`, and `explanation` properties if present
86
+ * - **Objects**: Extracts `score`, `label`, `explanation`, and `metadata` properties if present
66
87
  * - **Other types**: Returns an empty `EvaluationResult` object
67
88
  *
68
89
  * This is particularly useful when creating evaluators from functions that may
@@ -71,7 +92,7 @@ function resultHasExplanation(
71
92
  * @param result - The value to convert to an EvaluationResult. Can be:
72
93
  * - A number (converted to score)
73
94
  * - A string (converted to label)
74
- * - An object with optional `score`, `label`, and/or `explanation` properties
95
+ * - An object with optional `score`, `label`, `explanation`, and/or `metadata` properties
75
96
  * - Any other value (returns empty object)
76
97
  *
77
98
  * @returns An {@link EvaluationResult} object with extracted properties
@@ -91,7 +112,7 @@ function resultHasExplanation(
91
112
  * ```
92
113
  *
93
114
  * @example
94
- * Convert an object with all properties:
115
+ * Convert an object with multiple properties:
95
116
  * ```typescript
96
117
  * const result = toEvaluationResult({
97
118
  * score: 0.9,
@@ -139,6 +160,9 @@ export function toEvaluationResult(result: unknown): EvaluationResult {
139
160
  if (resultHasExplanation(result)) {
140
161
  evaluationResult.explanation = result.explanation;
141
162
  }
163
+ if (resultHasMetadata(result)) {
164
+ evaluationResult.metadata = result.metadata;
165
+ }
142
166
  return evaluationResult;
143
167
  }
144
168
  return {};