langwatch 0.2.0 → 0.3.0-prerelease.2
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/LICENSE +7 -0
- package/README.md +268 -1
- package/dist/chunk-4BZATFKJ.mjs +181 -0
- package/dist/chunk-4BZATFKJ.mjs.map +1 -0
- package/dist/chunk-CSC3CMIT.mjs +118 -0
- package/dist/chunk-CSC3CMIT.mjs.map +1 -0
- package/dist/chunk-F63YKTXA.mjs +47 -0
- package/dist/chunk-F63YKTXA.mjs.map +1 -0
- package/dist/chunk-G3AUABT7.js +4 -0
- package/dist/chunk-G3AUABT7.js.map +1 -0
- package/dist/chunk-HPC6Z7J4.js +118 -0
- package/dist/chunk-HPC6Z7J4.js.map +1 -0
- package/dist/chunk-KGDAENGD.js +50 -0
- package/dist/chunk-KGDAENGD.js.map +1 -0
- package/dist/chunk-LD74LVRU.js +47 -0
- package/dist/chunk-LD74LVRU.js.map +1 -0
- package/dist/chunk-OM7VY3XT.mjs +4 -0
- package/dist/chunk-PCQVQ7SB.js +45 -0
- package/dist/chunk-PCQVQ7SB.js.map +1 -0
- package/dist/chunk-PMBEK6YE.mjs +424 -0
- package/dist/chunk-PMBEK6YE.mjs.map +1 -0
- package/dist/chunk-PR3JDWC3.mjs +50 -0
- package/dist/chunk-PR3JDWC3.mjs.map +1 -0
- package/dist/chunk-PTJ6AAI7.js +360 -0
- package/dist/chunk-PTJ6AAI7.js.map +1 -0
- package/dist/chunk-QEWDG5QE.mjs +45 -0
- package/dist/chunk-QEWDG5QE.mjs.map +1 -0
- package/dist/chunk-REUCVT7A.mjs +39 -0
- package/dist/chunk-REUCVT7A.mjs.map +1 -0
- package/dist/chunk-SVJ7SCGB.js +424 -0
- package/dist/chunk-SVJ7SCGB.js.map +1 -0
- package/dist/chunk-VJSOCNPA.js +181 -0
- package/dist/chunk-VJSOCNPA.js.map +1 -0
- package/dist/chunk-WM2GRSRW.js +39 -0
- package/dist/chunk-WM2GRSRW.js.map +1 -0
- package/dist/chunk-Z5J5UI5E.mjs +360 -0
- package/dist/chunk-Z5J5UI5E.mjs.map +1 -0
- package/dist/client-B2HqIKg6.d.ts +51 -0
- package/dist/client-XyCqclCi.d.mts +51 -0
- package/dist/client-browser.d.mts +8 -0
- package/dist/client-browser.d.ts +8 -0
- package/dist/client-browser.js +83 -0
- package/dist/client-browser.js.map +1 -0
- package/dist/client-browser.mjs +83 -0
- package/dist/client-browser.mjs.map +1 -0
- package/dist/client-node.d.mts +8 -0
- package/dist/client-node.d.ts +8 -0
- package/dist/client-node.js +90 -0
- package/dist/client-node.js.map +1 -0
- package/dist/client-node.mjs +90 -0
- package/dist/client-node.mjs.map +1 -0
- package/dist/evaluation/index.d.mts +897 -0
- package/dist/evaluation/index.d.ts +897 -0
- package/dist/evaluation/index.js +13 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/index.mjs +13 -0
- package/dist/evaluation/index.mjs.map +1 -0
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.mts +64 -0
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.ts +64 -0
- package/dist/index.d.mts +45 -1027
- package/dist/index.d.ts +45 -1027
- package/dist/index.js +11 -27291
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -956
- package/dist/index.mjs.map +1 -1
- package/dist/observability/index.d.mts +260 -0
- package/dist/observability/index.d.ts +260 -0
- package/dist/observability/index.js +20 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/index.mjs +20 -0
- package/dist/observability/index.mjs.map +1 -0
- package/dist/observability/instrumentation/langchain/index.d.mts +40 -0
- package/dist/observability/instrumentation/langchain/index.d.ts +40 -0
- package/dist/observability/instrumentation/langchain/index.js +666 -0
- package/dist/observability/instrumentation/langchain/index.js.map +1 -0
- package/dist/observability/instrumentation/langchain/index.mjs +666 -0
- package/dist/observability/instrumentation/langchain/index.mjs.map +1 -0
- package/dist/prompt/index.d.mts +10 -0
- package/dist/prompt/index.d.ts +10 -0
- package/dist/prompt/index.js +18 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/index.mjs +18 -0
- package/dist/prompt/index.mjs.map +1 -0
- package/dist/prompt-BXJWdbQp.d.mts +1967 -0
- package/dist/prompt-BXJWdbQp.d.ts +1967 -0
- package/dist/record-evaluation-CmxMXa-3.d.mts +25 -0
- package/dist/record-evaluation-CmxMXa-3.d.ts +25 -0
- package/dist/trace-D-bZOuqb.d.mts +622 -0
- package/dist/trace-G2312klE.d.ts +622 -0
- package/package.json +86 -37
- package/.eslintrc.cjs +0 -37
- package/copy-types.sh +0 -17
- package/dist/chunk-LKD2K67J.mjs +0 -717
- package/dist/chunk-LKD2K67J.mjs.map +0 -1
- package/dist/utils-Cv-rUjJ1.d.mts +0 -313
- package/dist/utils-Cv-rUjJ1.d.ts +0 -313
- package/dist/utils.d.mts +0 -2
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -709
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs +0 -11
- package/example/.env.example +0 -12
- package/example/.eslintrc.json +0 -26
- package/example/LICENSE +0 -13
- package/example/README.md +0 -12
- package/example/app/(chat)/chat/[id]/page.tsx +0 -60
- package/example/app/(chat)/layout.tsx +0 -14
- package/example/app/(chat)/page.tsx +0 -27
- package/example/app/actions.ts +0 -156
- package/example/app/globals.css +0 -76
- package/example/app/guardrails/page.tsx +0 -26
- package/example/app/langchain/page.tsx +0 -27
- package/example/app/langchain-rag/page.tsx +0 -28
- package/example/app/late-update/page.tsx +0 -27
- package/example/app/layout.tsx +0 -64
- package/example/app/login/actions.ts +0 -71
- package/example/app/login/page.tsx +0 -18
- package/example/app/manual/page.tsx +0 -27
- package/example/app/new/page.tsx +0 -5
- package/example/app/opengraph-image.png +0 -0
- package/example/app/share/[id]/page.tsx +0 -58
- package/example/app/signup/actions.ts +0 -111
- package/example/app/signup/page.tsx +0 -18
- package/example/app/twitter-image.png +0 -0
- package/example/auth.config.ts +0 -42
- package/example/auth.ts +0 -45
- package/example/components/button-scroll-to-bottom.tsx +0 -36
- package/example/components/chat-history.tsx +0 -49
- package/example/components/chat-list.tsx +0 -52
- package/example/components/chat-message-actions.tsx +0 -40
- package/example/components/chat-message.tsx +0 -80
- package/example/components/chat-panel.tsx +0 -139
- package/example/components/chat-share-dialog.tsx +0 -95
- package/example/components/chat.tsx +0 -84
- package/example/components/clear-history.tsx +0 -75
- package/example/components/empty-screen.tsx +0 -38
- package/example/components/external-link.tsx +0 -29
- package/example/components/footer.tsx +0 -19
- package/example/components/header.tsx +0 -114
- package/example/components/login-button.tsx +0 -42
- package/example/components/login-form.tsx +0 -97
- package/example/components/markdown.tsx +0 -9
- package/example/components/prompt-form.tsx +0 -115
- package/example/components/providers.tsx +0 -17
- package/example/components/sidebar-actions.tsx +0 -125
- package/example/components/sidebar-desktop.tsx +0 -19
- package/example/components/sidebar-footer.tsx +0 -16
- package/example/components/sidebar-item.tsx +0 -124
- package/example/components/sidebar-items.tsx +0 -42
- package/example/components/sidebar-list.tsx +0 -38
- package/example/components/sidebar-mobile.tsx +0 -31
- package/example/components/sidebar-toggle.tsx +0 -24
- package/example/components/sidebar.tsx +0 -21
- package/example/components/signup-form.tsx +0 -95
- package/example/components/stocks/events-skeleton.tsx +0 -31
- package/example/components/stocks/events.tsx +0 -30
- package/example/components/stocks/index.tsx +0 -36
- package/example/components/stocks/message.tsx +0 -134
- package/example/components/stocks/spinner.tsx +0 -16
- package/example/components/stocks/stock-purchase.tsx +0 -146
- package/example/components/stocks/stock-skeleton.tsx +0 -22
- package/example/components/stocks/stock.tsx +0 -210
- package/example/components/stocks/stocks-skeleton.tsx +0 -9
- package/example/components/stocks/stocks.tsx +0 -67
- package/example/components/tailwind-indicator.tsx +0 -14
- package/example/components/theme-toggle.tsx +0 -31
- package/example/components/ui/alert-dialog.tsx +0 -141
- package/example/components/ui/badge.tsx +0 -36
- package/example/components/ui/button.tsx +0 -57
- package/example/components/ui/codeblock.tsx +0 -148
- package/example/components/ui/dialog.tsx +0 -122
- package/example/components/ui/dropdown-menu.tsx +0 -205
- package/example/components/ui/icons.tsx +0 -507
- package/example/components/ui/input.tsx +0 -25
- package/example/components/ui/label.tsx +0 -26
- package/example/components/ui/select.tsx +0 -164
- package/example/components/ui/separator.tsx +0 -31
- package/example/components/ui/sheet.tsx +0 -140
- package/example/components/ui/sonner.tsx +0 -31
- package/example/components/ui/switch.tsx +0 -29
- package/example/components/ui/textarea.tsx +0 -24
- package/example/components/ui/tooltip.tsx +0 -30
- package/example/components/user-menu.tsx +0 -53
- package/example/components.json +0 -17
- package/example/instrumentation.ts +0 -11
- package/example/lib/chat/guardrails.tsx +0 -181
- package/example/lib/chat/langchain-rag.tsx +0 -191
- package/example/lib/chat/langchain.tsx +0 -112
- package/example/lib/chat/late-update.tsx +0 -208
- package/example/lib/chat/manual.tsx +0 -605
- package/example/lib/chat/vercel-ai.tsx +0 -576
- package/example/lib/hooks/use-copy-to-clipboard.tsx +0 -33
- package/example/lib/hooks/use-enter-submit.tsx +0 -23
- package/example/lib/hooks/use-local-storage.ts +0 -24
- package/example/lib/hooks/use-scroll-anchor.tsx +0 -86
- package/example/lib/hooks/use-sidebar.tsx +0 -60
- package/example/lib/hooks/use-streamable-text.ts +0 -25
- package/example/lib/types.ts +0 -41
- package/example/lib/utils.ts +0 -89
- package/example/middleware.ts +0 -8
- package/example/next-env.d.ts +0 -5
- package/example/next.config.js +0 -16
- package/example/package-lock.json +0 -10917
- package/example/package.json +0 -84
- package/example/pnpm-lock.yaml +0 -5712
- package/example/postcss.config.js +0 -6
- package/example/prettier.config.cjs +0 -34
- package/example/public/apple-touch-icon.png +0 -0
- package/example/public/favicon-16x16.png +0 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/next.svg +0 -1
- package/example/public/thirteen.svg +0 -1
- package/example/public/vercel.svg +0 -1
- package/example/tailwind.config.ts +0 -81
- package/example/tsconfig.json +0 -35
- package/src/LangWatchExporter.ts +0 -96
- package/src/evaluations.ts +0 -219
- package/src/index.test.ts +0 -402
- package/src/index.ts +0 -596
- package/src/langchain.ts +0 -557
- package/src/server/types/.gitkeep +0 -0
- package/src/typeUtils.ts +0 -89
- package/src/types.ts +0 -82
- package/src/utils.ts +0 -205
- package/ts-to-zod.config.js +0 -24
- package/tsconfig.json +0 -32
- package/tsup.config.ts +0 -10
- package/vitest.config.ts +0 -8
- /package/dist/{utils.mjs.map → chunk-OM7VY3XT.mjs.map} +0 -0
package/src/types.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { OpenAI } from "openai";
|
|
2
|
-
import { type SnakeToCamelCaseNested } from "./typeUtils";
|
|
3
|
-
import {
|
|
4
|
-
type BaseSpan as ServerBaseSpan,
|
|
5
|
-
type ChatMessage as ServerChatMessage,
|
|
6
|
-
type ChatRichContent as ServerChatRichContent,
|
|
7
|
-
type LLMSpan as ServerLLMSpan,
|
|
8
|
-
type RAGSpan as ServerRAGSpan,
|
|
9
|
-
type SpanInputOutput as ServerSpanInputOutput,
|
|
10
|
-
type TypedValueChatMessages,
|
|
11
|
-
type Trace as ServerTrace,
|
|
12
|
-
type RESTEvaluation as ServerRESTEvaluation,
|
|
13
|
-
type LLMModeTrace as ServerLLMModeTrace,
|
|
14
|
-
type ErrorCapture as ServerErrorCapture,
|
|
15
|
-
} from "./server/types/tracer";
|
|
16
|
-
|
|
17
|
-
export type Trace = ServerTrace;
|
|
18
|
-
|
|
19
|
-
export type LLMModeTrace = ServerLLMModeTrace;
|
|
20
|
-
|
|
21
|
-
export type Metadata = SnakeToCamelCaseNested<Trace["metadata"]>;
|
|
22
|
-
|
|
23
|
-
export type ChatMessage = ServerChatMessage;
|
|
24
|
-
|
|
25
|
-
export type ChatRichContent = ServerChatRichContent;
|
|
26
|
-
|
|
27
|
-
// Check to see if out ChatMessage type is compatible with OpenAIChatCompletion messages
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
-
({}) as OpenAI.Chat.ChatCompletionMessageParam satisfies ChatMessage;
|
|
30
|
-
// Check to see spans input/output is still compatible with OpenAIChatCompletion messages to avoid camelCase/snake_case issues
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
({}) as {
|
|
33
|
-
type: "chat_messages";
|
|
34
|
-
value: OpenAI.Chat.ChatCompletionMessageParam[];
|
|
35
|
-
} satisfies BaseSpan["input"];
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
({}) as {
|
|
38
|
-
type: "chat_messages";
|
|
39
|
-
value: OpenAI.Chat.ChatCompletionMessageParam[];
|
|
40
|
-
} satisfies BaseSpan["output"];
|
|
41
|
-
|
|
42
|
-
// Keep the input/output types signatures as snake case to match the official openai nodejs api
|
|
43
|
-
export type SpanInputOutput =
|
|
44
|
-
| SnakeToCamelCaseNested<
|
|
45
|
-
Exclude<ServerSpanInputOutput, TypedValueChatMessages>
|
|
46
|
-
>
|
|
47
|
-
| (TypedValueChatMessages & { type: ChatMessage });
|
|
48
|
-
|
|
49
|
-
export type ConvertServerSpan<T extends ServerBaseSpan> =
|
|
50
|
-
SnakeToCamelCaseNested<Omit<T, "input" | "output" | "error">> & {
|
|
51
|
-
input?: SpanInputOutput | null;
|
|
52
|
-
output?: SpanInputOutput | null;
|
|
53
|
-
error?: T["error"] | NonNullable<unknown>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type PendingSpan<T extends BaseSpan> = Omit<
|
|
57
|
-
T,
|
|
58
|
-
"traceId" | "timestamps"
|
|
59
|
-
> & {
|
|
60
|
-
timestamps: Omit<T["timestamps"], "finishedAt"> & {
|
|
61
|
-
finishedAt?: number | null;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type BaseSpan = ConvertServerSpan<ServerBaseSpan>;
|
|
66
|
-
|
|
67
|
-
export type PendingBaseSpan = PendingSpan<BaseSpan>;
|
|
68
|
-
|
|
69
|
-
// vendor is deprecated, and we try to force the available models here
|
|
70
|
-
export type LLMSpan = ConvertServerSpan<
|
|
71
|
-
Omit<ServerLLMSpan, "vendor" | "model">
|
|
72
|
-
> & { model: string };
|
|
73
|
-
export type PendingLLMSpan = PendingSpan<LLMSpan>;
|
|
74
|
-
|
|
75
|
-
export type RAGSpan = ConvertServerSpan<ServerRAGSpan>;
|
|
76
|
-
export type PendingRAGSpan = PendingSpan<RAGSpan>;
|
|
77
|
-
|
|
78
|
-
export type RESTEvaluation = SnakeToCamelCaseNested<
|
|
79
|
-
Omit<ServerRESTEvaluation, "error">
|
|
80
|
-
> & { error?: ServerRESTEvaluation["error"] };
|
|
81
|
-
|
|
82
|
-
export type ErrorCapture = ServerErrorCapture;
|
package/src/utils.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { convertUint8ArrayToBase64 } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { type CoreMessage, type ImagePart } from "ai";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { type ErrorCapture } from "./server/types/tracer";
|
|
5
|
-
import { chatMessageSchema } from "./server/types/tracer.generated";
|
|
6
|
-
import { type ChatMessage, type SpanInputOutput } from "./types";
|
|
7
|
-
|
|
8
|
-
const convertImageToUrl = (
|
|
9
|
-
image: ImagePart["image"],
|
|
10
|
-
mimeType: string | undefined
|
|
11
|
-
) => {
|
|
12
|
-
try {
|
|
13
|
-
return image instanceof URL
|
|
14
|
-
? image.toString()
|
|
15
|
-
: typeof image === "string"
|
|
16
|
-
? image
|
|
17
|
-
: `data:${mimeType ?? "image/jpeg"};base64,${convertUint8ArrayToBase64(
|
|
18
|
-
image as any
|
|
19
|
-
)}`;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.error("[LangWatch] error converting vercel ui image to url:", e);
|
|
22
|
-
return "";
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Mostly copied from https://github.com/vercel/ai/blob/main/packages/openai/src/convert-to-openai-chat-messages.ts
|
|
27
|
-
export function convertFromVercelAIMessages(
|
|
28
|
-
messages: CoreMessage[]
|
|
29
|
-
): ChatMessage[] {
|
|
30
|
-
const lwMessages: ChatMessage[] = [];
|
|
31
|
-
|
|
32
|
-
for (const { role, content } of messages) {
|
|
33
|
-
switch (role) {
|
|
34
|
-
case "system": {
|
|
35
|
-
lwMessages.push({ role: "system", content });
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
case "user": {
|
|
40
|
-
if (
|
|
41
|
-
Array.isArray(content) &&
|
|
42
|
-
content.length === 1 &&
|
|
43
|
-
content[0]?.type === "text"
|
|
44
|
-
) {
|
|
45
|
-
lwMessages.push({ role: "user", content: content[0].text });
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
lwMessages.push({
|
|
50
|
-
role: "user",
|
|
51
|
-
content: Array.isArray(content)
|
|
52
|
-
? content.map((part) => {
|
|
53
|
-
switch (part.type) {
|
|
54
|
-
case "text": {
|
|
55
|
-
return { type: "text", text: part.text };
|
|
56
|
-
}
|
|
57
|
-
case "image": {
|
|
58
|
-
return {
|
|
59
|
-
type: "image_url",
|
|
60
|
-
image_url: {
|
|
61
|
-
url: convertImageToUrl(part.image, part.mimeType),
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
default: {
|
|
66
|
-
return part as any;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
: content,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
case "assistant": {
|
|
77
|
-
let text = "";
|
|
78
|
-
const toolCalls: Array<{
|
|
79
|
-
id: string;
|
|
80
|
-
type: "function";
|
|
81
|
-
function: { name: string; arguments: string };
|
|
82
|
-
}> = [];
|
|
83
|
-
|
|
84
|
-
if (Array.isArray(content)) {
|
|
85
|
-
for (const part of content) {
|
|
86
|
-
switch (part.type) {
|
|
87
|
-
case "text": {
|
|
88
|
-
text += part.text;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "tool-call": {
|
|
92
|
-
toolCalls.push({
|
|
93
|
-
id: part.toolCallId,
|
|
94
|
-
type: "function",
|
|
95
|
-
function: {
|
|
96
|
-
name: part.toolName,
|
|
97
|
-
arguments: JSON.stringify(part.args),
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
default: {
|
|
103
|
-
const _exhaustiveCheck = part;
|
|
104
|
-
throw new Error(`Unsupported part: ${_exhaustiveCheck as any}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
text = content;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
lwMessages.push({
|
|
113
|
-
role: "assistant",
|
|
114
|
-
content: text,
|
|
115
|
-
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
case "tool": {
|
|
122
|
-
for (const toolResponse of content) {
|
|
123
|
-
lwMessages.push({
|
|
124
|
-
role: "tool",
|
|
125
|
-
tool_call_id: toolResponse.toolCallId,
|
|
126
|
-
content: JSON.stringify(toolResponse.result),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
default: {
|
|
133
|
-
const _exhaustiveCheck = role;
|
|
134
|
-
throw new Error(`Unsupported role: ${_exhaustiveCheck as any}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return lwMessages;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export const captureError = (error: unknown): ErrorCapture => {
|
|
143
|
-
if (
|
|
144
|
-
error &&
|
|
145
|
-
typeof error === "object" &&
|
|
146
|
-
"has_error" in error &&
|
|
147
|
-
"message" in error &&
|
|
148
|
-
"stacktrace" in error
|
|
149
|
-
) {
|
|
150
|
-
return error as ErrorCapture;
|
|
151
|
-
} else if (error instanceof Error) {
|
|
152
|
-
return {
|
|
153
|
-
has_error: true,
|
|
154
|
-
message: error.message,
|
|
155
|
-
stacktrace: error.stack ? error.stack.split("\n") : [],
|
|
156
|
-
};
|
|
157
|
-
} else if (typeof error === "object" && error !== null) {
|
|
158
|
-
const err = error as { message: unknown; stack: unknown };
|
|
159
|
-
const message =
|
|
160
|
-
typeof err.message === "string"
|
|
161
|
-
? err.message
|
|
162
|
-
: "An unknown error occurred";
|
|
163
|
-
const stacktrace =
|
|
164
|
-
typeof err.stack === "string"
|
|
165
|
-
? err.stack.split("\n")
|
|
166
|
-
: Array.isArray(err.stack) &&
|
|
167
|
-
err.stack.length > 0 &&
|
|
168
|
-
typeof err.stack[0] === "string"
|
|
169
|
-
? err.stack
|
|
170
|
-
: ["No stack trace available"];
|
|
171
|
-
return {
|
|
172
|
-
has_error: true,
|
|
173
|
-
message,
|
|
174
|
-
stacktrace,
|
|
175
|
-
};
|
|
176
|
-
} else {
|
|
177
|
-
// Handle primitives and other types that are not an error object
|
|
178
|
-
return {
|
|
179
|
-
has_error: true,
|
|
180
|
-
message: String(error),
|
|
181
|
-
stacktrace: [],
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export const autoconvertTypedValues = (value: unknown): SpanInputOutput => {
|
|
187
|
-
if (typeof value === "string") {
|
|
188
|
-
return { type: "text", value };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const chatMessages = z.array(chatMessageSchema).safeParse(value);
|
|
192
|
-
if (Array.isArray(value) && chatMessages.success) {
|
|
193
|
-
return {
|
|
194
|
-
type: "chat_messages",
|
|
195
|
-
value: chatMessages.data,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
JSON.stringify(value);
|
|
201
|
-
return { type: "json", value: value as object };
|
|
202
|
-
} catch (e) {
|
|
203
|
-
return { type: "raw", value: value as any };
|
|
204
|
-
}
|
|
205
|
-
};
|
package/ts-to-zod.config.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ts-to-zod configuration.
|
|
3
|
-
*
|
|
4
|
-
* @type {import("ts-to-zod").TsToZodConfig}
|
|
5
|
-
*/
|
|
6
|
-
module.exports = {
|
|
7
|
-
input: "server/tracer/types.ts",
|
|
8
|
-
output: "server/tracer/types.zod.ts",
|
|
9
|
-
nameFilter: (name) =>
|
|
10
|
-
![
|
|
11
|
-
"ElasticSearchSpan",
|
|
12
|
-
"ElasticSearchInputOutput",
|
|
13
|
-
"EvaluatorDefinition",
|
|
14
|
-
"TraceCheckJob",
|
|
15
|
-
"AnalyticsMetric",
|
|
16
|
-
"NewDatasetEntries",
|
|
17
|
-
"EvaluationRESTParams",
|
|
18
|
-
"EvaluationRESTResult",
|
|
19
|
-
"Json",
|
|
20
|
-
"Literal",
|
|
21
|
-
"DatasetSpan",
|
|
22
|
-
"LLMModeTrace",
|
|
23
|
-
].includes(name),
|
|
24
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"declarationMap": true,
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"allowJs": true,
|
|
12
|
-
"checkJs": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"isolatedModules": true,
|
|
17
|
-
"jsx": "preserve",
|
|
18
|
-
"incremental": true,
|
|
19
|
-
"noUncheckedIndexedAccess": true,
|
|
20
|
-
"baseUrl": ".",
|
|
21
|
-
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
".eslintrc.cjs",
|
|
25
|
-
"next-env.d.ts",
|
|
26
|
-
"**/*.ts",
|
|
27
|
-
"**/*.tsx",
|
|
28
|
-
"**/*.cjs",
|
|
29
|
-
"**/*.mjs"
|
|
30
|
-
],
|
|
31
|
-
"exclude": ["node_modules", "./dist/**/*", "./example/**/*"]
|
|
32
|
-
}
|
package/tsup.config.ts
DELETED
package/vitest.config.ts
DELETED
|
File without changes
|