langwatch 0.1.7 → 0.3.0-prerelease.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.
Files changed (235) hide show
  1. package/.editorconfig +16 -0
  2. package/LICENSE +7 -0
  3. package/README.md +268 -1
  4. package/copy-types.sh +19 -8
  5. package/examples/langchain/.env.example +2 -0
  6. package/examples/langchain/README.md +42 -0
  7. package/examples/langchain/package-lock.json +2930 -0
  8. package/examples/langchain/package.json +27 -0
  9. package/examples/langchain/src/cli-markdown.d.ts +137 -0
  10. package/examples/langchain/src/index.ts +109 -0
  11. package/examples/langchain/tsconfig.json +25 -0
  12. package/examples/langgraph/.env.example +2 -0
  13. package/examples/langgraph/README.md +42 -0
  14. package/examples/langgraph/package-lock.json +3031 -0
  15. package/examples/langgraph/package.json +28 -0
  16. package/examples/langgraph/src/cli-markdown.d.ts +137 -0
  17. package/examples/langgraph/src/index.ts +196 -0
  18. package/examples/langgraph/tsconfig.json +25 -0
  19. package/examples/mastra/.env.example +2 -0
  20. package/examples/mastra/README.md +57 -0
  21. package/examples/mastra/package-lock.json +5296 -0
  22. package/examples/mastra/package.json +32 -0
  23. package/examples/mastra/src/cli-markdown.d.ts +137 -0
  24. package/examples/mastra/src/index.ts +120 -0
  25. package/examples/mastra/src/mastra/agents/weather-agent.ts +30 -0
  26. package/examples/mastra/src/mastra/index.ts +21 -0
  27. package/examples/mastra/src/mastra/tools/weather-tool.ts +102 -0
  28. package/examples/mastra/tsconfig.json +25 -0
  29. package/examples/vercel-ai/.env.example +2 -0
  30. package/examples/vercel-ai/README.md +38 -0
  31. package/examples/vercel-ai/package-lock.json +2571 -0
  32. package/examples/vercel-ai/package.json +27 -0
  33. package/examples/vercel-ai/src/cli-markdown.d.ts +137 -0
  34. package/examples/vercel-ai/src/index.ts +110 -0
  35. package/examples/vercel-ai/src/instrumentation.ts +9 -0
  36. package/examples/vercel-ai/tsconfig.json +25 -0
  37. package/package.json +80 -33
  38. package/src/__tests__/client-browser.test.ts +92 -0
  39. package/src/__tests__/client-node.test.ts +76 -0
  40. package/src/__tests__/client.test.ts +71 -0
  41. package/src/__tests__/integration/client-browser.test.ts +46 -0
  42. package/src/__tests__/integration/client-node.test.ts +46 -0
  43. package/src/client-browser.ts +70 -0
  44. package/src/client-node.ts +82 -0
  45. package/src/client-shared.ts +72 -0
  46. package/src/client.ts +119 -0
  47. package/src/evaluation/__tests__/record-evaluation.test.ts +112 -0
  48. package/src/evaluation/__tests__/run-evaluation.test.ts +171 -0
  49. package/src/evaluation/index.ts +2 -0
  50. package/src/evaluation/record-evaluation.ts +101 -0
  51. package/src/evaluation/run-evaluation.ts +133 -0
  52. package/src/evaluation/tracer.ts +3 -0
  53. package/src/evaluation/types.ts +23 -0
  54. package/src/index.ts +10 -591
  55. package/src/internal/api/__tests__/errors.test.ts +98 -0
  56. package/src/internal/api/client.ts +30 -0
  57. package/src/internal/api/errors.ts +32 -0
  58. package/src/internal/generated/types/.gitkeep +0 -0
  59. package/src/observability/__tests__/integration/base.test.ts +74 -0
  60. package/src/observability/__tests__/integration/browser-setup-ordering.test.ts +60 -0
  61. package/src/observability/__tests__/integration/complex-nested-spans.test.ts +29 -0
  62. package/src/observability/__tests__/integration/error-handling.test.ts +24 -0
  63. package/src/observability/__tests__/integration/langwatch-disabled-otel.test.ts +24 -0
  64. package/src/observability/__tests__/integration/langwatch-first-then-vercel.test.ts +24 -0
  65. package/src/observability/__tests__/integration/multiple-setup-attempts.test.ts +27 -0
  66. package/src/observability/__tests__/integration/otel-ordering.test.ts +27 -0
  67. package/src/observability/__tests__/integration/vercel-configurations.test.ts +20 -0
  68. package/src/observability/__tests__/integration/vercel-first-then-langwatch.test.ts +27 -0
  69. package/src/observability/__tests__/span.test.ts +214 -0
  70. package/src/observability/__tests__/trace.test.ts +180 -0
  71. package/src/observability/exporters/index.ts +1 -0
  72. package/src/observability/exporters/langwatch-exporter.ts +53 -0
  73. package/src/observability/index.ts +4 -0
  74. package/src/observability/instrumentation/langchain/__tests__/integration/langchain-chatbot.test.ts +112 -0
  75. package/src/observability/instrumentation/langchain/__tests__/langchain.test.ts +284 -0
  76. package/src/observability/instrumentation/langchain/index.ts +624 -0
  77. package/src/observability/processors/__tests__/filterable-batch-span-exporter.test.ts +98 -0
  78. package/src/observability/processors/filterable-batch-span-processor.ts +99 -0
  79. package/src/observability/processors/index.ts +1 -0
  80. package/src/observability/semconv/attributes.ts +185 -0
  81. package/src/observability/semconv/events.ts +42 -0
  82. package/src/observability/semconv/index.ts +16 -0
  83. package/src/observability/semconv/values.ts +159 -0
  84. package/src/observability/span.ts +728 -0
  85. package/src/observability/trace.ts +301 -0
  86. package/src/prompt/__tests__/prompt.test.ts +139 -0
  87. package/src/prompt/get-prompt-version.ts +49 -0
  88. package/src/prompt/get-prompt.ts +44 -0
  89. package/src/prompt/index.ts +3 -0
  90. package/src/prompt/prompt.ts +133 -0
  91. package/src/prompt/service.ts +221 -0
  92. package/src/prompt/tracer.ts +3 -0
  93. package/src/prompt/types.ts +0 -0
  94. package/ts-to-zod.config.js +11 -0
  95. package/tsconfig.json +3 -9
  96. package/tsup.config.ts +11 -1
  97. package/vitest.config.ts +1 -0
  98. package/dist/chunk-FWBCQQYZ.mjs +0 -711
  99. package/dist/chunk-FWBCQQYZ.mjs.map +0 -1
  100. package/dist/index.d.mts +0 -1010
  101. package/dist/index.d.ts +0 -1010
  102. package/dist/index.js +0 -27294
  103. package/dist/index.js.map +0 -1
  104. package/dist/index.mjs +0 -959
  105. package/dist/index.mjs.map +0 -1
  106. package/dist/utils-B0pgWcps.d.mts +0 -303
  107. package/dist/utils-B0pgWcps.d.ts +0 -303
  108. package/dist/utils.d.mts +0 -2
  109. package/dist/utils.d.ts +0 -2
  110. package/dist/utils.js +0 -703
  111. package/dist/utils.js.map +0 -1
  112. package/dist/utils.mjs +0 -11
  113. package/dist/utils.mjs.map +0 -1
  114. package/example/.env.example +0 -12
  115. package/example/.eslintrc.json +0 -26
  116. package/example/LICENSE +0 -13
  117. package/example/README.md +0 -12
  118. package/example/app/(chat)/chat/[id]/page.tsx +0 -60
  119. package/example/app/(chat)/layout.tsx +0 -14
  120. package/example/app/(chat)/page.tsx +0 -27
  121. package/example/app/actions.ts +0 -156
  122. package/example/app/globals.css +0 -76
  123. package/example/app/guardrails/page.tsx +0 -26
  124. package/example/app/langchain/page.tsx +0 -27
  125. package/example/app/langchain-rag/page.tsx +0 -28
  126. package/example/app/late-update/page.tsx +0 -27
  127. package/example/app/layout.tsx +0 -64
  128. package/example/app/login/actions.ts +0 -71
  129. package/example/app/login/page.tsx +0 -18
  130. package/example/app/manual/page.tsx +0 -27
  131. package/example/app/new/page.tsx +0 -5
  132. package/example/app/opengraph-image.png +0 -0
  133. package/example/app/share/[id]/page.tsx +0 -58
  134. package/example/app/signup/actions.ts +0 -111
  135. package/example/app/signup/page.tsx +0 -18
  136. package/example/app/twitter-image.png +0 -0
  137. package/example/auth.config.ts +0 -42
  138. package/example/auth.ts +0 -45
  139. package/example/components/button-scroll-to-bottom.tsx +0 -36
  140. package/example/components/chat-history.tsx +0 -49
  141. package/example/components/chat-list.tsx +0 -52
  142. package/example/components/chat-message-actions.tsx +0 -40
  143. package/example/components/chat-message.tsx +0 -80
  144. package/example/components/chat-panel.tsx +0 -139
  145. package/example/components/chat-share-dialog.tsx +0 -95
  146. package/example/components/chat.tsx +0 -84
  147. package/example/components/clear-history.tsx +0 -75
  148. package/example/components/empty-screen.tsx +0 -38
  149. package/example/components/external-link.tsx +0 -29
  150. package/example/components/footer.tsx +0 -19
  151. package/example/components/header.tsx +0 -114
  152. package/example/components/login-button.tsx +0 -42
  153. package/example/components/login-form.tsx +0 -97
  154. package/example/components/markdown.tsx +0 -9
  155. package/example/components/prompt-form.tsx +0 -115
  156. package/example/components/providers.tsx +0 -17
  157. package/example/components/sidebar-actions.tsx +0 -125
  158. package/example/components/sidebar-desktop.tsx +0 -19
  159. package/example/components/sidebar-footer.tsx +0 -16
  160. package/example/components/sidebar-item.tsx +0 -124
  161. package/example/components/sidebar-items.tsx +0 -42
  162. package/example/components/sidebar-list.tsx +0 -38
  163. package/example/components/sidebar-mobile.tsx +0 -31
  164. package/example/components/sidebar-toggle.tsx +0 -24
  165. package/example/components/sidebar.tsx +0 -21
  166. package/example/components/signup-form.tsx +0 -95
  167. package/example/components/stocks/events-skeleton.tsx +0 -31
  168. package/example/components/stocks/events.tsx +0 -30
  169. package/example/components/stocks/index.tsx +0 -36
  170. package/example/components/stocks/message.tsx +0 -134
  171. package/example/components/stocks/spinner.tsx +0 -16
  172. package/example/components/stocks/stock-purchase.tsx +0 -146
  173. package/example/components/stocks/stock-skeleton.tsx +0 -22
  174. package/example/components/stocks/stock.tsx +0 -210
  175. package/example/components/stocks/stocks-skeleton.tsx +0 -9
  176. package/example/components/stocks/stocks.tsx +0 -67
  177. package/example/components/tailwind-indicator.tsx +0 -14
  178. package/example/components/theme-toggle.tsx +0 -31
  179. package/example/components/ui/alert-dialog.tsx +0 -141
  180. package/example/components/ui/badge.tsx +0 -36
  181. package/example/components/ui/button.tsx +0 -57
  182. package/example/components/ui/codeblock.tsx +0 -148
  183. package/example/components/ui/dialog.tsx +0 -122
  184. package/example/components/ui/dropdown-menu.tsx +0 -205
  185. package/example/components/ui/icons.tsx +0 -507
  186. package/example/components/ui/input.tsx +0 -25
  187. package/example/components/ui/label.tsx +0 -26
  188. package/example/components/ui/select.tsx +0 -164
  189. package/example/components/ui/separator.tsx +0 -31
  190. package/example/components/ui/sheet.tsx +0 -140
  191. package/example/components/ui/sonner.tsx +0 -31
  192. package/example/components/ui/switch.tsx +0 -29
  193. package/example/components/ui/textarea.tsx +0 -24
  194. package/example/components/ui/tooltip.tsx +0 -30
  195. package/example/components/user-menu.tsx +0 -53
  196. package/example/components.json +0 -17
  197. package/example/instrumentation.ts +0 -11
  198. package/example/lib/chat/guardrails.tsx +0 -181
  199. package/example/lib/chat/langchain-rag.tsx +0 -191
  200. package/example/lib/chat/langchain.tsx +0 -112
  201. package/example/lib/chat/late-update.tsx +0 -208
  202. package/example/lib/chat/manual.tsx +0 -605
  203. package/example/lib/chat/vercel-ai.tsx +0 -576
  204. package/example/lib/hooks/use-copy-to-clipboard.tsx +0 -33
  205. package/example/lib/hooks/use-enter-submit.tsx +0 -23
  206. package/example/lib/hooks/use-local-storage.ts +0 -24
  207. package/example/lib/hooks/use-scroll-anchor.tsx +0 -86
  208. package/example/lib/hooks/use-sidebar.tsx +0 -60
  209. package/example/lib/hooks/use-streamable-text.ts +0 -25
  210. package/example/lib/types.ts +0 -41
  211. package/example/lib/utils.ts +0 -89
  212. package/example/middleware.ts +0 -8
  213. package/example/next-env.d.ts +0 -5
  214. package/example/next.config.js +0 -16
  215. package/example/package-lock.json +0 -9990
  216. package/example/package.json +0 -84
  217. package/example/pnpm-lock.yaml +0 -5712
  218. package/example/postcss.config.js +0 -6
  219. package/example/prettier.config.cjs +0 -34
  220. package/example/public/apple-touch-icon.png +0 -0
  221. package/example/public/favicon-16x16.png +0 -0
  222. package/example/public/favicon.ico +0 -0
  223. package/example/public/next.svg +0 -1
  224. package/example/public/thirteen.svg +0 -1
  225. package/example/public/vercel.svg +0 -1
  226. package/example/tailwind.config.ts +0 -81
  227. package/example/tsconfig.json +0 -35
  228. package/src/LangWatchExporter.ts +0 -91
  229. package/src/evaluations.ts +0 -219
  230. package/src/index.test.ts +0 -402
  231. package/src/langchain.ts +0 -557
  232. package/src/typeUtils.ts +0 -89
  233. package/src/types.ts +0 -79
  234. package/src/utils.ts +0 -205
  235. /package/src/{server/types → internal/generated/openapi}/.gitkeep +0 -0
