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
@@ -0,0 +1,897 @@
1
+ export { R as RecordedEvaluationDetails, r as recordEvaluation } from '../record-evaluation-CmxMXa-3.js';
2
+ import '@opentelemetry/api';
3
+
4
+ type EvaluatorTypes = keyof Evaluators;
5
+ type EvaluationResult = {
6
+ status: "processed";
7
+ score?: number | undefined;
8
+ passed?: boolean | undefined;
9
+ label?: string | undefined;
10
+ details?: string | undefined;
11
+ cost?: Money | undefined;
12
+ raw_response?: any;
13
+ };
14
+ type EvaluationResultSkipped = {
15
+ status: "skipped";
16
+ details?: string | undefined;
17
+ };
18
+ type EvaluationResultError = {
19
+ status: "error";
20
+ error_type: string;
21
+ details: string;
22
+ traceback: string[];
23
+ };
24
+ type SingleEvaluationResult = EvaluationResult | EvaluationResultSkipped | EvaluationResultError;
25
+ type Money = {
26
+ currency: string;
27
+ amount: number;
28
+ };
29
+ type Evaluators = {
30
+ "huggingface/llama_guard": {
31
+ settings: {
32
+ /**
33
+ * @description The policy to enforce, described into rules of what it 'Should not' and what it 'Can' do (max 768 tokens)
34
+ * @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."
35
+ */
36
+ policy: string;
37
+ /**
38
+ * @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.
39
+ * @default "input"
40
+ */
41
+ evaluate: "input" | "output" | "both";
42
+ /**
43
+ * @description The provider to use for evaluation. Only CloudFlare AI workers is supported for now.
44
+ * @default "cloudflare/thebloke/llamaguard-7b-awq"
45
+ */
46
+ model: "cloudflare/thebloke/llamaguard-7b-awq";
47
+ };
48
+ };
49
+ "langevals/basic": {
50
+ settings: {
51
+ /**
52
+ * @description List of rules to check, the message must pass all of them
53
+ * @default [{"field": "output", "rule": "not_contains", "value": "artificial intelligence"}]
54
+ */
55
+ rules: {
56
+ /**
57
+ * @default "output"
58
+ */
59
+ field: "input" | "output";
60
+ rule: "contains" | "not_contains" | "matches_regex" | "not_matches_regex";
61
+ value: string;
62
+ }[];
63
+ };
64
+ };
65
+ "langevals/competitor_blocklist": {
66
+ settings: {
67
+ /**
68
+ * @description The competitors that must not be mentioned.
69
+ * @default ["OpenAI", "Google", "Microsoft"]
70
+ */
71
+ competitors: string[];
72
+ };
73
+ };
74
+ "langevals/competitor_llm": {
75
+ settings: {
76
+ /**
77
+ * @description The model to use for evaluation
78
+ * @default "openai/gpt-4o-mini"
79
+ */
80
+ model: string;
81
+ /**
82
+ * @description Max tokens allowed for evaluation
83
+ * @default 8192
84
+ */
85
+ max_tokens: number;
86
+ /**
87
+ * @description The name of your company
88
+ * @default "LangWatch"
89
+ */
90
+ name: string;
91
+ /**
92
+ * @description Description of what your company is specializing at
93
+ * @default "We are providing an LLM observability and evaluation platform"
94
+ */
95
+ description: string;
96
+ };
97
+ };
98
+ "langevals/competitor_llm_function_call": {
99
+ settings: {
100
+ /**
101
+ * @description The model to use for evaluation
102
+ * @default "openai/gpt-4o-mini"
103
+ */
104
+ model: string;
105
+ /**
106
+ * @description Max tokens allowed for evaluation
107
+ * @default 8192
108
+ */
109
+ max_tokens: number;
110
+ /**
111
+ * @description The name of your company
112
+ * @default "LangWatch"
113
+ */
114
+ name: string;
115
+ /**
116
+ * @description Description of what your company is specializing at
117
+ * @default "We are providing an LLM observability and evaluation platform"
118
+ */
119
+ description: string;
120
+ /**
121
+ * @description The competitors that must not be mentioned.
122
+ * @default ["OpenAI", "Google", "Microsoft"]
123
+ */
124
+ competitors: string[];
125
+ };
126
+ };
127
+ "langevals/exact_match": {
128
+ settings: {
129
+ /**
130
+ * @description True if the comparison should be case-sensitive, False otherwise
131
+ * @default false
132
+ */
133
+ case_sensitive: boolean;
134
+ /**
135
+ * @description True if the comparison should trim whitespace, False otherwise
136
+ * @default true
137
+ */
138
+ trim_whitespace: boolean;
139
+ /**
140
+ * @description True if the comparison should remove punctuation, False otherwise
141
+ * @default true
142
+ */
143
+ remove_punctuation: boolean;
144
+ };
145
+ };
146
+ "langevals/llm_answer_match": {
147
+ settings: {
148
+ /**
149
+ * @description The model to use for evaluation
150
+ * @default "openai/gpt-4o-mini"
151
+ */
152
+ model: string;
153
+ /**
154
+ * @description Max tokens allowed for evaluation
155
+ * @default 8192
156
+ */
157
+ max_tokens: number;
158
+ /**
159
+ * @description Prompt for the comparison
160
+ * @default "Verify that the predicted answer matches the gold answer for the question. Style does not matter, for example the gold answer may be more direct while the predicted answer more verbose and still be correct."
161
+ */
162
+ prompt: string;
163
+ };
164
+ };
165
+ "langevals/llm_boolean": {
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 evaluator. We need the guarantee that the output answers what is being asked on the input, please evaluate as False if it doesn't"
179
+ */
180
+ prompt: string;
181
+ };
182
+ };
183
+ "langevals/llm_category": {
184
+ settings: {
185
+ /**
186
+ * @description The model to use for evaluation
187
+ * @default "openai/gpt-4o-mini"
188
+ */
189
+ model: string;
190
+ /**
191
+ * @default 8192
192
+ */
193
+ max_tokens: number;
194
+ /**
195
+ * @description The system prompt to use for the LLM to run the evaluation
196
+ * @default "You are an LLM category evaluator. Please categorize the message in one of the following categories"
197
+ */
198
+ prompt: string;
199
+ /**
200
+ * @description The categories to use for the evaluation
201
+ * @default [{"name": "smalltalk", "description": "Smalltalk with the user"}, {"name": "company", "description": "Questions about the company, what we do, etc"}]
202
+ */
203
+ categories: {
204
+ name: string;
205
+ description: string;
206
+ }[];
207
+ };
208
+ };
209
+ "langevals/llm_score": {
210
+ settings: {
211
+ /**
212
+ * @description The model to use for evaluation
213
+ * @default "openai/gpt-4o-mini"
214
+ */
215
+ model: string;
216
+ /**
217
+ * @default 8192
218
+ */
219
+ max_tokens: number;
220
+ /**
221
+ * @description The system prompt to use for the LLM to run the evaluation
222
+ * @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"
223
+ */
224
+ prompt: string;
225
+ };
226
+ };
227
+ "langevals/off_topic": {
228
+ settings: {
229
+ /**
230
+ * @description The model to use for evaluation
231
+ * @default "openai/gpt-4o-mini"
232
+ */
233
+ model: string;
234
+ /**
235
+ * @description Max tokens allowed for evaluation
236
+ * @default 8192
237
+ */
238
+ max_tokens: number;
239
+ /**
240
+ * @description The list of topics and their short descriptions that the chatbot is allowed to talk about
241
+ * @default [{"topic": "simple_chat", "description": "Smalltalk with the user"}, {"topic": "company", "description": "Questions about the company, what we do, etc"}]
242
+ */
243
+ allowed_topics: {
244
+ topic: string;
245
+ description: string;
246
+ }[];
247
+ };
248
+ };
249
+ "langevals/query_resolution": {
250
+ settings: {
251
+ /**
252
+ * @description The model to use for evaluation
253
+ * @default "openai/gpt-4o-mini"
254
+ */
255
+ model: string;
256
+ /**
257
+ * @description Max tokens allowed for evaluation
258
+ * @default 8192
259
+ */
260
+ max_tokens: number;
261
+ };
262
+ };
263
+ "langevals/similarity": {
264
+ settings: {
265
+ /**
266
+ * @default "output"
267
+ */
268
+ field: "input" | "output";
269
+ /**
270
+ * @default "is_not_similar_to"
271
+ */
272
+ rule: "is_not_similar_to" | "is_similar_to";
273
+ /**
274
+ * @default "example"
275
+ */
276
+ value: string;
277
+ /**
278
+ * @default 0.3
279
+ */
280
+ threshold: number;
281
+ /**
282
+ * @default "openai/text-embedding-3-small"
283
+ */
284
+ embeddings_model: string;
285
+ };
286
+ };
287
+ "langevals/valid_format": {
288
+ settings: {
289
+ /**
290
+ * @default "json"
291
+ */
292
+ format: "json" | "markdown" | "python" | "sql";
293
+ /**
294
+ * @description JSON schema to validate against when format is 'json'
295
+ */
296
+ json_schema?: string;
297
+ };
298
+ };
299
+ "azure/content_safety": {
300
+ settings: {
301
+ /**
302
+ * @description The minimum severity level to consider content as unsafe, from 1 to 7.
303
+ * @default 1
304
+ */
305
+ severity_threshold: 1 | 2 | 3 | 4 | 5 | 6 | 7;
306
+ /**
307
+ * @description The categories of moderation to check for.
308
+ * @default {"Hate": true, "SelfHarm": true, "Sexual": true, "Violence": true}
309
+ */
310
+ categories: {
311
+ /**
312
+ * @default true
313
+ */
314
+ Hate: boolean;
315
+ /**
316
+ * @default true
317
+ */
318
+ SelfHarm: boolean;
319
+ /**
320
+ * @default true
321
+ */
322
+ Sexual: boolean;
323
+ /**
324
+ * @default true
325
+ */
326
+ Violence: boolean;
327
+ };
328
+ /**
329
+ * @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.
330
+ * @default "FourSeverityLevels"
331
+ */
332
+ output_type: "FourSeverityLevels" | "EightSeverityLevels";
333
+ };
334
+ };
335
+ "azure/jailbreak": {
336
+ settings: Record<string, never>;
337
+ };
338
+ "azure/prompt_injection": {
339
+ settings: Record<string, never>;
340
+ };
341
+ "openai/moderation": {
342
+ settings: {
343
+ /**
344
+ * @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.
345
+ * @default "text-moderation-stable"
346
+ */
347
+ model: "text-moderation-stable" | "text-moderation-latest";
348
+ /**
349
+ * @description The categories of content to check for moderation.
350
+ * @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}
351
+ */
352
+ categories: {
353
+ /**
354
+ * @default true
355
+ */
356
+ harassment: boolean;
357
+ /**
358
+ * @default true
359
+ */
360
+ harassment_threatening: boolean;
361
+ /**
362
+ * @default true
363
+ */
364
+ hate: boolean;
365
+ /**
366
+ * @default true
367
+ */
368
+ hate_threatening: boolean;
369
+ /**
370
+ * @default true
371
+ */
372
+ self_harm: boolean;
373
+ /**
374
+ * @default true
375
+ */
376
+ self_harm_instructions: boolean;
377
+ /**
378
+ * @default true
379
+ */
380
+ self_harm_intent: boolean;
381
+ /**
382
+ * @default true
383
+ */
384
+ sexual: boolean;
385
+ /**
386
+ * @default true
387
+ */
388
+ sexual_minors: boolean;
389
+ /**
390
+ * @default true
391
+ */
392
+ violence: boolean;
393
+ /**
394
+ * @default true
395
+ */
396
+ violence_graphic: boolean;
397
+ };
398
+ };
399
+ };
400
+ "lingua/language_detection": {
401
+ settings: {
402
+ /**
403
+ * @description What should be checked
404
+ * @default "input_matches_output"
405
+ */
406
+ check_for: "input_matches_output" | "output_matches_language";
407
+ /**
408
+ * @description The specific language that the output is expected to be
409
+ */
410
+ 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";
411
+ /**
412
+ * @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.
413
+ * @default 7
414
+ */
415
+ min_words: number;
416
+ /**
417
+ * @description Minimum confidence threshold for the language detection. If the confidence is lower than this, the evaluation will be skipped.
418
+ * @default 0.25
419
+ */
420
+ threshold: number;
421
+ };
422
+ };
423
+ "legacy/ragas_answer_correctness": {
424
+ settings: {
425
+ /**
426
+ * @description The model to use for evaluation.
427
+ * @default "openai/gpt-4o-mini"
428
+ */
429
+ model: string;
430
+ /**
431
+ * @description The model to use for embeddings.
432
+ * @default "openai/text-embedding-ada-002"
433
+ */
434
+ embeddings_model: string;
435
+ /**
436
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
437
+ * @default 2048
438
+ */
439
+ max_tokens: number;
440
+ };
441
+ };
442
+ "legacy/ragas_answer_relevancy": {
443
+ settings: {
444
+ /**
445
+ * @description The model to use for evaluation.
446
+ * @default "openai/gpt-4o-mini"
447
+ */
448
+ model: string;
449
+ /**
450
+ * @description The model to use for embeddings.
451
+ * @default "openai/text-embedding-ada-002"
452
+ */
453
+ embeddings_model: string;
454
+ /**
455
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
456
+ * @default 2048
457
+ */
458
+ max_tokens: number;
459
+ };
460
+ };
461
+ "legacy/ragas_context_precision": {
462
+ settings: {
463
+ /**
464
+ * @description The model to use for evaluation.
465
+ * @default "openai/gpt-4o-mini"
466
+ */
467
+ model: string;
468
+ /**
469
+ * @description The model to use for embeddings.
470
+ * @default "openai/text-embedding-ada-002"
471
+ */
472
+ embeddings_model: string;
473
+ /**
474
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
475
+ * @default 2048
476
+ */
477
+ max_tokens: number;
478
+ };
479
+ };
480
+ "legacy/ragas_context_recall": {
481
+ settings: {
482
+ /**
483
+ * @description The model to use for evaluation.
484
+ * @default "openai/gpt-4o-mini"
485
+ */
486
+ model: string;
487
+ /**
488
+ * @description The model to use for embeddings.
489
+ * @default "openai/text-embedding-ada-002"
490
+ */
491
+ embeddings_model: string;
492
+ /**
493
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
494
+ * @default 2048
495
+ */
496
+ max_tokens: number;
497
+ };
498
+ };
499
+ "legacy/ragas_context_relevancy": {
500
+ settings: {
501
+ /**
502
+ * @description The model to use for evaluation.
503
+ * @default "openai/gpt-4o-mini"
504
+ */
505
+ model: string;
506
+ /**
507
+ * @description The model to use for embeddings.
508
+ * @default "openai/text-embedding-ada-002"
509
+ */
510
+ embeddings_model: string;
511
+ /**
512
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
513
+ * @default 2048
514
+ */
515
+ max_tokens: number;
516
+ };
517
+ };
518
+ "legacy/ragas_context_utilization": {
519
+ settings: {
520
+ /**
521
+ * @description The model to use for evaluation.
522
+ * @default "openai/gpt-4o-mini"
523
+ */
524
+ model: string;
525
+ /**
526
+ * @description The model to use for embeddings.
527
+ * @default "openai/text-embedding-ada-002"
528
+ */
529
+ embeddings_model: string;
530
+ /**
531
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
532
+ * @default 2048
533
+ */
534
+ max_tokens: number;
535
+ };
536
+ };
537
+ "legacy/ragas_faithfulness": {
538
+ settings: {
539
+ /**
540
+ * @description The model to use for evaluation.
541
+ * @default "openai/gpt-4o-mini"
542
+ */
543
+ model: string;
544
+ /**
545
+ * @description The model to use for embeddings.
546
+ * @default "openai/text-embedding-ada-002"
547
+ */
548
+ embeddings_model: string;
549
+ /**
550
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
551
+ * @default 2048
552
+ */
553
+ max_tokens: number;
554
+ };
555
+ };
556
+ "example/word_count": {
557
+ settings: Record<string, never>;
558
+ };
559
+ "ragas/bleu_score": {
560
+ settings: Record<string, never>;
561
+ };
562
+ "ragas/context_f1": {
563
+ settings: {
564
+ /**
565
+ * @default "levenshtein"
566
+ */
567
+ distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
568
+ };
569
+ };
570
+ "ragas/context_precision": {
571
+ settings: {
572
+ /**
573
+ * @default "levenshtein"
574
+ */
575
+ distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
576
+ };
577
+ };
578
+ "ragas/context_recall": {
579
+ settings: {
580
+ /**
581
+ * @default "levenshtein"
582
+ */
583
+ distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
584
+ };
585
+ };
586
+ "ragas/factual_correctness": {
587
+ settings: {
588
+ /**
589
+ * @description The model to use for evaluation.
590
+ * @default "openai/gpt-4o-mini"
591
+ */
592
+ model: string;
593
+ /**
594
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
595
+ * @default 2048
596
+ */
597
+ max_tokens: number;
598
+ /**
599
+ * @description The mode to use for the factual correctness metric.
600
+ * @default "f1"
601
+ */
602
+ mode: "f1" | "precision" | "recall";
603
+ /**
604
+ * @description The level of atomicity for claim decomposition.
605
+ * @default "low"
606
+ */
607
+ atomicity: "low" | "high";
608
+ /**
609
+ * @description The level of coverage for claim decomposition.
610
+ * @default "low"
611
+ */
612
+ coverage: "low" | "high";
613
+ };
614
+ };
615
+ "ragas/faithfulness": {
616
+ settings: {
617
+ /**
618
+ * @description The model to use for evaluation.
619
+ * @default "openai/gpt-4o-mini"
620
+ */
621
+ model: string;
622
+ /**
623
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
624
+ * @default 2048
625
+ */
626
+ max_tokens: number;
627
+ /**
628
+ * @description Whether to autodetect 'I don't know' in the output to avoid failing the evaluation.
629
+ * @default true
630
+ */
631
+ autodetect_dont_know: boolean;
632
+ };
633
+ };
634
+ "ragas/response_context_precision": {
635
+ settings: {
636
+ /**
637
+ * @description The model to use for evaluation.
638
+ * @default "openai/gpt-4o-mini"
639
+ */
640
+ model: string;
641
+ /**
642
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
643
+ * @default 2048
644
+ */
645
+ max_tokens: number;
646
+ };
647
+ };
648
+ "ragas/response_context_recall": {
649
+ settings: {
650
+ /**
651
+ * @description The model to use for evaluation.
652
+ * @default "openai/gpt-4o-mini"
653
+ */
654
+ model: string;
655
+ /**
656
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
657
+ * @default 2048
658
+ */
659
+ max_tokens: number;
660
+ };
661
+ };
662
+ "ragas/response_relevancy": {
663
+ settings: {
664
+ /**
665
+ * @description The model to use for evaluation.
666
+ * @default "openai/gpt-4o-mini"
667
+ */
668
+ model: string;
669
+ /**
670
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
671
+ * @default 2048
672
+ */
673
+ max_tokens: number;
674
+ /**
675
+ * @description The model to use for embeddings.
676
+ * @default "openai/text-embedding-ada-002"
677
+ */
678
+ embeddings_model: string;
679
+ };
680
+ };
681
+ "ragas/rouge_score": {
682
+ settings: {
683
+ /**
684
+ * @description ROUGE type
685
+ * @default "rouge1"
686
+ */
687
+ rouge_type: "rouge1" | "rougeL";
688
+ /**
689
+ * @description ROUGE measure type
690
+ * @default "fmeasure"
691
+ */
692
+ measure_type: "fmeasure" | "precision" | "recall";
693
+ };
694
+ };
695
+ "ragas/rubrics_based_scoring": {
696
+ settings: {
697
+ /**
698
+ * @description The model to use for evaluation.
699
+ * @default "openai/gpt-4o-mini"
700
+ */
701
+ model: string;
702
+ /**
703
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
704
+ * @default 2048
705
+ */
706
+ max_tokens: number;
707
+ /**
708
+ * @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."}]
709
+ */
710
+ rubrics: {
711
+ description: string;
712
+ }[];
713
+ };
714
+ };
715
+ "ragas/sql_query_equivalence": {
716
+ settings: {
717
+ /**
718
+ * @description The model to use for evaluation.
719
+ * @default "openai/gpt-4o-mini"
720
+ */
721
+ model: string;
722
+ /**
723
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
724
+ * @default 2048
725
+ */
726
+ max_tokens: number;
727
+ };
728
+ };
729
+ "ragas/summarization_score": {
730
+ settings: {
731
+ /**
732
+ * @description The model to use for evaluation.
733
+ * @default "openai/gpt-4o-mini"
734
+ */
735
+ model: string;
736
+ /**
737
+ * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
738
+ * @default 2048
739
+ */
740
+ max_tokens: number;
741
+ };
742
+ };
743
+ "presidio/pii_detection": {
744
+ settings: {
745
+ /**
746
+ * @description The types of PII to check for in the input.
747
+ * @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}
748
+ */
749
+ entities: {
750
+ /**
751
+ * @default true
752
+ */
753
+ credit_card: boolean;
754
+ /**
755
+ * @default true
756
+ */
757
+ crypto: boolean;
758
+ /**
759
+ * @default true
760
+ */
761
+ email_address: boolean;
762
+ /**
763
+ * @default true
764
+ */
765
+ iban_code: boolean;
766
+ /**
767
+ * @default true
768
+ */
769
+ ip_address: boolean;
770
+ /**
771
+ * @default false
772
+ */
773
+ location: boolean;
774
+ /**
775
+ * @default false
776
+ */
777
+ person: boolean;
778
+ /**
779
+ * @default true
780
+ */
781
+ phone_number: boolean;
782
+ /**
783
+ * @default true
784
+ */
785
+ medical_license: boolean;
786
+ /**
787
+ * @default false
788
+ */
789
+ us_bank_number: boolean;
790
+ /**
791
+ * @default false
792
+ */
793
+ us_driver_license: boolean;
794
+ /**
795
+ * @default false
796
+ */
797
+ us_itin: boolean;
798
+ /**
799
+ * @default false
800
+ */
801
+ us_passport: boolean;
802
+ /**
803
+ * @default false
804
+ */
805
+ us_ssn: boolean;
806
+ /**
807
+ * @default false
808
+ */
809
+ uk_nhs: boolean;
810
+ /**
811
+ * @default false
812
+ */
813
+ sg_nric_fin: boolean;
814
+ /**
815
+ * @default false
816
+ */
817
+ au_abn: boolean;
818
+ /**
819
+ * @default false
820
+ */
821
+ au_acn: boolean;
822
+ /**
823
+ * @default false
824
+ */
825
+ au_tfn: boolean;
826
+ /**
827
+ * @default false
828
+ */
829
+ au_medicare: boolean;
830
+ /**
831
+ * @default false
832
+ */
833
+ in_pan: boolean;
834
+ /**
835
+ * @default false
836
+ */
837
+ in_aadhaar: boolean;
838
+ /**
839
+ * @default false
840
+ */
841
+ in_vehicle_registration: boolean;
842
+ /**
843
+ * @default false
844
+ */
845
+ in_voter: boolean;
846
+ /**
847
+ * @default false
848
+ */
849
+ in_passport: boolean;
850
+ };
851
+ /**
852
+ * @description The minimum confidence required for failing the evaluation on a PII match.
853
+ * @default 0.5
854
+ */
855
+ min_threshold: number;
856
+ };
857
+ };
858
+ };
859
+
860
+ type Conversation = {
861
+ input?: string;
862
+ output?: string;
863
+ }[];
864
+
865
+ interface RAGChunk {
866
+ document_id?: string | null;
867
+ chunk_id?: string | null;
868
+ content: string | Record<string, any> | any[];
869
+ }
870
+
871
+ interface BasicEvaluationData {
872
+ input?: string;
873
+ output?: string;
874
+ expected_output?: unknown;
875
+ contexts?: RAGChunk[] | string[];
876
+ expected_contexts?: RAGChunk[] | string[];
877
+ conversation?: Conversation;
878
+ }
879
+ interface EvaluationDetailsBase {
880
+ name?: string;
881
+ data: BasicEvaluationData | Record<string, unknown>;
882
+ contexts?: RAGChunk[] | string[];
883
+ conversation?: Conversation;
884
+ asGuardrail?: boolean;
885
+ }
886
+ interface SavedEvaluationDetails extends EvaluationDetailsBase {
887
+ slug: string;
888
+ settings?: Record<string, unknown>;
889
+ }
890
+ interface LangEvalsEvaluationDetails<T extends EvaluatorTypes> extends EvaluationDetailsBase {
891
+ evaluator: T;
892
+ settings?: Evaluators[T]["settings"];
893
+ }
894
+ type EvaluationDetails = SavedEvaluationDetails | LangEvalsEvaluationDetails<EvaluatorTypes>;
895
+ declare function runEvaluation(details: EvaluationDetails): Promise<SingleEvaluationResult>;
896
+
897
+ export { type BasicEvaluationData, type EvaluationDetails, type EvaluationDetailsBase, type LangEvalsEvaluationDetails, type SavedEvaluationDetails, runEvaluation };