@arizeai/phoenix-evals 0.0.4 → 0.0.6

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 (59) hide show
  1. package/README.md +98 -0
  2. package/dist/esm/llm/createClassifier.d.ts.map +1 -1
  3. package/dist/esm/llm/createClassifier.js +2 -1
  4. package/dist/esm/llm/createClassifier.js.map +1 -1
  5. package/dist/esm/llm/createHallucinationEvaluator.d.ts.map +1 -1
  6. package/dist/esm/llm/createHallucinationEvaluator.js +2 -1
  7. package/dist/esm/llm/createHallucinationEvaluator.js.map +1 -1
  8. package/dist/esm/llm/generateClassification.d.ts +2 -1
  9. package/dist/esm/llm/generateClassification.d.ts.map +1 -1
  10. package/dist/esm/llm/generateClassification.js +8 -1
  11. package/dist/esm/llm/generateClassification.js.map +1 -1
  12. package/dist/esm/telemetry/index.d.ts +2 -0
  13. package/dist/esm/telemetry/index.d.ts.map +1 -0
  14. package/dist/esm/telemetry/index.js +3 -0
  15. package/dist/esm/telemetry/index.js.map +1 -0
  16. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  17. package/dist/esm/types/evals.d.ts +2 -4
  18. package/dist/esm/types/evals.d.ts.map +1 -1
  19. package/dist/esm/types/index.d.ts +1 -0
  20. package/dist/esm/types/index.d.ts.map +1 -1
  21. package/dist/esm/types/index.js +1 -0
  22. package/dist/esm/types/index.js.map +1 -1
  23. package/dist/esm/types/otel.d.ts +17 -0
  24. package/dist/esm/types/otel.d.ts.map +1 -0
  25. package/dist/esm/types/otel.js +2 -0
  26. package/dist/esm/types/otel.js.map +1 -0
  27. package/dist/src/llm/createClassifier.d.ts.map +1 -1
  28. package/dist/src/llm/createClassifier.js +13 -6
  29. package/dist/src/llm/createClassifier.js.map +1 -1
  30. package/dist/src/llm/createHallucinationEvaluator.d.ts.map +1 -1
  31. package/dist/src/llm/createHallucinationEvaluator.js +14 -3
  32. package/dist/src/llm/createHallucinationEvaluator.js.map +1 -1
  33. package/dist/src/llm/generateClassification.d.ts +2 -1
  34. package/dist/src/llm/generateClassification.d.ts.map +1 -1
  35. package/dist/src/llm/generateClassification.js +9 -2
  36. package/dist/src/llm/generateClassification.js.map +1 -1
  37. package/dist/src/telemetry/index.d.ts +2 -0
  38. package/dist/src/telemetry/index.d.ts.map +1 -0
  39. package/dist/src/telemetry/index.js +6 -0
  40. package/dist/src/telemetry/index.js.map +1 -0
  41. package/dist/src/types/evals.d.ts +2 -4
  42. package/dist/src/types/evals.d.ts.map +1 -1
  43. package/dist/src/types/index.d.ts +1 -0
  44. package/dist/src/types/index.d.ts.map +1 -1
  45. package/dist/src/types/index.js +1 -0
  46. package/dist/src/types/index.js.map +1 -1
  47. package/dist/src/types/otel.d.ts +17 -0
  48. package/dist/src/types/otel.d.ts.map +1 -0
  49. package/dist/src/types/otel.js +3 -0
  50. package/dist/src/types/otel.js.map +1 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +5 -3
  53. package/src/llm/createClassifier.ts +2 -1
  54. package/src/llm/createHallucinationEvaluator.ts +2 -0
  55. package/src/llm/generateClassification.ts +12 -3
  56. package/src/telemetry/index.ts +3 -0
  57. package/src/types/evals.ts +3 -2
  58. package/src/types/index.ts +1 -0
  59. package/src/types/otel.ts +17 -0
