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.
Files changed (229) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +268 -1
  3. package/dist/chunk-4BZATFKJ.mjs +181 -0
  4. package/dist/chunk-4BZATFKJ.mjs.map +1 -0
  5. package/dist/chunk-CSC3CMIT.mjs +118 -0
  6. package/dist/chunk-CSC3CMIT.mjs.map +1 -0
  7. package/dist/chunk-F63YKTXA.mjs +47 -0
  8. package/dist/chunk-F63YKTXA.mjs.map +1 -0
  9. package/dist/chunk-G3AUABT7.js +4 -0
  10. package/dist/chunk-G3AUABT7.js.map +1 -0
  11. package/dist/chunk-HPC6Z7J4.js +118 -0
  12. package/dist/chunk-HPC6Z7J4.js.map +1 -0
  13. package/dist/chunk-KGDAENGD.js +50 -0
  14. package/dist/chunk-KGDAENGD.js.map +1 -0
  15. package/dist/chunk-LD74LVRU.js +47 -0
  16. package/dist/chunk-LD74LVRU.js.map +1 -0
  17. package/dist/chunk-OM7VY3XT.mjs +4 -0
  18. package/dist/chunk-PCQVQ7SB.js +45 -0
  19. package/dist/chunk-PCQVQ7SB.js.map +1 -0
  20. package/dist/chunk-PMBEK6YE.mjs +424 -0
  21. package/dist/chunk-PMBEK6YE.mjs.map +1 -0
  22. package/dist/chunk-PR3JDWC3.mjs +50 -0
  23. package/dist/chunk-PR3JDWC3.mjs.map +1 -0
  24. package/dist/chunk-PTJ6AAI7.js +360 -0
  25. package/dist/chunk-PTJ6AAI7.js.map +1 -0
  26. package/dist/chunk-QEWDG5QE.mjs +45 -0
  27. package/dist/chunk-QEWDG5QE.mjs.map +1 -0
  28. package/dist/chunk-REUCVT7A.mjs +39 -0
  29. package/dist/chunk-REUCVT7A.mjs.map +1 -0
  30. package/dist/chunk-SVJ7SCGB.js +424 -0
  31. package/dist/chunk-SVJ7SCGB.js.map +1 -0
  32. package/dist/chunk-VJSOCNPA.js +181 -0
  33. package/dist/chunk-VJSOCNPA.js.map +1 -0
  34. package/dist/chunk-WM2GRSRW.js +39 -0
  35. package/dist/chunk-WM2GRSRW.js.map +1 -0
  36. package/dist/chunk-Z5J5UI5E.mjs +360 -0
  37. package/dist/chunk-Z5J5UI5E.mjs.map +1 -0
  38. package/dist/client-B2HqIKg6.d.ts +51 -0
  39. package/dist/client-XyCqclCi.d.mts +51 -0
  40. package/dist/client-browser.d.mts +8 -0
  41. package/dist/client-browser.d.ts +8 -0
  42. package/dist/client-browser.js +83 -0
  43. package/dist/client-browser.js.map +1 -0
  44. package/dist/client-browser.mjs +83 -0
  45. package/dist/client-browser.mjs.map +1 -0
  46. package/dist/client-node.d.mts +8 -0
  47. package/dist/client-node.d.ts +8 -0
  48. package/dist/client-node.js +90 -0
  49. package/dist/client-node.js.map +1 -0
  50. package/dist/client-node.mjs +90 -0
  51. package/dist/client-node.mjs.map +1 -0
  52. package/dist/evaluation/index.d.mts +897 -0
  53. package/dist/evaluation/index.d.ts +897 -0
  54. package/dist/evaluation/index.js +13 -0
  55. package/dist/evaluation/index.js.map +1 -0
  56. package/dist/evaluation/index.mjs +13 -0
  57. package/dist/evaluation/index.mjs.map +1 -0
  58. package/dist/filterable-batch-span-processor-zO5kcjBY.d.mts +64 -0
  59. package/dist/filterable-batch-span-processor-zO5kcjBY.d.ts +64 -0
  60. package/dist/index.d.mts +45 -1027
  61. package/dist/index.d.ts +45 -1027
  62. package/dist/index.js +11 -27291
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +23 -956
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/observability/index.d.mts +260 -0
  67. package/dist/observability/index.d.ts +260 -0
  68. package/dist/observability/index.js +20 -0
  69. package/dist/observability/index.js.map +1 -0
  70. package/dist/observability/index.mjs +20 -0
  71. package/dist/observability/index.mjs.map +1 -0
  72. package/dist/observability/instrumentation/langchain/index.d.mts +40 -0
  73. package/dist/observability/instrumentation/langchain/index.d.ts +40 -0
  74. package/dist/observability/instrumentation/langchain/index.js +666 -0
  75. package/dist/observability/instrumentation/langchain/index.js.map +1 -0
  76. package/dist/observability/instrumentation/langchain/index.mjs +666 -0
  77. package/dist/observability/instrumentation/langchain/index.mjs.map +1 -0
  78. package/dist/prompt/index.d.mts +10 -0
  79. package/dist/prompt/index.d.ts +10 -0
  80. package/dist/prompt/index.js +18 -0
  81. package/dist/prompt/index.js.map +1 -0
  82. package/dist/prompt/index.mjs +18 -0
  83. package/dist/prompt/index.mjs.map +1 -0
  84. package/dist/prompt-BXJWdbQp.d.mts +1967 -0
  85. package/dist/prompt-BXJWdbQp.d.ts +1967 -0
  86. package/dist/record-evaluation-CmxMXa-3.d.mts +25 -0
  87. package/dist/record-evaluation-CmxMXa-3.d.ts +25 -0
  88. package/dist/trace-D-bZOuqb.d.mts +622 -0
  89. package/dist/trace-G2312klE.d.ts +622 -0
  90. package/package.json +86 -37
  91. package/.eslintrc.cjs +0 -37
  92. package/copy-types.sh +0 -17
  93. package/dist/chunk-LKD2K67J.mjs +0 -717
  94. package/dist/chunk-LKD2K67J.mjs.map +0 -1
  95. package/dist/utils-Cv-rUjJ1.d.mts +0 -313
  96. package/dist/utils-Cv-rUjJ1.d.ts +0 -313
  97. package/dist/utils.d.mts +0 -2
  98. package/dist/utils.d.ts +0 -2
  99. package/dist/utils.js +0 -709
  100. package/dist/utils.js.map +0 -1
  101. package/dist/utils.mjs +0 -11
  102. package/example/.env.example +0 -12
  103. package/example/.eslintrc.json +0 -26
  104. package/example/LICENSE +0 -13
  105. package/example/README.md +0 -12
  106. package/example/app/(chat)/chat/[id]/page.tsx +0 -60
  107. package/example/app/(chat)/layout.tsx +0 -14
  108. package/example/app/(chat)/page.tsx +0 -27
  109. package/example/app/actions.ts +0 -156
  110. package/example/app/globals.css +0 -76
  111. package/example/app/guardrails/page.tsx +0 -26
  112. package/example/app/langchain/page.tsx +0 -27
  113. package/example/app/langchain-rag/page.tsx +0 -28
  114. package/example/app/late-update/page.tsx +0 -27
  115. package/example/app/layout.tsx +0 -64
  116. package/example/app/login/actions.ts +0 -71
  117. package/example/app/login/page.tsx +0 -18
  118. package/example/app/manual/page.tsx +0 -27
  119. package/example/app/new/page.tsx +0 -5
  120. package/example/app/opengraph-image.png +0 -0
  121. package/example/app/share/[id]/page.tsx +0 -58
  122. package/example/app/signup/actions.ts +0 -111
  123. package/example/app/signup/page.tsx +0 -18
  124. package/example/app/twitter-image.png +0 -0
  125. package/example/auth.config.ts +0 -42
  126. package/example/auth.ts +0 -45
  127. package/example/components/button-scroll-to-bottom.tsx +0 -36
  128. package/example/components/chat-history.tsx +0 -49
  129. package/example/components/chat-list.tsx +0 -52
  130. package/example/components/chat-message-actions.tsx +0 -40
  131. package/example/components/chat-message.tsx +0 -80
  132. package/example/components/chat-panel.tsx +0 -139
  133. package/example/components/chat-share-dialog.tsx +0 -95
  134. package/example/components/chat.tsx +0 -84
  135. package/example/components/clear-history.tsx +0 -75
  136. package/example/components/empty-screen.tsx +0 -38
  137. package/example/components/external-link.tsx +0 -29
  138. package/example/components/footer.tsx +0 -19
  139. package/example/components/header.tsx +0 -114
  140. package/example/components/login-button.tsx +0 -42
  141. package/example/components/login-form.tsx +0 -97
  142. package/example/components/markdown.tsx +0 -9
  143. package/example/components/prompt-form.tsx +0 -115
  144. package/example/components/providers.tsx +0 -17
  145. package/example/components/sidebar-actions.tsx +0 -125
  146. package/example/components/sidebar-desktop.tsx +0 -19
  147. package/example/components/sidebar-footer.tsx +0 -16
  148. package/example/components/sidebar-item.tsx +0 -124
  149. package/example/components/sidebar-items.tsx +0 -42
  150. package/example/components/sidebar-list.tsx +0 -38
  151. package/example/components/sidebar-mobile.tsx +0 -31
  152. package/example/components/sidebar-toggle.tsx +0 -24
  153. package/example/components/sidebar.tsx +0 -21
  154. package/example/components/signup-form.tsx +0 -95
  155. package/example/components/stocks/events-skeleton.tsx +0 -31
  156. package/example/components/stocks/events.tsx +0 -30
  157. package/example/components/stocks/index.tsx +0 -36
  158. package/example/components/stocks/message.tsx +0 -134
  159. package/example/components/stocks/spinner.tsx +0 -16
  160. package/example/components/stocks/stock-purchase.tsx +0 -146
  161. package/example/components/stocks/stock-skeleton.tsx +0 -22
  162. package/example/components/stocks/stock.tsx +0 -210
  163. package/example/components/stocks/stocks-skeleton.tsx +0 -9
  164. package/example/components/stocks/stocks.tsx +0 -67
  165. package/example/components/tailwind-indicator.tsx +0 -14
  166. package/example/components/theme-toggle.tsx +0 -31
  167. package/example/components/ui/alert-dialog.tsx +0 -141
  168. package/example/components/ui/badge.tsx +0 -36
  169. package/example/components/ui/button.tsx +0 -57
  170. package/example/components/ui/codeblock.tsx +0 -148
  171. package/example/components/ui/dialog.tsx +0 -122
  172. package/example/components/ui/dropdown-menu.tsx +0 -205
  173. package/example/components/ui/icons.tsx +0 -507
  174. package/example/components/ui/input.tsx +0 -25
  175. package/example/components/ui/label.tsx +0 -26
  176. package/example/components/ui/select.tsx +0 -164
  177. package/example/components/ui/separator.tsx +0 -31
  178. package/example/components/ui/sheet.tsx +0 -140
  179. package/example/components/ui/sonner.tsx +0 -31
  180. package/example/components/ui/switch.tsx +0 -29
  181. package/example/components/ui/textarea.tsx +0 -24
  182. package/example/components/ui/tooltip.tsx +0 -30
  183. package/example/components/user-menu.tsx +0 -53
  184. package/example/components.json +0 -17
  185. package/example/instrumentation.ts +0 -11
  186. package/example/lib/chat/guardrails.tsx +0 -181
  187. package/example/lib/chat/langchain-rag.tsx +0 -191
  188. package/example/lib/chat/langchain.tsx +0 -112
  189. package/example/lib/chat/late-update.tsx +0 -208
  190. package/example/lib/chat/manual.tsx +0 -605
  191. package/example/lib/chat/vercel-ai.tsx +0 -576
  192. package/example/lib/hooks/use-copy-to-clipboard.tsx +0 -33
  193. package/example/lib/hooks/use-enter-submit.tsx +0 -23
  194. package/example/lib/hooks/use-local-storage.ts +0 -24
  195. package/example/lib/hooks/use-scroll-anchor.tsx +0 -86
  196. package/example/lib/hooks/use-sidebar.tsx +0 -60
  197. package/example/lib/hooks/use-streamable-text.ts +0 -25
  198. package/example/lib/types.ts +0 -41
  199. package/example/lib/utils.ts +0 -89
  200. package/example/middleware.ts +0 -8
  201. package/example/next-env.d.ts +0 -5
  202. package/example/next.config.js +0 -16
  203. package/example/package-lock.json +0 -10917
  204. package/example/package.json +0 -84
  205. package/example/pnpm-lock.yaml +0 -5712
  206. package/example/postcss.config.js +0 -6
  207. package/example/prettier.config.cjs +0 -34
  208. package/example/public/apple-touch-icon.png +0 -0
  209. package/example/public/favicon-16x16.png +0 -0
  210. package/example/public/favicon.ico +0 -0
  211. package/example/public/next.svg +0 -1
  212. package/example/public/thirteen.svg +0 -1
  213. package/example/public/vercel.svg +0 -1
  214. package/example/tailwind.config.ts +0 -81
  215. package/example/tsconfig.json +0 -35
  216. package/src/LangWatchExporter.ts +0 -96
  217. package/src/evaluations.ts +0 -219
  218. package/src/index.test.ts +0 -402
  219. package/src/index.ts +0 -596
  220. package/src/langchain.ts +0 -557
  221. package/src/server/types/.gitkeep +0 -0
  222. package/src/typeUtils.ts +0 -89
  223. package/src/types.ts +0 -82
  224. package/src/utils.ts +0 -205
  225. package/ts-to-zod.config.js +0 -24
  226. package/tsconfig.json +0 -32
  227. package/tsup.config.ts +0 -10
  228. package/vitest.config.ts +0 -8
  229. /package/dist/{utils.mjs.map → chunk-OM7VY3XT.mjs.map} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,1030 +1,48 @@
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-Cv-rUjJ1.mjs';
10
- export { B as BaseSpan, e as ChatMessage, f as ChatRichContent, E as ErrorCapture, 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-Cv-rUjJ1.mjs';
11
- import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
12
- import { ExportResult } from '@opentelemetry/core';
13
- import 'ai';
1
+ export { L as LangWatchSpan, g as getLangWatchTracer } from './trace-D-bZOuqb.mjs';
2
+ export { F as FilterableBatchSpanProcessor, S as SpanProcessingExcludeRule } from './filterable-batch-span-processor-zO5kcjBY.mjs';
3
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
4
+ export { runEvaluation } from './evaluation/index.mjs';
5
+ export { r as recordEvaluation } from './record-evaluation-CmxMXa-3.mjs';
6
+ export { getPrompt, getPromptVersion } from './prompt/index.mjs';
7
+ import '@opentelemetry/api';
8
+ import './prompt-BXJWdbQp.mjs';
9
+ import '@opentelemetry/sdk-trace-base';
14
10
 
15
- type EvaluatorTypes = keyof Evaluators;
16
- type Evaluators = {
17
- "huggingface/llama_guard": {
18
- settings: {
19
- /**
20
- * @description The policy to enforce, described into rules of what it 'Should not' and what it 'Can' do (max 768 tokens)
21
- * @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."
22
- */
23
- policy: string;
24
- /**
25
- * @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.
26
- * @default "input"
27
- */
28
- evaluate: "input" | "output" | "both";
29
- /**
30
- * @description The provider to use for evaluation. Only CloudFlare AI workers is supported for now.
31
- * @default "cloudflare/thebloke/llamaguard-7b-awq"
32
- */
33
- model: "cloudflare/thebloke/llamaguard-7b-awq";
34
- };
35
- };
36
- "langevals/basic": {
37
- settings: {
38
- /**
39
- * @description List of rules to check, the message must pass all of them
40
- * @default [{"field": "output", "rule": "not_contains", "value": "artificial intelligence"}]
41
- */
42
- rules: {
43
- /**
44
- * @default "output"
45
- */
46
- field: "input" | "output";
47
- rule: "contains" | "not_contains" | "matches_regex" | "not_matches_regex";
48
- value: string;
49
- }[];
50
- };
51
- };
52
- "langevals/competitor_blocklist": {
53
- settings: {
54
- /**
55
- * @description The competitors that must not be mentioned.
56
- * @default ["OpenAI", "Google", "Microsoft"]
57
- */
58
- competitors: string[];
59
- };
60
- };
61
- "langevals/competitor_llm": {
62
- settings: {
63
- /**
64
- * @description The model to use for evaluation
65
- * @default "openai/gpt-4o-mini"
66
- */
67
- model: string;
68
- /**
69
- * @description Max tokens allowed for evaluation
70
- * @default 8192
71
- */
72
- max_tokens: number;
73
- /**
74
- * @description The name of your company
75
- * @default "LangWatch"
76
- */
77
- name: string;
78
- /**
79
- * @description Description of what your company is specializing at
80
- * @default "We are providing an LLM observability and evaluation platform"
81
- */
82
- description: string;
83
- };
84
- };
85
- "langevals/competitor_llm_function_call": {
86
- settings: {
87
- /**
88
- * @description The model to use for evaluation
89
- * @default "openai/gpt-4o-mini"
90
- */
91
- model: string;
92
- /**
93
- * @description Max tokens allowed for evaluation
94
- * @default 8192
95
- */
96
- max_tokens: number;
97
- /**
98
- * @description The name of your company
99
- * @default "LangWatch"
100
- */
101
- name: string;
102
- /**
103
- * @description Description of what your company is specializing at
104
- * @default "We are providing an LLM observability and evaluation platform"
105
- */
106
- description: string;
107
- /**
108
- * @description The competitors that must not be mentioned.
109
- * @default ["OpenAI", "Google", "Microsoft"]
110
- */
111
- competitors: string[];
112
- };
113
- };
114
- "langevals/exact_match": {
115
- settings: {
116
- /**
117
- * @description True if the comparison should be case-sensitive, False otherwise
118
- * @default false
119
- */
120
- case_sensitive: boolean;
121
- /**
122
- * @description True if the comparison should trim whitespace, False otherwise
123
- * @default true
124
- */
125
- trim_whitespace: boolean;
126
- /**
127
- * @description True if the comparison should remove punctuation, False otherwise
128
- * @default true
129
- */
130
- remove_punctuation: boolean;
131
- };
132
- };
133
- "langevals/llm_answer_match": {
134
- settings: {
135
- /**
136
- * @description The model to use for evaluation
137
- * @default "openai/gpt-4o-mini"
138
- */
139
- model: string;
140
- /**
141
- * @description Max tokens allowed for evaluation
142
- * @default 8192
143
- */
144
- max_tokens: number;
145
- };
146
- };
147
- "langevals/llm_boolean": {
148
- settings: {
149
- /**
150
- * @description The model to use for evaluation
151
- * @default "openai/gpt-4o-mini"
152
- */
153
- model: string;
154
- /**
155
- * @default 8192
156
- */
157
- max_tokens: number;
158
- /**
159
- * @description The system prompt to use for the LLM to run the evaluation
160
- * @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"
161
- */
162
- prompt: string;
163
- };
164
- };
165
- "langevals/llm_category": {
166
- settings: {
167
- /**
168
- * @description The model to use for evaluation
169
- * @default "openai/gpt-4o-mini"
170
- */
171
- model: string;
172
- /**
173
- * @default 8192
174
- */
175
- max_tokens: number;
176
- /**
177
- * @description The system prompt to use for the LLM to run the evaluation
178
- * @default "You are an LLM category evaluator. Please categorize the message in one of the following categories"
179
- */
180
- prompt: string;
181
- /**
182
- * @description The categories to use for the evaluation
183
- * @default [{"name": "smalltalk", "description": "Smalltalk with the user"}, {"name": "company", "description": "Questions about the company, what we do, etc"}]
184
- */
185
- categories: {
186
- name: string;
187
- description: string;
188
- }[];
189
- };
190
- };
191
- "langevals/llm_score": {
192
- settings: {
193
- /**
194
- * @description The model to use for evaluation
195
- * @default "openai/gpt-4o-mini"
196
- */
197
- model: string;
198
- /**
199
- * @default 8192
200
- */
201
- max_tokens: number;
202
- /**
203
- * @description The system prompt to use for the LLM to run the evaluation
204
- * @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"
205
- */
206
- prompt: string;
207
- };
208
- };
209
- "langevals/off_topic": {
210
- settings: {
211
- /**
212
- * @description The model to use for evaluation
213
- * @default "openai/gpt-4o-mini"
214
- */
215
- model: string;
216
- /**
217
- * @description Max tokens allowed for evaluation
218
- * @default 8192
219
- */
220
- max_tokens: number;
221
- /**
222
- * @description The list of topics and their short descriptions that the chatbot is allowed to talk about
223
- * @default [{"topic": "simple_chat", "description": "Smalltalk with the user"}, {"topic": "company", "description": "Questions about the company, what we do, etc"}]
224
- */
225
- allowed_topics: {
226
- topic: string;
227
- description: string;
228
- }[];
229
- };
230
- };
231
- "langevals/query_resolution": {
232
- settings: {
233
- /**
234
- * @description The model to use for evaluation
235
- * @default "openai/gpt-4o-mini"
236
- */
237
- model: string;
238
- /**
239
- * @description Max tokens allowed for evaluation
240
- * @default 8192
241
- */
242
- max_tokens: number;
243
- };
244
- };
245
- "langevals/similarity": {
246
- settings: {
247
- /**
248
- * @default "output"
249
- */
250
- field: "input" | "output";
251
- /**
252
- * @default "is_not_similar_to"
253
- */
254
- rule: "is_not_similar_to" | "is_similar_to";
255
- /**
256
- * @default "example"
257
- */
258
- value: string;
259
- /**
260
- * @default 0.3
261
- */
262
- threshold: number;
263
- /**
264
- * @default "openai/text-embedding-3-small"
265
- */
266
- embeddings_model: string;
267
- };
268
- };
269
- "langevals/valid_format": {
270
- settings: {
271
- /**
272
- * @default "json"
273
- */
274
- format: "json" | "markdown" | "python" | "sql";
275
- /**
276
- * @description JSON schema to validate against when format is 'json'
277
- */
278
- json_schema?: string;
279
- };
280
- };
281
- "azure/content_safety": {
282
- settings: {
283
- /**
284
- * @description The minimum severity level to consider content as unsafe, from 1 to 7.
285
- * @default 1
286
- */
287
- severity_threshold: 1 | 2 | 3 | 4 | 5 | 6 | 7;
288
- /**
289
- * @description The categories of moderation to check for.
290
- * @default {"Hate": true, "SelfHarm": true, "Sexual": true, "Violence": true}
291
- */
292
- categories: {
293
- /**
294
- * @default true
295
- */
296
- Hate: boolean;
297
- /**
298
- * @default true
299
- */
300
- SelfHarm: boolean;
301
- /**
302
- * @default true
303
- */
304
- Sexual: boolean;
305
- /**
306
- * @default true
307
- */
308
- Violence: boolean;
309
- };
310
- /**
311
- * @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.
312
- * @default "FourSeverityLevels"
313
- */
314
- output_type: "FourSeverityLevels" | "EightSeverityLevels";
315
- };
316
- };
317
- "azure/jailbreak": {
318
- settings: Record<string, never>;
319
- };
320
- "azure/prompt_injection": {
321
- settings: Record<string, never>;
322
- };
323
- "openai/moderation": {
324
- settings: {
325
- /**
326
- * @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.
327
- * @default "text-moderation-stable"
328
- */
329
- model: "text-moderation-stable" | "text-moderation-latest";
330
- /**
331
- * @description The categories of content to check for moderation.
332
- * @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}
333
- */
334
- categories: {
335
- /**
336
- * @default true
337
- */
338
- harassment: boolean;
339
- /**
340
- * @default true
341
- */
342
- harassment_threatening: boolean;
343
- /**
344
- * @default true
345
- */
346
- hate: boolean;
347
- /**
348
- * @default true
349
- */
350
- hate_threatening: boolean;
351
- /**
352
- * @default true
353
- */
354
- self_harm: boolean;
355
- /**
356
- * @default true
357
- */
358
- self_harm_instructions: boolean;
359
- /**
360
- * @default true
361
- */
362
- self_harm_intent: boolean;
363
- /**
364
- * @default true
365
- */
366
- sexual: boolean;
367
- /**
368
- * @default true
369
- */
370
- sexual_minors: boolean;
371
- /**
372
- * @default true
373
- */
374
- violence: boolean;
375
- /**
376
- * @default true
377
- */
378
- violence_graphic: boolean;
379
- };
380
- };
381
- };
382
- "lingua/language_detection": {
383
- settings: {
384
- /**
385
- * @description What should be checked
386
- * @default "input_matches_output"
387
- */
388
- check_for: "input_matches_output" | "output_matches_language";
389
- /**
390
- * @description The specific language that the output is expected to be
391
- */
392
- 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";
393
- /**
394
- * @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.
395
- * @default 7
396
- */
397
- min_words: number;
398
- /**
399
- * @description Minimum confidence threshold for the language detection. If the confidence is lower than this, the evaluation will be skipped.
400
- * @default 0.25
401
- */
402
- threshold: number;
403
- };
404
- };
405
- "legacy/ragas_answer_correctness": {
406
- settings: {
407
- /**
408
- * @description The model to use for evaluation.
409
- * @default "openai/gpt-4o-mini"
410
- */
411
- model: string;
412
- /**
413
- * @description The model to use for embeddings.
414
- * @default "openai/text-embedding-ada-002"
415
- */
416
- embeddings_model: string;
417
- /**
418
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
419
- * @default 2048
420
- */
421
- max_tokens: number;
422
- };
423
- };
424
- "legacy/ragas_answer_relevancy": {
425
- settings: {
426
- /**
427
- * @description The model to use for evaluation.
428
- * @default "openai/gpt-4o-mini"
429
- */
430
- model: string;
431
- /**
432
- * @description The model to use for embeddings.
433
- * @default "openai/text-embedding-ada-002"
434
- */
435
- embeddings_model: string;
436
- /**
437
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
438
- * @default 2048
439
- */
440
- max_tokens: number;
441
- };
442
- };
443
- "legacy/ragas_context_precision": {
444
- settings: {
445
- /**
446
- * @description The model to use for evaluation.
447
- * @default "openai/gpt-4o-mini"
448
- */
449
- model: string;
450
- /**
451
- * @description The model to use for embeddings.
452
- * @default "openai/text-embedding-ada-002"
453
- */
454
- embeddings_model: string;
455
- /**
456
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
457
- * @default 2048
458
- */
459
- max_tokens: number;
460
- };
461
- };
462
- "legacy/ragas_context_recall": {
463
- settings: {
464
- /**
465
- * @description The model to use for evaluation.
466
- * @default "openai/gpt-4o-mini"
467
- */
468
- model: string;
469
- /**
470
- * @description The model to use for embeddings.
471
- * @default "openai/text-embedding-ada-002"
472
- */
473
- embeddings_model: string;
474
- /**
475
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
476
- * @default 2048
477
- */
478
- max_tokens: number;
479
- };
480
- };
481
- "legacy/ragas_context_relevancy": {
482
- settings: {
483
- /**
484
- * @description The model to use for evaluation.
485
- * @default "openai/gpt-4o-mini"
486
- */
487
- model: string;
488
- /**
489
- * @description The model to use for embeddings.
490
- * @default "openai/text-embedding-ada-002"
491
- */
492
- embeddings_model: string;
493
- /**
494
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
495
- * @default 2048
496
- */
497
- max_tokens: number;
498
- };
499
- };
500
- "legacy/ragas_context_utilization": {
501
- settings: {
502
- /**
503
- * @description The model to use for evaluation.
504
- * @default "openai/gpt-4o-mini"
505
- */
506
- model: string;
507
- /**
508
- * @description The model to use for embeddings.
509
- * @default "openai/text-embedding-ada-002"
510
- */
511
- embeddings_model: string;
512
- /**
513
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
514
- * @default 2048
515
- */
516
- max_tokens: number;
517
- };
518
- };
519
- "legacy/ragas_faithfulness": {
520
- settings: {
521
- /**
522
- * @description The model to use for evaluation.
523
- * @default "openai/gpt-4o-mini"
524
- */
525
- model: string;
526
- /**
527
- * @description The model to use for embeddings.
528
- * @default "openai/text-embedding-ada-002"
529
- */
530
- embeddings_model: string;
531
- /**
532
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
533
- * @default 2048
534
- */
535
- max_tokens: number;
536
- };
537
- };
538
- "example/word_count": {
539
- settings: Record<string, never>;
540
- };
541
- "ragas/bleu_score": {
542
- settings: Record<string, never>;
543
- };
544
- "ragas/context_f1": {
545
- settings: {
546
- /**
547
- * @default "levenshtein"
548
- */
549
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
550
- };
551
- };
552
- "ragas/context_precision": {
553
- settings: {
554
- /**
555
- * @default "levenshtein"
556
- */
557
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
558
- };
559
- };
560
- "ragas/context_recall": {
561
- settings: {
562
- /**
563
- * @default "levenshtein"
564
- */
565
- distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
566
- };
567
- };
568
- "ragas/factual_correctness": {
569
- settings: {
570
- /**
571
- * @description The model to use for evaluation.
572
- * @default "openai/gpt-4o-mini"
573
- */
574
- model: string;
575
- /**
576
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
577
- * @default 2048
578
- */
579
- max_tokens: number;
580
- /**
581
- * @description The mode to use for the factual correctness metric.
582
- * @default "f1"
583
- */
584
- mode: "f1" | "precision" | "recall";
585
- /**
586
- * @description The level of atomicity for claim decomposition.
587
- * @default "low"
588
- */
589
- atomicity: "low" | "high";
590
- /**
591
- * @description The level of coverage for claim decomposition.
592
- * @default "low"
593
- */
594
- coverage: "low" | "high";
595
- };
596
- };
597
- "ragas/faithfulness": {
598
- settings: {
599
- /**
600
- * @description The model to use for evaluation.
601
- * @default "openai/gpt-4o-mini"
602
- */
603
- model: string;
604
- /**
605
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
606
- * @default 2048
607
- */
608
- max_tokens: number;
609
- /**
610
- * @description Whether to autodetect 'I don't know' in the output to avoid failing the evaluation.
611
- * @default true
612
- */
613
- autodetect_dont_know: boolean;
614
- };
615
- };
616
- "ragas/response_context_precision": {
617
- settings: {
618
- /**
619
- * @description The model to use for evaluation.
620
- * @default "openai/gpt-4o-mini"
621
- */
622
- model: string;
623
- /**
624
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
625
- * @default 2048
626
- */
627
- max_tokens: number;
628
- };
629
- };
630
- "ragas/response_context_recall": {
631
- settings: {
632
- /**
633
- * @description The model to use for evaluation.
634
- * @default "openai/gpt-4o-mini"
635
- */
636
- model: string;
637
- /**
638
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
639
- * @default 2048
640
- */
641
- max_tokens: number;
642
- };
643
- };
644
- "ragas/response_relevancy": {
645
- settings: {
646
- /**
647
- * @description The model to use for evaluation.
648
- * @default "openai/gpt-4o-mini"
649
- */
650
- model: string;
651
- /**
652
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
653
- * @default 2048
654
- */
655
- max_tokens: number;
656
- /**
657
- * @description The model to use for embeddings.
658
- * @default "openai/text-embedding-ada-002"
659
- */
660
- embeddings_model: string;
661
- };
662
- };
663
- "ragas/rouge_score": {
664
- settings: {
665
- /**
666
- * @description ROUGE type
667
- * @default "rouge1"
668
- */
669
- rouge_type: "rouge1" | "rougeL";
670
- /**
671
- * @description ROUGE measure type
672
- * @default "fmeasure"
673
- */
674
- measure_type: "fmeasure" | "precision" | "recall";
675
- };
676
- };
677
- "ragas/rubrics_based_scoring": {
678
- settings: {
679
- /**
680
- * @description The model to use for evaluation.
681
- * @default "openai/gpt-4o-mini"
682
- */
683
- model: string;
684
- /**
685
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
686
- * @default 2048
687
- */
688
- max_tokens: number;
689
- /**
690
- * @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."}]
691
- */
692
- rubrics: {
693
- description: string;
694
- }[];
695
- };
696
- };
697
- "ragas/sql_query_equivalence": {
698
- settings: {
699
- /**
700
- * @description The model to use for evaluation.
701
- * @default "openai/gpt-4o-mini"
702
- */
703
- model: string;
704
- /**
705
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
706
- * @default 2048
707
- */
708
- max_tokens: number;
709
- };
710
- };
711
- "ragas/summarization_score": {
712
- settings: {
713
- /**
714
- * @description The model to use for evaluation.
715
- * @default "openai/gpt-4o-mini"
716
- */
717
- model: string;
718
- /**
719
- * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
720
- * @default 2048
721
- */
722
- max_tokens: number;
723
- };
724
- };
725
- "presidio/pii_detection": {
726
- settings: {
727
- /**
728
- * @description The types of PII to check for in the input.
729
- * @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}
730
- */
731
- entities: {
732
- /**
733
- * @default true
734
- */
735
- credit_card: boolean;
736
- /**
737
- * @default true
738
- */
739
- crypto: boolean;
740
- /**
741
- * @default true
742
- */
743
- email_address: boolean;
744
- /**
745
- * @default true
746
- */
747
- iban_code: boolean;
748
- /**
749
- * @default true
750
- */
751
- ip_address: boolean;
752
- /**
753
- * @default false
754
- */
755
- location: boolean;
756
- /**
757
- * @default false
758
- */
759
- person: boolean;
760
- /**
761
- * @default true
762
- */
763
- phone_number: boolean;
764
- /**
765
- * @default true
766
- */
767
- medical_license: boolean;
768
- /**
769
- * @default false
770
- */
771
- us_bank_number: boolean;
772
- /**
773
- * @default false
774
- */
775
- us_driver_license: boolean;
776
- /**
777
- * @default false
778
- */
779
- us_itin: boolean;
780
- /**
781
- * @default false
782
- */
783
- us_passport: boolean;
784
- /**
785
- * @default false
786
- */
787
- us_ssn: boolean;
788
- /**
789
- * @default false
790
- */
791
- uk_nhs: boolean;
792
- /**
793
- * @default false
794
- */
795
- sg_nric_fin: boolean;
796
- /**
797
- * @default false
798
- */
799
- au_abn: boolean;
800
- /**
801
- * @default false
802
- */
803
- au_acn: boolean;
804
- /**
805
- * @default false
806
- */
807
- au_tfn: boolean;
808
- /**
809
- * @default false
810
- */
811
- au_medicare: boolean;
812
- /**
813
- * @default false
814
- */
815
- in_pan: boolean;
816
- /**
817
- * @default false
818
- */
819
- in_aadhaar: boolean;
820
- /**
821
- * @default false
822
- */
823
- in_vehicle_registration: boolean;
824
- /**
825
- * @default false
826
- */
827
- in_voter: boolean;
828
- /**
829
- * @default false
830
- */
831
- in_passport: boolean;
832
- };
833
- /**
834
- * @description The minimum confidence required for failing the evaluation on a PII match.
835
- * @default 0.5
836
- */
837
- min_threshold: number;
838
- };
839
- };
840
- };
841
-
842
- type Conversation = {
843
- input?: string;
844
- output?: string;
845
- }[];
846
-
847
- type Money = {
848
- currency: string;
849
- amount: number;
850
- };
851
- type EvaluationResultModel = {
852
- status: "processed" | "skipped" | "error";
853
- passed?: boolean;
854
- score?: number;
855
- details?: string;
856
- label?: string;
857
- cost?: Money;
858
- };
859
- type CommonEvaluationParams = {
860
- name?: string;
861
- input?: string;
862
- output?: string;
863
- expectedOutput?: string;
864
- contexts?: RAGChunk[] | string[];
865
- conversation?: Conversation;
866
- asGuardrail?: boolean;
867
- trace?: LangWatchTrace;
868
- span?: LangWatchSpan;
869
- };
870
- type SavedEvaluationParams = {
871
- slug: string;
872
- settings?: Record<string, unknown>;
873
- } & CommonEvaluationParams;
874
- type LangEvalsEvaluationParams<T extends EvaluatorTypes> = {
875
- evaluator: T;
876
- settings?: Evaluators[T]["settings"];
877
- } & CommonEvaluationParams;
878
- type EvaluationParams = SavedEvaluationParams | LangEvalsEvaluationParams<EvaluatorTypes>;
879
-
880
- declare class LangWatchCallbackHandler extends BaseCallbackHandler {
881
- name: string;
882
- trace: LangWatchTrace;
883
- spans: Record<string, LangWatchSpan>;
884
- constructor({ trace }: {
885
- trace: LangWatchTrace;
886
- });
887
- 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>;
888
- private buildLLMSpan;
889
- 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>;
890
- handleNewToken(_token: string, runId: string): Promise<void>;
891
- handleLLMEnd(response: LLMResult, runId: string, _parentRunId?: string | undefined): Promise<void>;
892
- handleLLMError(err: Error, runId: string, _parentRunId?: string | undefined): Promise<void>;
893
- handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, _runType?: string, name?: string): Promise<void>;
894
- handleChainEnd(output: ChainValues, runId: string, _parentRunId?: string | undefined): Promise<void>;
895
- handleChainError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined, _kwargs?: {
896
- inputs?: Record<string, unknown> | undefined;
897
- } | undefined): Promise<void>;
898
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
899
- handleToolEnd(output: string, runId: string, _parentRunId?: string | undefined): Promise<void>;
900
- handleToolError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
901
- handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string | undefined): Promise<void>;
902
- handleRetrieverEnd(documents: DocumentInterface<Record<string, any>>[], runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
903
- handleRetrieverError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
904
- handleAgentAction(_action: AgentAction, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
905
- handleAgentEnd(action: AgentFinish, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
906
- private buildSpan;
907
- private endSpan;
908
- private errorSpan;
909
- private autoconvertTypedValues;
910
- private getParent;
911
- }
912
-
913
- declare class LangWatchExporter implements SpanExporter {
914
- private endpoint;
915
- private apiKey;
916
- private includeAllSpans;
917
- private debug;
918
- private serializer;
919
- constructor(params?: {
920
- endpoint?: string;
921
- apiKey?: string;
922
- includeAllSpans?: boolean;
923
- debug?: boolean;
924
- });
925
- export(allSpans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
926
- private isAiSdkSpan;
927
- shutdown(): Promise<void>;
928
- }
929
-
930
- declare class LangWatch extends EventEmitter {
931
- apiKey: string | undefined;
932
- endpoint: string;
933
- constructor({ apiKey, endpoint, }?: {
934
- apiKey?: string;
935
- endpoint?: string;
936
- });
937
- getTrace({ traceId, metadata, }?: {
938
- traceId?: string;
939
- metadata?: Metadata;
940
- }): LangWatchTrace;
941
- sendTrace(params: CollectorRESTParams): Promise<void>;
942
- _sendTrace(params: CollectorRESTParams): Promise<void>;
943
- }
944
- type AddEvaluationParams = {
945
- evaluationId?: string;
946
- span?: LangWatchSpan;
947
- name: string;
948
- type?: string;
949
- isGuardrail?: boolean;
950
- status?: "processed" | "skipped" | "error";
951
- passed?: boolean;
952
- score?: number;
953
- label?: string;
954
- details?: string;
955
- error?: Error;
956
- timestamps?: RESTEvaluation["timestamps"];
957
- };
958
- declare class LangWatchTrace {
959
- client: LangWatch;
960
- traceId: string;
961
- metadata?: Metadata;
962
- finishedSpans: Record<string, Span>;
963
- langchainCallback?: LangWatchCallbackHandler;
964
- evaluations: RESTEvaluation[];
965
- private currentSpan?;
966
- private timeoutRef?;
967
- constructor({ client, traceId, metadata, }: {
968
- client: LangWatch;
969
- traceId: string;
970
- metadata?: Metadata;
971
- });
972
- update({ metadata }: {
973
- metadata: Metadata;
974
- }): void;
975
- setCurrentSpan(span: LangWatchSpan): void;
976
- getCurrentSpan(): LangWatchSpan | undefined;
977
- resetCurrentSpan(): void;
978
- startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
979
- startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
980
- startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
981
- addEvaluation: ({ evaluationId, span, name, type, isGuardrail, status, passed, score, label, details, error, timestamps, }: AddEvaluationParams) => void;
982
- evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
983
- getLangChainCallback(): LangWatchCallbackHandler;
984
- onEnd(span: Span): void;
985
- delayedSendSpans(): void;
986
- sendSpans(): Promise<void>;
987
- }
988
- declare class LangWatchSpan implements PendingBaseSpan {
989
- trace: LangWatchTrace;
990
- spanId: string;
991
- parentId?: string | null;
992
- type: SpanTypes;
993
- name?: string | null;
994
- input?: PendingBaseSpan["input"];
995
- output?: PendingBaseSpan["output"];
996
- error?: PendingBaseSpan["error"];
997
- timestamps: PendingBaseSpan["timestamps"];
998
- metrics: PendingBaseSpan["metrics"];
999
- constructor({ trace, spanId, parentId, type, name, input, output, error, timestamps, metrics, }: Partial<PendingBaseSpan> & {
1000
- trace: LangWatchTrace;
1001
- });
1002
- update(params: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
1003
- startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
1004
- startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
1005
- startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
1006
- addEvaluation(params: AddEvaluationParams): void;
1007
- evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
1008
- end(params?: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
1009
- }
1010
- declare class LangWatchLLMSpan extends LangWatchSpan implements PendingLLMSpan {
1011
- type: "llm";
1012
- model: PendingLLMSpan["model"];
1013
- params: PendingLLMSpan["params"];
1014
- constructor(params: Partial<PendingLLMSpan> & {
1015
- trace: LangWatchTrace;
1016
- });
1017
- update(params: Partial<PendingLLMSpan>): void;
1018
- end(params?: Partial<PendingLLMSpan>): void;
1019
- }
1020
- declare class LangWatchRAGSpan extends LangWatchSpan implements PendingRAGSpan {
1021
- type: "rag";
1022
- contexts: PendingRAGSpan["contexts"];
1023
- constructor(params: Partial<PendingRAGSpan> & {
1024
- trace: LangWatchTrace;
1025
- });
1026
- update(params: Partial<PendingRAGSpan>): void;
1027
- end(params?: Partial<PendingRAGSpan>): void;
11
+ /**
12
+ * LangWatchExporter extends the OpenTelemetry OTLP HTTP trace exporter
13
+ * to send trace data to LangWatch with proper authentication and metadata headers.
14
+ *
15
+ * This exporter automatically configures:
16
+ * - Authorization headers using the provided API key or environment variables/fallback
17
+ * - SDK version and language identification headers
18
+ * - Proper endpoint configuration for LangWatch ingestion using provided URL or environment variables/fallback
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { LangWatchExporter } from '@langwatch/observability';
23
+ *
24
+ * // Using environment variables/fallback configuration
25
+ * const exporter = new LangWatchExporter();
26
+ *
27
+ * // Using custom API key and endpoint
28
+ *
29
+ * // With environment variables/fallback configuration
30
+ * const exporter = new LangWatchExporter();
31
+ *
32
+ * // With custom API key and endpoint
33
+ * const exporter = new LangWatchExporter('api-key', 'https://custom.langwatch.com');
34
+ * ```
35
+ */
36
+ declare class LangWatchExporter extends OTLPTraceExporter {
37
+ /**
38
+ * Creates a new LangWatchExporter instance.
39
+ *
40
+ * @param apiKey - Optional API key for LangWatch authentication. If not provided,
41
+ * will use environment variables or fallback configuration.
42
+ * @param endpointURL - Optional custom endpoint URL for LangWatch ingestion.
43
+ * If not provided, will use environment variables or fallback configuration.
44
+ */
45
+ constructor(apiKey?: string, endpointURL?: string);
1028
46
  }
1029
47
 
1030
- export { LangWatch, LangWatchExporter, LangWatchLLMSpan, LangWatchRAGSpan, LangWatchSpan, LangWatchTrace, Metadata, PendingBaseSpan, PendingLLMSpan, PendingRAGSpan };
48
+ export { LangWatchExporter };