langsmith 0.3.87 → 0.4.0

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 (52) hide show
  1. package/README.md +0 -50
  2. package/dist/client.cjs +52 -31
  3. package/dist/client.d.ts +2 -9
  4. package/dist/client.js +53 -32
  5. package/dist/evaluation/_runner.cjs +34 -32
  6. package/dist/evaluation/_runner.js +35 -33
  7. package/dist/experimental/otel/setup.cjs +2 -0
  8. package/dist/experimental/otel/setup.d.ts +2 -0
  9. package/dist/experimental/otel/setup.js +2 -0
  10. package/dist/experimental/vercel/index.d.ts +11 -0
  11. package/dist/experimental/vercel/middleware.cjs +15 -4
  12. package/dist/experimental/vercel/middleware.d.ts +1 -0
  13. package/dist/experimental/vercel/middleware.js +15 -4
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/singletons/constants.cjs +2 -1
  18. package/dist/singletons/constants.d.ts +1 -0
  19. package/dist/singletons/constants.js +1 -0
  20. package/dist/traceable.cjs +107 -43
  21. package/dist/traceable.js +108 -44
  22. package/dist/utils/error.cjs +33 -1
  23. package/dist/utils/error.d.ts +13 -0
  24. package/dist/utils/error.js +30 -0
  25. package/dist/utils/jestlike/index.cjs +1 -1
  26. package/dist/utils/jestlike/index.js +1 -1
  27. package/dist/utils/jestlike/types.d.ts +0 -4
  28. package/package.json +1 -40
  29. package/dist/evaluation/langchain.cjs +0 -54
  30. package/dist/evaluation/langchain.d.ts +0 -21
  31. package/dist/evaluation/langchain.js +0 -51
  32. package/dist/utils/vercel.types.cjs +0 -2
  33. package/dist/utils/vercel.types.d.ts +0 -1
  34. package/dist/utils/vercel.types.js +0 -1
  35. package/dist/vercel.cjs +0 -866
  36. package/dist/vercel.d.ts +0 -87
  37. package/dist/vercel.js +0 -861
  38. package/dist/wrappers/vercel.cjs +0 -101
  39. package/dist/wrappers/vercel.d.ts +0 -31
  40. package/dist/wrappers/vercel.js +0 -97
  41. package/evaluation/langchain.cjs +0 -1
  42. package/evaluation/langchain.d.cts +0 -1
  43. package/evaluation/langchain.d.ts +0 -1
  44. package/evaluation/langchain.js +0 -1
  45. package/vercel.cjs +0 -1
  46. package/vercel.d.cts +0 -1
  47. package/vercel.d.ts +0 -1
  48. package/vercel.js +0 -1
  49. package/wrappers/vercel.cjs +0 -1
  50. package/wrappers/vercel.d.cts +0 -1
  51. package/wrappers/vercel.d.ts +0 -1
  52. package/wrappers/vercel.js +0 -1
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapAISDKModel = void 0;
4
- const traceable_js_1 = require("../traceable.cjs");
5
- const generic_js_1 = require("./generic.cjs");
6
- /**
7
- * @deprecated Use `wrapAISDK` from `langsmith/experimental/vercel` instead.
8
- * Wrap a Vercel AI SDK model, enabling automatic LangSmith tracing.
9
- * After wrapping a model, you can use it with the Vercel AI SDK Core
10
- * methods as normal.
11
- *
12
- * @example
13
- * ```ts
14
- * import { anthropic } from "@ai-sdk/anthropic";
15
- * import { streamText } from "ai";
16
- * import { wrapAISDKModel } from "langsmith/wrappers/vercel";
17
- *
18
- * const anthropicModel = anthropic("claude-3-haiku-20240307");
19
- *
20
- * const modelWithTracing = wrapAISDKModel(anthropicModel);
21
- *
22
- * const { textStream } = await streamText({
23
- * model: modelWithTracing,
24
- * prompt: "Write a vegetarian lasagna recipe for 4 people.",
25
- * });
26
- *
27
- * for await (const chunk of textStream) {
28
- * console.log(chunk);
29
- * }
30
- * ```
31
- * @param model An AI SDK model instance.
32
- * @param options LangSmith options.
33
- * @returns
34
- */
35
- const wrapAISDKModel = (model, options) => {
36
- if (!("doStream" in model) ||
37
- typeof model.doStream !== "function" ||
38
- !("doGenerate" in model) ||
39
- typeof model.doGenerate !== "function") {
40
- throw new Error(`Received invalid input. This version of wrapAISDKModel only supports Vercel LanguageModelV1 instances.`);
41
- }
42
- const runName = options?.name ?? model.constructor?.name;
43
- return new Proxy(model, {
44
- get(target, propKey, receiver) {
45
- const originalValue = target[propKey];
46
- if (typeof originalValue === "function") {
47
- let __finalTracedIteratorKey;
48
- let aggregator;
49
- if (propKey === "doStream") {
50
- __finalTracedIteratorKey = "stream";
51
- aggregator = (chunks) => {
52
- return chunks.reduce((aggregated, chunk) => {
53
- if (chunk.type === "text-delta") {
54
- return {
55
- ...aggregated,
56
- text: aggregated.text + chunk.textDelta,
57
- };
58
- }
59
- else if (chunk.type === "tool-call") {
60
- return {
61
- ...aggregated,
62
- ...chunk,
63
- };
64
- }
65
- else if (chunk.type === "finish") {
66
- return {
67
- ...aggregated,
68
- usage: chunk.usage,
69
- finishReason: chunk.finishReason,
70
- };
71
- }
72
- else {
73
- return aggregated;
74
- }
75
- }, {
76
- text: "",
77
- });
78
- };
79
- }
80
- return (0, traceable_js_1.traceable)(originalValue.bind(target), {
81
- run_type: "llm",
82
- name: runName,
83
- ...options,
84
- __finalTracedIteratorKey,
85
- aggregator,
86
- });
87
- }
88
- else if (originalValue != null &&
89
- !Array.isArray(originalValue) &&
90
- // eslint-disable-next-line no-instanceof/no-instanceof
91
- !(originalValue instanceof Date) &&
92
- typeof originalValue === "object") {
93
- return (0, generic_js_1._wrapClient)(originalValue, [runName, propKey.toString()].join("."), options);
94
- }
95
- else {
96
- return Reflect.get(target, propKey, receiver);
97
- }
98
- },
99
- });
100
- };
101
- exports.wrapAISDKModel = wrapAISDKModel;
@@ -1,31 +0,0 @@
1
- import type { RunTreeConfig } from "../index.js";
2
- /**
3
- * @deprecated Use `wrapAISDK` from `langsmith/experimental/vercel` instead.
4
- * Wrap a Vercel AI SDK model, enabling automatic LangSmith tracing.
5
- * After wrapping a model, you can use it with the Vercel AI SDK Core
6
- * methods as normal.
7
- *
8
- * @example
9
- * ```ts
10
- * import { anthropic } from "@ai-sdk/anthropic";
11
- * import { streamText } from "ai";
12
- * import { wrapAISDKModel } from "langsmith/wrappers/vercel";
13
- *
14
- * const anthropicModel = anthropic("claude-3-haiku-20240307");
15
- *
16
- * const modelWithTracing = wrapAISDKModel(anthropicModel);
17
- *
18
- * const { textStream } = await streamText({
19
- * model: modelWithTracing,
20
- * prompt: "Write a vegetarian lasagna recipe for 4 people.",
21
- * });
22
- *
23
- * for await (const chunk of textStream) {
24
- * console.log(chunk);
25
- * }
26
- * ```
27
- * @param model An AI SDK model instance.
28
- * @param options LangSmith options.
29
- * @returns
30
- */
31
- export declare const wrapAISDKModel: <T extends object>(model: T, options?: Partial<RunTreeConfig>) => T;
@@ -1,97 +0,0 @@
1
- import { traceable } from "../traceable.js";
2
- import { _wrapClient } from "./generic.js";
3
- /**
4
- * @deprecated Use `wrapAISDK` from `langsmith/experimental/vercel` instead.
5
- * Wrap a Vercel AI SDK model, enabling automatic LangSmith tracing.
6
- * After wrapping a model, you can use it with the Vercel AI SDK Core
7
- * methods as normal.
8
- *
9
- * @example
10
- * ```ts
11
- * import { anthropic } from "@ai-sdk/anthropic";
12
- * import { streamText } from "ai";
13
- * import { wrapAISDKModel } from "langsmith/wrappers/vercel";
14
- *
15
- * const anthropicModel = anthropic("claude-3-haiku-20240307");
16
- *
17
- * const modelWithTracing = wrapAISDKModel(anthropicModel);
18
- *
19
- * const { textStream } = await streamText({
20
- * model: modelWithTracing,
21
- * prompt: "Write a vegetarian lasagna recipe for 4 people.",
22
- * });
23
- *
24
- * for await (const chunk of textStream) {
25
- * console.log(chunk);
26
- * }
27
- * ```
28
- * @param model An AI SDK model instance.
29
- * @param options LangSmith options.
30
- * @returns
31
- */
32
- export const wrapAISDKModel = (model, options) => {
33
- if (!("doStream" in model) ||
34
- typeof model.doStream !== "function" ||
35
- !("doGenerate" in model) ||
36
- typeof model.doGenerate !== "function") {
37
- throw new Error(`Received invalid input. This version of wrapAISDKModel only supports Vercel LanguageModelV1 instances.`);
38
- }
39
- const runName = options?.name ?? model.constructor?.name;
40
- return new Proxy(model, {
41
- get(target, propKey, receiver) {
42
- const originalValue = target[propKey];
43
- if (typeof originalValue === "function") {
44
- let __finalTracedIteratorKey;
45
- let aggregator;
46
- if (propKey === "doStream") {
47
- __finalTracedIteratorKey = "stream";
48
- aggregator = (chunks) => {
49
- return chunks.reduce((aggregated, chunk) => {
50
- if (chunk.type === "text-delta") {
51
- return {
52
- ...aggregated,
53
- text: aggregated.text + chunk.textDelta,
54
- };
55
- }
56
- else if (chunk.type === "tool-call") {
57
- return {
58
- ...aggregated,
59
- ...chunk,
60
- };
61
- }
62
- else if (chunk.type === "finish") {
63
- return {
64
- ...aggregated,
65
- usage: chunk.usage,
66
- finishReason: chunk.finishReason,
67
- };
68
- }
69
- else {
70
- return aggregated;
71
- }
72
- }, {
73
- text: "",
74
- });
75
- };
76
- }
77
- return traceable(originalValue.bind(target), {
78
- run_type: "llm",
79
- name: runName,
80
- ...options,
81
- __finalTracedIteratorKey,
82
- aggregator,
83
- });
84
- }
85
- else if (originalValue != null &&
86
- !Array.isArray(originalValue) &&
87
- // eslint-disable-next-line no-instanceof/no-instanceof
88
- !(originalValue instanceof Date) &&
89
- typeof originalValue === "object") {
90
- return _wrapClient(originalValue, [runName, propKey.toString()].join("."), options);
91
- }
92
- else {
93
- return Reflect.get(target, propKey, receiver);
94
- }
95
- },
96
- });
97
- };
@@ -1 +0,0 @@
1
- module.exports = require('../dist/evaluation/langchain.cjs');
@@ -1 +0,0 @@
1
- export * from '../dist/evaluation/langchain.js'
@@ -1 +0,0 @@
1
- export * from '../dist/evaluation/langchain.js'
@@ -1 +0,0 @@
1
- export * from '../dist/evaluation/langchain.js'
package/vercel.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/vercel.cjs');
package/vercel.d.cts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/vercel.js'
package/vercel.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/vercel.js'
package/vercel.js DELETED
@@ -1 +0,0 @@
1
- export * from './dist/vercel.js'
@@ -1 +0,0 @@
1
- module.exports = require('../dist/wrappers/vercel.cjs');
@@ -1 +0,0 @@
1
- export * from '../dist/wrappers/vercel.js'
@@ -1 +0,0 @@
1
- export * from '../dist/wrappers/vercel.js'
@@ -1 +0,0 @@
1
- export * from '../dist/wrappers/vercel.js'