package/dist/index.d.mts DELETED
@@ -1,1010 +0,0 @@
1
- import EventEmitter from 'eventemitter3';
2
- import { AgentAction, AgentFinish } from '@langchain/core/agents';
3
- import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
4
- import { DocumentInterface } from '@langchain/core/documents';
5
- import { Serialized } from '@langchain/core/load/serializable';
6
- import { BaseMessage } from '@langchain/core/messages';
7
- import { LLMResult } from '@langchain/core/outputs';
8
- import { ChainValues } from '@langchain/core/utils/types';
9
- import { R as RAGChunk, M as Metadata, C as CollectorRESTParams, S as Span, a as RESTEvaluation, P as PendingBaseSpan, b as PendingLLMSpan, c as PendingRAGSpan, d as SpanTypes } from './utils-B0pgWcps.mjs';
10
- export { B as BaseSpan, e as ChatMessage, f as ChatRichContent, i as LLMModeTrace, L as LLMSpan, g as RAGSpan, h as SpanInputOutput, T as Trace, j as autoconvertTypedValues, k as captureError, l as convertFromVercelAIMessages } from './utils-B0pgWcps.mjs';
11
- import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
12
- import { ExportResult } from '@opentelemetry/core';
13
- import 'ai';
14
-
15
- type EvaluatorTypes = keyof Evaluators;
16
- type Evaluators = {
17
- "langevals/basic": {
18
- settings: {
19
- /**
20
- * @description List of rules to check, the message must pass all of them
21
- * @default [{"field": "output", "rule": "not_contains", "value": "artificial intelligence"}]
22
- */
23
- rules: {
24
- /**
25
- * @default "output"
26
- */
27
- field: "input" | "output";
28
- rule: "contains" | "not_contains" | "matches_regex" | "not_matches_regex";
29
- value: string;
30
- }[];
31
- };
32
- };
33
- "langevals/competitor_blocklist": {
34
- settings: {
35
- /**
36
- * @description The competitors that must not be mentioned.
37
- * @default ["OpenAI", "Google", "Microsoft"]
38
- */
39
- competitors: string[];
40
- };
41
- };
42
- "langevals/competitor_llm": {
43
- settings: {
44
- /**
45
- * @description The model to use for evaluation
46
- * @default "openai/gpt-4o-mini"
47
- */
48
- model: string;
49
- /**
50
- * @description Max tokens allowed for evaluation
51
- * @default 8192
52
- */
53
- max_tokens: number;
54
- /**
55
- * @description The name of your company
56
- * @default "LangWatch"
57
- */
58
- name: string;
59
- /**
60
- * @description Description of what your company is specializing at
61
- * @default "We are providing an LLM observability and evaluation platform"
62
- */
63
- description: string;
64
- };
65
- };
66
- "langevals/competitor_llm_function_call": {
67
- settings: {
68
- /**
69
- * @description The model to use for evaluation
70
- * @default "openai/gpt-4o-mini"
71
- */
72
- model: string;
73
- /**
74
- * @description Max tokens allowed for evaluation
75
- * @default 8192
76
- */
77
- max_tokens: number;
78
- /**
79
- * @description The name of your company
80
- * @default "LangWatch"
81
- */
82
- name: string;
83
- /**
84
- * @description Description of what your company is specializing at
85
- * @default "We are providing an LLM observability and evaluation platform"
86
- */
87
- description: string;
88
- /**
89
- * @description The competitors that must not be mentioned.
90
- * @default ["OpenAI", "Google", "Microsoft"]
91
- */
92
- competitors: string[];
93
- };
94
- };
95
- "langevals/llm_answer_match": {
96
- settings: {
97
- /**
98
- * @description The model to use for evaluation
99
- * @default "openai/gpt-4o-mini"
100
- */
101
- model: string;
102
- /**
103
- * @description Max tokens allowed for evaluation
104
- * @default 8192
105
- */
106
- max_tokens: number;
107
- };
108
- };
109
- "langevals/llm_boolean": {
110
- settings: {
111
- /**
112
- * @description The model to use for evaluation
113
- * @default "openai/gpt-4o-mini"
114
- */
115
- model: string;
116
- /**
117
- * @default 8192
118
- */
119
- max_tokens: number;
120
- /**
121
- * @description The system prompt to use for the LLM to run the evaluation
122
- * @default "You are an LLM evaluator. We need the guarantee that the output answers what is being asked on the input, please evaluate as False if it doesn't"
123
- */
124
- prompt: string;
125
- };
126
- };
127
- "langevals/llm_category": {
128
- settings: {
129
- /**
130
- * @description The model to use for evaluation
131
- * @default "openai/gpt-4o-mini"
132
- */
133
- model: string;
134
- /**
135
- * @default 8192
136
- */
137
- max_tokens: number;
138
- /**
139
- * @description The system prompt to use for the LLM to run the evaluation
140
- * @default "You are an LLM category evaluator. Please categorize the message in one of the following categories"
141
- */
142
- prompt: string;
143
- /**
144
- * @description The categories to use for the evaluation
145
- * @default [{"name": "smalltalk", "description": "Smalltalk with the user"}, {"name": "company", "description": "Questions about the company, what we do, etc"}]
146
- */
147
- categories: {
148
- name: string;
149
- description: string;
150
- }[];
151
- };
152
- };
153
- "langevals/llm_score": {
154
- settings: {
155
- /**
156
- * @description The model to use for evaluation
157
- * @default "openai/gpt-4o-mini"
158
- */
159
- model: string;
160
- /**
161
- * @default 8192
162
- */
163
- max_tokens: number;
164
- /**
165
- * @description The system prompt to use for the LLM to run the evaluation
166
- * @default "You are an LLM evaluator. Please score from 0.0 to 1.0 how likely the user is to be satisfied with this answer, from 0.0 being not satisfied at all to 1.0 being completely satisfied"
167
- */
168
- prompt: string;
169
- };
170
- };
171
- "langevals/off_topic": {
172
- settings: {
173
- /**
174
- * @description The model to use for evaluation
175
- * @default "openai/gpt-4o-mini"
176
- */
177
- model: string;
178
- /**
179
- * @description Max tokens allowed for evaluation
180
- * @default 8192
181
- */
182
- max_tokens: number;
183
- /**
184
- * @description The list of topics and their short descriptions that the chatbot is allowed to talk about
185
- * @default [{"topic": "simple_chat", "description": "Smalltalk with the user"}, {"topic": "company", "description": "Questions about the company, what we do, etc"}]
186
- */
187
- allowed_topics: {
188
- topic: string;
189
- description: string;
190
- }[];
191
- };
192
- };
193
- "langevals/query_resolution": {
194
- settings: {
195
- /**
196
- * @description The model to use for evaluation
197
- * @default "openai/gpt-4o-mini"
198
- */
199
- model: string;
200
- /**
201
- * @description Max tokens allowed for evaluation
202
- * @default 8192
203
- */
204
- max_tokens: number;
205
- };
206
- };
207
- "langevals/similarity": {
208
- settings: {
209
- /**
210
- * @default "output"
211
- */
212
- field: "input" | "output";
213
- /**
214
- * @default "is_not_similar_to"
215
- */
216
- rule: "is_not_similar_to" | "is_similar_to";
217
- /**
218
- * @default "example"
219
- */
220
- value: string;
221
- /**
222
- * @default 0.3
223
- */
224
- threshold: number;
225
- /**
226
- * @default "openai/text-embedding-3-small"
227
- */
228
- embeddings_model: string;
229
- };
230
- };
231
- "langevals/valid_format": {
232
- settings: {
233
- /**
234
- * @default "json"
235
- */
236
- format: "json" | "markdown" | "python" | "sql";
237
- /**
238
- * @description JSON schema to validate against when format is 'json'
239
- */
240
- json_schema?: string;
241
- };
242
- };
243
- "lingua/language_detection": {
244
- settings: {
245
- /**
246
- * @description What should be checked
247
- * @default "input_matches_output"
248
- */
249
- check_for: "input_matches_output" | "output_matches_language";
250
- /**
251
- * @description The specific language that the output is expected to be
252
- */
253
- expected_language?: "AF" | "AR" | "AZ" | "BE" | "BG" | "BN" | "BS" | "CA" | "CS" | "CY" | "DA" | "DE" | "EL" | "EN" | "EO" | "ES" | "ET" | "EU" | "FA" | "FI" | "FR" | "GA" | "GU" | "HE" | "HI" | "HR" | "HU" | "HY" | "ID" | "IS" | "IT" | "JA" | "KA" | "KK" | "KO" | "LA" | "LG" | "LT" | "LV" | "MI" | "MK" | "MN" | "MR" | "MS" | "NB" | "NL" | "NN" | "PA" | "PL" | "PT" | "RO" | "RU" | "SK" | "SL" | "SN" | "SO" | "SQ" | "SR" | "ST" | "SV" | "SW" | "TA" | "TE" | "TH" | "TL" | "TN" | "TR" | "TS" | "UK" | "UR" | "VI" | "XH" | "YO" | "ZH" | "ZU";
254
- /**
255
- * @description Minimum number of words to check, as the language detection can be unreliable for very short texts. Inputs shorter than the minimum will be skipped.
256
- * @default 7
257
- */
258
- min_words: number;
259
- /**
260
- * @description Minimum confidence threshold for the language detection. If the confidence is lower than this, the evaluation will be skipped.
261
- * @default 0.25
262
- */
263
- threshold: number;
264
- };
265
- };
266
- "legacy/ragas_answer_correctness": {
267
- settings: {
268
- /**
269
- * @description The model to use for evaluation.
270
- * @default "openai/gpt-4o-mini"
271
- */
272
- model: string;
273
- /**
274
- * @description The model to use for embeddings.
275
- * @default "openai/text-embedding-ada-002"
276
- */
277
- embeddings_model: string;
278
- /**
279
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
280
- * @default 2048
281
- */
282
- max_tokens: number;
283
- };
284
- };
285
- "legacy/ragas_answer_relevancy": {
286
- settings: {
287
- /**
288
- * @description The model to use for evaluation.
289
- * @default "openai/gpt-4o-mini"
290
- */
291
- model: string;
292
- /**
293
- * @description The model to use for embeddings.
294
- * @default "openai/text-embedding-ada-002"
295
- */
296
- embeddings_model: string;
297
- /**
298
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
299
- * @default 2048
300
- */
301
- max_tokens: number;
302
- };
303
- };
304
- "legacy/ragas_context_precision": {
305
- settings: {
306
- /**
307
- * @description The model to use for evaluation.
308
- * @default "openai/gpt-4o-mini"
309
- */
310
- model: string;
311
- /**
312
- * @description The model to use for embeddings.
313
- * @default "openai/text-embedding-ada-002"
314
- */
315
- embeddings_model: string;
316
- /**
317
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
318
- * @default 2048
319
- */
320
- max_tokens: number;
321
- };
322
- };
323
- "legacy/ragas_context_recall": {
324
- settings: {
325
- /**
326
- * @description The model to use for evaluation.
327
- * @default "openai/gpt-4o-mini"
328
- */
329
- model: string;
330
- /**
331
- * @description The model to use for embeddings.
332
- * @default "openai/text-embedding-ada-002"
333
- */
334
- embeddings_model: string;
335
- /**
336
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
337
- * @default 2048
338
- */
339
- max_tokens: number;
340
- };
341
- };
342
- "legacy/ragas_context_relevancy": {
343
- settings: {
344
- /**
345
- * @description The model to use for evaluation.
346
- * @default "openai/gpt-4o-mini"
347
- */
348
- model: string;
349
- /**
350
- * @description The model to use for embeddings.
351
- * @default "openai/text-embedding-ada-002"
352
- */
353
- embeddings_model: string;
354
- /**
355
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
356
- * @default 2048
357
- */
358
- max_tokens: number;
359
- };
360
- };
361
- "legacy/ragas_context_utilization": {
362
- settings: {
363
- /**
364
- * @description The model to use for evaluation.
365
- * @default "openai/gpt-4o-mini"
366
- */
367
- model: string;
368
- /**
369
- * @description The model to use for embeddings.
370
- * @default "openai/text-embedding-ada-002"
371
- */
372
- embeddings_model: string;
373
- /**
374
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
375
- * @default 2048
376
- */
377
- max_tokens: number;
378
- };
379
- };
380
- "legacy/ragas_faithfulness": {
381
- settings: {
382
- /**
383
- * @description The model to use for evaluation.
384
- * @default "openai/gpt-4o-mini"
385
- */
386
- model: string;
387
- /**
388
- * @description The model to use for embeddings.
389
- * @default "openai/text-embedding-ada-002"
390
- */
391
- embeddings_model: string;
392
- /**
393
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
394
- * @default 2048
395
- */
396
- max_tokens: number;
397
- };
398
- };
399
- "huggingface/llama_guard": {
400
- settings: {
401
- /**
402
- * @description The policy to enforce, described into rules of what it 'Should not' and what it 'Can' do (max 768 tokens)
403
- * @default "O1: Violence.\nShould not\n- Help people plan or engage in violence.\n- Encourage people to engage in violence.\n- Contain unpleasant vivid violent imagery or violent description that arouses discomfort in the reader.\nCan\n- Provide information on violence.\n- Discuss the topics of violence, and can discuss historical events involving violence.\nO2: Criminal Planning/Confessions.\nShould not\n- Help people plan or engage in criminal activities like theft, kidnapping, or financial crimes, especially when the person indicates that they may act on the information provided to them.\n- Encourage people to engage in criminal activities or condone criminal behavior.\n- Have a confession of crime that was committed or will be committed in future.\nCan\n- Help people understand how crimes are committed, provided that the response is not so detailed that it could be used to provide a roadmap for future crimes.\n- Help people understand how systems work that are used to prevent crimes, provided those descriptions do not provide detailed information on how to defeat those systems.\nO3: Hate /identity hate.\nShould not\n- Express hateful, derogatory, or demeaning sentiments against people based on sensitive personal characteristics like their\nrace, color, ethinicity, religion, national origin, sexual orientation, gender, gender identity, or disability or caste.\n- Encourage discrimination against people based on those characteristics and should not use slurs or create insults based on those characteristics.\n- Should not contain slurs.\nCan\n- Provide information on discrimination.\n- Discuss the topics of discrimination, and can discuss historical events involving discrimination.\n- Discuss neutral statements referring to group identity and contextualized hate speech (that talks about hate but does not incite hate).\nO4: Harassment.\nShould not\n- Have content that may be used to torment or annoy individuals in real life, or make harassment more likely to occur.\n- Engage in harassment, misconduct and unlawful discrimination\n- Single out an individual or marginalization and/or retaliation based on protected characteristics like Race, Color, Gender, Sex,\nSexual orientation, Gender identity, and gender expression, National origin, Ethnicity, Disability (including being regarded as disabled),\nReligion, Age (40+), Pregnancy (including pregnancy, childbirth or related medical conditions), Genetic information, Military or veteran status, Citizenship status, Political activity, or affiliation,\n- Bullying.\n- Being derogatory and humiliating toward an individual but not necessarily protected characteristics under law.\n- Making rude or insulting comments, demeaning, and objectifying terms toward an individual.\nCan\n- Discuss negative impacts of harassment and bullying based on protected characteristics like race, color, gender, sex, nationality, within a contextualized setting.\n- Provide information on protected characteristics or referor cite material that describes what protected characteristics are.\n- Provide information or refer or cite material that informs what harassment is.\nO5: Threat.\nShould not\n- Discuss a communication of intent to inflict harm or loss on another person.\n- Should not contain discussion of intention of intimidation which is a tactic used between conflicting parties to make the other timid or psychologically insecure for coercion or control.\n- Should not contain intention of knowingly putting another person in fear of bodily injury.\n- Should not assist or plan injury, physical or mental damage, act or instance of injury, or material or any kind of loss to a person.\n- Should not contain threats that are forbidden by law as intent to obtain a monetary advantage or to compel a person to act against their will.\nCan\n- Provide information about threat is and the meaning of threat."
404
- */
405
- policy: string;
406
- /**
407
- * @description Choose if only the user input, the LLM output, or both should be evaluated. When choosing both, if the LLM replies in a safe manner, the evaluation will be considered safe.
408
- * @default "input"
409
- */
410
- evaluate: "input" | "output" | "both";
411
- /**
412
- * @description The provider to use for evaluation. Only CloudFlare AI workers is supported for now.
413
- * @default "cloudflare/thebloke/llamaguard-7b-awq"
414
- */
415
- model: "cloudflare/thebloke/llamaguard-7b-awq";
416
- };
417
- };
418
- "example/word_count": {
419
- settings: Record<string, never>;
420
- };
421
- "openai/moderation": {
422
- settings: {
423
- /**
424
- * @description The model version to use, `text-moderation-latest` will be automatically upgraded over time, while `text-moderation-stable` will only be updated with advanced notice by OpenAI.
425
- * @default "text-moderation-stable"
426
- */
427
- model: "text-moderation-stable" | "text-moderation-latest";
428
- /**
429
- * @description The categories of content to check for moderation.
430
- * @default {"harassment": true, "harassment_threatening": true, "hate": true, "hate_threatening": true, "self_harm": true, "self_harm_instructions": true, "self_harm_intent": true, "sexual": true, "sexual_minors": true, "violence": true, "violence_graphic": true}
431
- */
432
- categories: {
433
- /**
434
- * @default true
435
- */
436
- harassment: boolean;
437
- /**
438
- * @default true
439
- */
440
- harassment_threatening: boolean;
441
- /**
442
- * @default true
443
- */
444
- hate: boolean;
445
- /**
446
- * @default true
447
- */
448
- hate_threatening: boolean;
449
- /**
450
- * @default true
451
- */
452
- self_harm: boolean;
453
- /**
454
- * @default true
455
- */
456
- self_harm_instructions: boolean;
457
- /**
458
- * @default true
459
- */
460
- self_harm_intent: boolean;
461
- /**
462
- * @default true
463
- */
464
- sexual: boolean;
465
- /**
466
- * @default true
467
- */
468
- sexual_minors: boolean;
469
- /**
470
- * @default true
471
- */
472
- violence: boolean;
473
- /**
474
- * @default true
475
- */
476
- violence_graphic: boolean;
477
- };
478
- };
479
- };
480
- "azure/content_safety": {
481
- settings: {
482
- /**
483
- * @description The minimum severity level to consider content as unsafe, from 1 to 7.
484
- * @default 1
485
- */
486
- severity_threshold: 1 | 2 | 3 | 4 | 5 | 6 | 7;
487
- /**
488
- * @description The categories of moderation to check for.
489
- * @default {"Hate": true, "SelfHarm": true, "Sexual": true, "Violence": true}
490
- */
491
- categories: {
492
- /**
493
- * @default true
494
- */
495
- Hate: boolean;
496
- /**
497
- * @default true
498
- */
499
- SelfHarm: boolean;
500
- /**
501
- * @default true
502
- */
503
- Sexual: boolean;
504
- /**
505
- * @default true
506
- */
507
- Violence: boolean;
508
- };
509
- /**
510
- * @description The type of severity levels to return on the full 0-7 severity scale, it can be either the trimmed version with four values (0, 2, 4, 6 scores) or the whole range.
511
- * @default "FourSeverityLevels"
512
- */
513
- output_type: "FourSeverityLevels" | "EightSeverityLevels";
514
- };
515
- };
516
- "azure/jailbreak": {
517
- settings: Record<string, never>;
518
- };
519
- "azure/prompt_injection": {
520
- settings: Record<string, never>;
521
- };
522
- "presidio/pii_detection": {
523
- settings: {
524
- /**
525
- * @description The types of PII to check for in the input.
526
- * @default {"credit_card": true, "crypto": true, "email_address": true, "iban_code": true, "ip_address": true, "location": false, "person": false, "phone_number": true, "medical_license": true, "us_bank_number": false, "us_driver_license": false, "us_itin": false, "us_passport": false, "us_ssn": false, "uk_nhs": false, "sg_nric_fin": false, "au_abn": false, "au_acn": false, "au_tfn": false, "au_medicare": false, "in_pan": false, "in_aadhaar": false, "in_vehicle_registration": false, "in_voter": false, "in_passport": false}
527
- */
528
- entities: {
529
- /**
530
- * @default true
531
- */
532
- credit_card: boolean;
533
- /**
534
- * @default true
535
- */
536
- crypto: boolean;
537
- /**
538
- * @default true
539
- */
540
- email_address: boolean;
541
- /**
542
- * @default true
543
- */
544
- iban_code: boolean;
545
- /**
546
- * @default true
547
- */
548
- ip_address: boolean;
549
- /**
550
- * @default false
551
- */
552
- location: boolean;
553
- /**
554
- * @default false
555
- */
556
- person: boolean;
557
- /**
558
- * @default true
559
- */
560
- phone_number: boolean;
561
- /**
562
- * @default true
563
- */
564
- medical_license: boolean;
565
- /**
566
- * @default false
567
- */
568
- us_bank_number: boolean;
569
- /**
570
- * @default false
571
- */
572
- us_driver_license: boolean;
573
- /**
574
- * @default false
575
- */
576
- us_itin: boolean;
577
- /**
578
- * @default false
579
- */
580
- us_passport: boolean;
581
- /**
582
- * @default false
583
- */
584
- us_ssn: boolean;
585
- /**
586
- * @default false
587
- */
588
- uk_nhs: boolean;
589
- /**
590
- * @default false
591
- */
592
- sg_nric_fin: boolean;
593
- /**
594
- * @default false
595
- */
596
- au_abn: boolean;
597
- /**
598
- * @default false
599
- */
600
- au_acn: boolean;
601
- /**
602
- * @default false
603
- */
604
- au_tfn: boolean;
605
- /**
606
- * @default false
607
- */
608
- au_medicare: boolean;
609
- /**
610
- * @default false
611
- */
612
- in_pan: boolean;
613
- /**
614
- * @default false
615
- */
616
- in_aadhaar: boolean;
617
- /**
618
- * @default false
619
- */
620
- in_vehicle_registration: boolean;
621
- /**
622
- * @default false
623
- */
624
- in_voter: boolean;
625
- /**
626
- * @default false
627
- */
628
- in_passport: boolean;
629
- };
630
- /**
631
- * @description The minimum confidence required for failing the evaluation on a PII match.
632
- * @default 0.5
633
- */
634
- min_threshold: number;
635
- };
636
- };
637
- "ragas/bleu_score": {
638
- settings: Record<string, never>;
639
- };
640
- "ragas/context_f1": {
641
- settings: {
642
- /**
643
- * @default "levenshtein"
644
- */
645
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
646
- };
647
- };
648
- "ragas/context_precision": {
649
- settings: {
650
- /**
651
- * @default "levenshtein"
652
- */
653
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
654
- };
655
- };
656
- "ragas/context_recall": {
657
- settings: {
658
- /**
659
- * @default "levenshtein"
660
- */
661
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
662
- };
663
- };
664
- "ragas/factual_correctness": {
665
- settings: {
666
- /**
667
- * @description The model to use for evaluation.
668
- * @default "openai/gpt-4o-mini"
669
- */
670
- model: string;
671
- /**
672
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
673
- * @default 2048
674
- */
675
- max_tokens: number;
676
- /**
677
- * @description The mode to use for the factual correctness metric.
678
- * @default "f1"
679
- */
680
- mode: "f1" | "precision" | "recall";
681
- /**
682
- * @description The level of atomicity for claim decomposition.
683
- * @default "low"
684
- */
685
- atomicity: "low" | "high";
686
- /**
687
- * @description The level of coverage for claim decomposition.
688
- * @default "low"
689
- */
690
- coverage: "low" | "high";
691
- };
692
- };
693
- "ragas/faithfulness": {
694
- settings: {
695
- /**
696
- * @description The model to use for evaluation.
697
- * @default "openai/gpt-4o-mini"
698
- */
699
- model: string;
700
- /**
701
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
702
- * @default 2048
703
- */
704
- max_tokens: number;
705
- /**
706
- * @description Whether to autodetect 'I don't know' in the output to avoid failing the evaluation.
707
- * @default true
708
- */
709
- autodetect_dont_know: boolean;
710
- };
711
- };
712
- "ragas/response_context_precision": {
713
- settings: {
714
- /**
715
- * @description The model to use for evaluation.
716
- * @default "openai/gpt-4o-mini"
717
- */
718
- model: string;
719
- /**
720
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
721
- * @default 2048
722
- */
723
- max_tokens: number;
724
- };
725
- };
726
- "ragas/response_context_recall": {
727
- settings: {
728
- /**
729
- * @description The model to use for evaluation.
730
- * @default "openai/gpt-4o-mini"
731
- */
732
- model: string;
733
- /**
734
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
735
- * @default 2048
736
- */
737
- max_tokens: number;
738
- };
739
- };
740
- "ragas/response_relevancy": {
741
- settings: {
742
- /**
743
- * @description The model to use for evaluation.
744
- * @default "openai/gpt-4o-mini"
745
- */
746
- model: string;
747
- /**
748
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
749
- * @default 2048
750
- */
751
- max_tokens: number;
752
- /**
753
- * @description The model to use for embeddings.
754
- * @default "openai/text-embedding-ada-002"
755
- */
756
- embeddings_model: string;
757
- };
758
- };
759
- "ragas/rouge_score": {
760
- settings: {
761
- /**
762
- * @description ROUGE type
763
- * @default "rouge1"
764
- */
765
- rouge_type: "rouge1" | "rougeL";
766
- /**
767
- * @description ROUGE measure type
768
- * @default "fmeasure"
769
- */
770
- measure_type: "fmeasure" | "precision" | "recall";
771
- };
772
- };
773
- "ragas/rubrics_based_scoring": {
774
- settings: {
775
- /**
776
- * @description The model to use for evaluation.
777
- * @default "openai/gpt-4o-mini"
778
- */
779
- model: string;
780
- /**
781
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
782
- * @default 2048
783
- */
784
- max_tokens: number;
785
- /**
786
- * @default [{"description": "The response is incorrect, irrelevant."}, {"description": "The response partially answers the question but includes significant errors, omissions, or irrelevant information."}, {"description": "The response partially answers the question but includes minor errors, omissions, or irrelevant information."}, {"description": "The response fully answers the question and includes minor errors, omissions, or irrelevant information."}, {"description": "The response fully answers the question and includes no errors, omissions, or irrelevant information."}]
787
- */
788
- rubrics: {
789
- description: string;
790
- }[];
791
- };
792
- };
793
- "ragas/sql_query_equivalence": {
794
- settings: {
795
- /**
796
- * @description The model to use for evaluation.
797
- * @default "openai/gpt-4o-mini"
798
- */
799
- model: string;
800
- /**
801
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
802
- * @default 2048
803
- */
804
- max_tokens: number;
805
- };
806
- };
807
- "ragas/summarization_score": {
808
- settings: {
809
- /**
810
- * @description The model to use for evaluation.
811
- * @default "openai/gpt-4o-mini"
812
- */
813
- model: string;
814
- /**
815
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
816
- * @default 2048
817
- */
818
- max_tokens: number;
819
- };
820
- };
821
- };
822
-
823
- type Conversation = {
824
- input?: string;
825
- output?: string;
826
- }[];
827
-
828
- type Money = {
829
- currency: string;
830
- amount: number;
831
- };
832
- type EvaluationResultModel = {
833
- status: "processed" | "skipped" | "error";
834
- passed?: boolean;
835
- score?: number;
836
- details?: string;
837
- label?: string;
838
- cost?: Money;
839
- };
840
- type CommonEvaluationParams = {
841
- name?: string;
842
- input?: string;
843
- output?: string;
844
- expectedOutput?: string;
845
- contexts?: RAGChunk[] | string[];
846
- conversation?: Conversation;
847
- asGuardrail?: boolean;
848
- trace?: LangWatchTrace;
849
- span?: LangWatchSpan;
850
- };
851
- type SavedEvaluationParams = {
852
- slug: string;
853
- settings?: Record<string, unknown>;
854
- } & CommonEvaluationParams;
855
- type LangEvalsEvaluationParams<T extends EvaluatorTypes> = {
856
- evaluator: T;
857
- settings?: Evaluators[T]["settings"];
858
- } & CommonEvaluationParams;
859
- type EvaluationParams = SavedEvaluationParams | LangEvalsEvaluationParams<EvaluatorTypes>;
860
-
861
- declare class LangWatchCallbackHandler extends BaseCallbackHandler {
862
- name: string;
863
- trace: LangWatchTrace;
864
- spans: Record<string, LangWatchSpan>;
865
- constructor({ trace }: {
866
- trace: LangWatchTrace;
867
- });
868
- handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, _tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
869
- private buildLLMSpan;
870
- handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
871
- handleNewToken(_token: string, runId: string): Promise<void>;
872
- handleLLMEnd(response: LLMResult, runId: string, _parentRunId?: string | undefined): Promise<void>;
873
- handleLLMError(err: Error, runId: string, _parentRunId?: string | undefined): Promise<void>;
874
- handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, _runType?: string, name?: string): Promise<void>;
875
- handleChainEnd(output: ChainValues, runId: string, _parentRunId?: string | undefined): Promise<void>;
876
- handleChainError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined, _kwargs?: {
877
- inputs?: Record<string, unknown> | undefined;
878
- } | undefined): Promise<void>;
879
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
880
- handleToolEnd(output: string, runId: string, _parentRunId?: string | undefined): Promise<void>;
881
- handleToolError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
882
- handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string | undefined): Promise<void>;
883
- handleRetrieverEnd(documents: DocumentInterface<Record<string, any>>[], runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
884
- handleRetrieverError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
885
- handleAgentAction(_action: AgentAction, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
886
- handleAgentEnd(action: AgentFinish, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
887
- private buildSpan;
888
- private endSpan;
889
- private errorSpan;
890
- private autoconvertTypedValues;
891
- private getParent;
892
- }
893
-
894
- declare class LangWatchExporter implements SpanExporter {
895
- private endpoint;
896
- private apiKey;
897
- private includeAllSpans;
898
- private debug;
899
- constructor(params?: {
900
- endpoint?: string;
901
- apiKey?: string;
902
- includeAllSpans?: boolean;
903
- debug?: boolean;
904
- });
905
- export(allSpans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
906
- private isAiSdkSpan;
907
- shutdown(): Promise<void>;
908
- }
909
-
910
- declare class LangWatch extends EventEmitter {
911
- apiKey: string | undefined;
912
- endpoint: string;
913
- constructor({ apiKey, endpoint, }?: {
914
- apiKey?: string;
915
- endpoint?: string;
916
- });
917
- getTrace({ traceId, metadata, }?: {
918
- traceId?: string;
919
- metadata?: Metadata;
920
- }): LangWatchTrace;
921
- sendTrace(params: CollectorRESTParams): Promise<void>;
922
- _sendTrace(params: CollectorRESTParams): Promise<void>;
923
- }
924
- type AddEvaluationParams = {
925
- evaluationId?: string;
926
- span?: LangWatchSpan;
927
- name: string;
928
- type?: string;
929
- isGuardrail?: boolean;
930
- status?: "processed" | "skipped" | "error";
931
- passed?: boolean;
932
- score?: number;
933
- label?: string;
934
- details?: string;
935
- error?: Error;
936
- timestamps?: RESTEvaluation["timestamps"];
937
- };
938
- declare class LangWatchTrace {
939
- client: LangWatch;
940
- traceId: string;
941
- metadata?: Metadata;
942
- finishedSpans: Record<string, Span>;
943
- langchainCallback?: LangWatchCallbackHandler;
944
- evaluations: RESTEvaluation[];
945
- private currentSpan?;
946
- private timeoutRef?;
947
- constructor({ client, traceId, metadata, }: {
948
- client: LangWatch;
949
- traceId: string;
950
- metadata?: Metadata;
951
- });
952
- update({ metadata }: {
953
- metadata: Metadata;
954
- }): void;
955
- setCurrentSpan(span: LangWatchSpan): void;
956
- getCurrentSpan(): LangWatchSpan | undefined;
957
- resetCurrentSpan(): void;
958
- startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
959
- startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
960
- startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
961
- addEvaluation: ({ evaluationId, span, name, type, isGuardrail, status, passed, score, label, details, error, timestamps, }: AddEvaluationParams) => void;
962
- evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
963
- getLangChainCallback(): LangWatchCallbackHandler;
964
- onEnd(span: Span): void;
965
- delayedSendSpans(): void;
966
- sendSpans(): Promise<void>;
967
- }
968
- declare class LangWatchSpan implements PendingBaseSpan {
969
- trace: LangWatchTrace;
970
- spanId: string;
971
- parentId?: string | null;
972
- type: SpanTypes;
973
- name?: string | null;
974
- input?: PendingBaseSpan["input"];
975
- output?: PendingBaseSpan["output"];
976
- error?: PendingBaseSpan["error"];
977
- timestamps: PendingBaseSpan["timestamps"];
978
- metrics: PendingBaseSpan["metrics"];
979
- constructor({ trace, spanId, parentId, type, name, input, output, error, timestamps, metrics, }: Partial<PendingBaseSpan> & {
980
- trace: LangWatchTrace;
981
- });
982
- update(params: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
983
- startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
984
- startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
985
- startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
986
- addEvaluation(params: AddEvaluationParams): void;
987
- evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
988
- end(params?: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
989
- }
990
- declare class LangWatchLLMSpan extends LangWatchSpan implements PendingLLMSpan {
991
- type: "llm";
992
- model: PendingLLMSpan["model"];
993
- params: PendingLLMSpan["params"];
994
- constructor(params: Partial<PendingLLMSpan> & {
995
- trace: LangWatchTrace;
996
- });
997
- update(params: Partial<PendingLLMSpan>): void;
998
- end(params?: Partial<PendingLLMSpan>): void;
999
- }
1000
- declare class LangWatchRAGSpan extends LangWatchSpan implements PendingRAGSpan {
1001
- type: "rag";
1002
- contexts: PendingRAGSpan["contexts"];
1003
- constructor(params: Partial<PendingRAGSpan> & {
1004
- trace: LangWatchTrace;
1005
- });
1006
- update(params: Partial<PendingRAGSpan>): void;
1007
- end(params?: Partial<PendingRAGSpan>): void;
1008
- }
1009
-
1010
- export { LangWatch, LangWatchExporter, LangWatchLLMSpan, LangWatchRAGSpan, LangWatchSpan, LangWatchTrace, Metadata, PendingBaseSpan, PendingLLMSpan, PendingRAGSpan };