@@ -1 +1 @@
1
- {"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,UAAU,EAAE,SAAS;IACnD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB,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CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB,CAAC,UAAU,EAAE,SAAS,CACtD,SAAQ,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,EAC3C,OAAO;CAAG;AAEd;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAIzD,KAAK,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,wBAAwB,CAAC;IAClC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,CAAC,UAAU,EAAE,SAAS,IAAI,CAC/C,IAAI,EAAE,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,KACxC,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./evals.js";
2
2
  export * from "./templating.js";
3
+ export * from "./otel.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./evals.js";
2
2
  export * from "./templating.js";
3
+ export * from "./otel.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Tracer } from "@opentelemetry/api";
2
+ export interface WithTelemetry {
3
+ telemetry?: {
4
+ /**
5
+ * Whether OpenTelemetry is enabled on the call.
6
+ * Defaults to true for visibility into the evals calls.
7
+ * @default true
8
+ */
9
+ isEnabled?: boolean;
10
+ /**
11
+ * The tracer to use for the call.
12
+ * If not provided, the traces will get picked up by the global tracer.
13
+ */
14
+ tracer?: Tracer;
15
+ };
16
+ }
17
+ //# sourceMappingURL=otel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE;QACV;;;;WAIG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=otel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"createClassifier.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,EACpD,IAAI,EAAE,oBAAoB,GACzB,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CA6BpC"}
1
+ {"version":3,"file":"createClassifier.d.ts","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAkBxB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,EACpD,IAAI,EAAE,oBAAoB,GACzB,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CA8BpC"}
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.createClassifier = createClassifier;
4
15
  const generateClassification_1 = require("./generateClassification");
@@ -18,18 +29,14 @@ function choicesToLabels(choices) {
18
29
  * A function that serves as a factory that will output a classification evaluator
19
30
  */
20
31
  function createClassifier(args) {
21
- const { model, choices, promptTemplate } = args;
32
+ const { model, choices, promptTemplate } = args, rest = __rest(args, ["model", "choices", "promptTemplate"]);
22
33
  return async (args) => {
23
34
  const templateVariables = Object.assign({}, args);
24
35
  const prompt = (0, template_1.formatTemplate)({
25
36
  template: promptTemplate,
26
37
  variables: templateVariables,
27
38
  });
28
- const classification = await (0, generateClassification_1.generateClassification)({
29
- model,
30
- labels: choicesToLabels(choices),
31
- prompt,
32
- });
39
+ const classification = await (0, generateClassification_1.generateClassification)(Object.assign({ model, labels: choicesToLabels(choices), prompt }, rest));
33
40
  // Post-process the classification result and map it to the choices
34
41
  const score = choices[classification.label];
35
42
  return Object.assign({ score }, classification);
@@ -1 +1 @@
1
- {"version":3,"file":"createClassifier.js","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":";;AA2BA,4CA+BC;AAnDD,qEAAkE;AAClE,0CAA6C;AAE7C;;;GAGG;AACH,SAAS,eAAe,CACtB,OAAiC;IAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAA+B,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,IAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAEhD,OAAO,KAAK,EACV,IAA2C,EAChB,EAAE;QAC7B,MAAM,iBAAiB,qBAClB,IAAI,CACR,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC;YAC5B,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE,iBAAiB;SAC7B,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,IAAA,+CAAsB,EAAC;YAClD,KAAK;YACL,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC;YAChC,MAAM;SACP,CAAC,CAAC;QAEH,mEAAmE;QACnE,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAE5C,uBACE,KAAK,IACF,cAAc,EACjB;IACJ,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"createClassifier.js","sourceRoot":"","sources":["../../../src/llm/createClassifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA2BA,4CAgCC;AApDD,qEAAkE;AAClE,0CAA6C;AAE7C;;;GAGG;AACH,SAAS,eAAe,CACtB,OAAiC;IAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAA+B,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,IAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,KAAc,IAAI,EAAb,IAAI,UAAK,IAAI,EAAlD,sCAA2C,CAAO,CAAC;IAEzD,OAAO,KAAK,EACV,IAA2C,EAChB,EAAE;QAC7B,MAAM,iBAAiB,qBAClB,IAAI,CACR,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC;YAC5B,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE,iBAAiB;SAC7B,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,IAAA,+CAAsB,kBACjD,KAAK,EACL,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,EAChC,MAAM,IACH,IAAI,EACP,CAAC;QAEH,mEAAmE;QACnE,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAE5C,uBACE,KAAK,IACF,cAAc,EACjB;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMnE,UAAU,0BACR,SAAQ,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChE,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CACzD;AACD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAW7B"}
1
+ {"version":3,"file":"createHallucinationEvaluator.d.ts","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMnE,UAAU,0BACR,SAAQ,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChE,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CACzD;AACD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAa7B"}
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.createHallucinationEvaluator = createHallucinationEvaluator;
4
15
  const createClassifier_1 = require("./createClassifier");
@@ -10,9 +21,9 @@ const HALLUCINATION_TEMPLATE_1 = require("../default_templates/HALLUCINATION_TEM
10
21
  * @returns A function that evaluates whether an answer is factual or hallucinated based on a query and reference text.
11
22
  */
12
23
  function createHallucinationEvaluator(args) {
13
- const { choices = HALLUCINATION_TEMPLATE_1.HALLUCINATION_CHOICES, promptTemplate = HALLUCINATION_TEMPLATE_1.HALLUCINATION_TEMPLATE, } = args;
14
- const hallucinationEvaluatorFn = (0, createClassifier_1.createClassifier)(Object.assign(Object.assign({}, args), { promptTemplate,
15
- choices }));
24
+ const { choices = HALLUCINATION_TEMPLATE_1.HALLUCINATION_CHOICES, promptTemplate = HALLUCINATION_TEMPLATE_1.HALLUCINATION_TEMPLATE } = args, rest = __rest(args, ["choices", "promptTemplate"]);
25
+ const hallucinationEvaluatorFn = (0, createClassifier_1.createClassifier)(Object.assign(Object.assign(Object.assign({}, args), { promptTemplate,
26
+ choices }), rest));
16
27
  return hallucinationEvaluatorFn;
17
28
  }
18
29
  //# sourceMappingURL=createHallucinationEvaluator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;AAkBA,oEAaC;AA/BD,yDAAsD;AAEtD,wFAGqD;AAOrD;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,IAAgC;IAEhC,MAAM,EACJ,OAAO,GAAG,8CAAqB,EAC/B,cAAc,GAAG,+CAAsB,GACxC,GAAG,IAAI,CAAC;IACT,MAAM,wBAAwB,GAAG,IAAA,mCAAgB,kCAC5C,IAAI,KACP,cAAc;QACd,OAAO,IACP,CAAC;IACH,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"createHallucinationEvaluator.js","sourceRoot":"","sources":["../../../src/llm/createHallucinationEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAkBA,oEAeC;AAjCD,yDAAsD;AAEtD,wFAGqD;AAOrD;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,IAAgC;IAEhC,MAAM,EACJ,OAAO,GAAG,8CAAqB,EAC/B,cAAc,GAAG,+CAAsB,KAErC,IAAI,EADH,IAAI,UACL,IAAI,EAJF,6BAIL,CAAO,CAAC;IACT,MAAM,wBAAwB,GAAG,IAAA,mCAAgB,gDAC5C,IAAI,KACP,cAAc;QACd,OAAO,KACJ,IAAI,EACP,CAAC;IACH,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { ClassificationResult, WithLLM } from "../types/evals";
2
+ import { WithTelemetry } from "../types/otel";
2
3
  import type { WithPrompt } from "../types/prompts";
3
- interface ClassifyArgs extends WithLLM, WithPrompt {
4
+ interface ClassifyArgs extends WithLLM, WithPrompt, WithTelemetry {
4
5
  /**
5
6
  * The labels to classify the example into. E.x. ["correct", "incorrect"]
6
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"generateClassification.d.ts","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,UAAU,YAAa,SAAQ,OAAO,EAAE,UAAU;IAChD;;OAEG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AACD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAiB/B"}
1
+ {"version":3,"file":"generateClassification.d.ts","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,UAAU,YAAa,SAAQ,OAAO,EAAE,UAAU,EAAE,aAAa;IAC/D;;OAEG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AACD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
@@ -14,17 +14,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.generateClassification = generateClassification;
15
15
  const ai_1 = require("ai");
16
16
  const zod_1 = require("zod");
17
+ const telemetry_1 = require("../telemetry");
17
18
  /**
18
19
  * A function that leverages an llm to perform a classification
19
20
  */
20
21
  async function generateClassification(args) {
21
- const { labels, model, schemaName, schemaDescription } = args, prompt = __rest(args, ["labels", "model", "schemaName", "schemaDescription"]);
22
+ var _a, _b;
23
+ const { labels, model, schemaName, schemaDescription, telemetry } = args, prompt = __rest(args, ["labels", "model", "schemaName", "schemaDescription", "telemetry"]);
24
+ const experimental_telemetry = {
25
+ isEnabled: (_a = telemetry === null || telemetry === void 0 ? void 0 : telemetry.isEnabled) !== null && _a !== void 0 ? _a : true,
26
+ functionId: "generateClassification",
27
+ tracer: (_b = telemetry === null || telemetry === void 0 ? void 0 : telemetry.tracer) !== null && _b !== void 0 ? _b : telemetry_1.tracer,
28
+ };
22
29
  const result = await (0, ai_1.generateObject)(Object.assign({ model,
23
30
  schemaName,
24
31
  schemaDescription, schema: zod_1.z.object({
25
32
  explanation: zod_1.z.string(), // We place the explanation in hopes it uses reasoning to explain the label.
26
33
  label: zod_1.z.enum(labels),
27
- }) }, prompt));
34
+ }), experimental_telemetry }, prompt));
28
35
  return {
29
36
  label: result.object.label,
30
37
  explanation: result.object.explanation,
@@ -1 +1 @@
1
- {"version":3,"file":"generateClassification.js","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAsBA,wDAmBC;AAvCD,2BAAoC;AACpC,6BAAwB;AAgBxB;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,IAAkB;IAElB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,KAAgB,IAAI,EAAf,MAAM,UAAK,IAAI,EAAlE,sDAA2D,CAAO,CAAC;IAEzE,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAc,kBACjC,KAAK;QACL,UAAU;QACV,iBAAiB,EACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,4EAA4E;YACrG,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SACtB,CAAC,IACC,MAAM,EACT,CAAC;IACH,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;KACvC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"generateClassification.js","sourceRoot":"","sources":["../../../src/llm/generateClassification.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAuBA,wDA2BC;AA/CD,2BAAoC;AACpC,6BAAwB;AACxB,4CAAsC;AAetC;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,IAAkB;;IAElB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,KAC7D,IAAI,EAD8D,MAAM,UACxE,IAAI,EADA,mEAAsE,CACtE,CAAC;IAEP,MAAM,sBAAsB,GAAG;QAC7B,SAAS,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,mCAAI,IAAI;QACvC,UAAU,EAAE,wBAAwB;QACpC,MAAM,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,mCAAI,kBAAM;KACpC,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAc,kBACjC,KAAK;QACL,UAAU;QACV,iBAAiB,EACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,4EAA4E;YACrG,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SACtB,CAAC,EACF,sBAAsB,IACnB,MAAM,EACT,CAAC;IACH,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;KACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const tracer: import("@opentelemetry/api").Tracer;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,qCAAmC,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tracer = void 0;
4
+ const api_1 = require("@opentelemetry/api");
5
+ exports.tracer = api_1.trace.getTracer("phoenix-evals");
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":";;;AAAA,4CAA2C;AAE9B,QAAA,MAAM,GAAG,WAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { LanguageModel } from "ai";
2
+ import { WithTelemetry } from "./otel";
2
3
  /**
3
4
  * The arguments for an evaluation
4
5
  */
@@ -54,10 +55,7 @@ export type ClassificationChoicesMap = Record<string, number>;
54
55
  /**
55
56
  * The arguments for creating a classification-based evaluator
56
57
  */
57
- export interface CreateClassifierArgs {
58
- /**
59
- * The LLM to use for classification / evaluation
60
- */
58
+ export interface CreateClassifierArgs extends WithTelemetry {
61
59
  model: LanguageModel;
62
60
  /**
63
61
  * The choices to classify the example into.
@@ -1 +1 @@
1
- {"version":3,"file":"evals.d.ts","sourceRoot":"","sources":["../../../src/types/evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,UAAU,EAAE,SAAS;IACnD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB,CAAC,UAAU,EAAE,SAAS,CACtD,SAAQ,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,EAC3C,OAAO;CAAG;AAEd;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK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;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAIzD,KAAK,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,wBAAwB,CAAC;IAClC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,CAAC,UAAU,EAAE,SAAS,IAAI,CAC/C,IAAI,EAAE,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,KACxC,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./evals";
2
2
  export * from "./templating";
3
+ export * from "./otel";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./evals"), exports);
18
18
  __exportStar(require("./templating"), exports);
19
+ __exportStar(require("./otel"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B;AAC7B,yCAAuB"}
@@ -0,0 +1,17 @@
1
+ import { Tracer } from "@opentelemetry/api";
2
+ export interface WithTelemetry {
3
+ telemetry?: {
4
+ /**
5
+ * Whether OpenTelemetry is enabled on the call.
6
+ * Defaults to true for visibility into the evals calls.
7
+ * @default true
8
+ */
9
+ isEnabled?: boolean;
10
+ /**
11
+ * The tracer to use for the call.
12
+ * If not provided, the traces will get picked up by the global tracer.
13
+ */
14
+ tracer?: Tracer;
15
+ };
16
+ }
17
+ //# sourceMappingURL=otel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE;QACV;;;;WAIG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=otel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../../../src/types/otel.ts"],"names":[],"mappings":""}