glin-profanity 3.2.0 → 3.2.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 (65) hide show
  1. package/dist/{types-Dj5vaoch.d.cts → Filter-BGcyIAvO.d.ts} +2 -162
  2. package/dist/{types-Dj5vaoch.d.ts → Filter-D34Wsmrj.d.cts} +2 -162
  3. package/dist/frameworks/index.cjs +5257 -0
  4. package/dist/frameworks/index.d.cts +2 -0
  5. package/dist/frameworks/index.d.ts +2 -0
  6. package/dist/frameworks/index.js +5252 -0
  7. package/dist/frameworks/nextjs.cjs +5257 -0
  8. package/dist/frameworks/nextjs.d.cts +173 -0
  9. package/dist/frameworks/nextjs.d.ts +173 -0
  10. package/dist/frameworks/nextjs.js +5252 -0
  11. package/dist/index.cjs +0 -28
  12. package/dist/index.d.cts +5 -29
  13. package/dist/index.d.ts +5 -29
  14. package/dist/index.js +1 -28
  15. package/dist/integrations/index.cjs +6110 -0
  16. package/dist/integrations/index.d.cts +5 -0
  17. package/dist/integrations/index.d.ts +5 -0
  18. package/dist/integrations/index.js +6082 -0
  19. package/dist/integrations/langchain.cjs +5252 -0
  20. package/dist/integrations/langchain.d.cts +231 -0
  21. package/dist/integrations/langchain.d.ts +231 -0
  22. package/dist/integrations/langchain.js +5239 -0
  23. package/dist/integrations/openai.cjs +5367 -0
  24. package/dist/integrations/openai.d.cts +167 -0
  25. package/dist/integrations/openai.d.ts +167 -0
  26. package/dist/integrations/openai.js +5362 -0
  27. package/dist/integrations/semantic.cjs +5314 -0
  28. package/dist/integrations/semantic.d.cts +268 -0
  29. package/dist/integrations/semantic.d.ts +268 -0
  30. package/dist/integrations/semantic.js +5309 -0
  31. package/dist/integrations/vercel-ai.cjs +5282 -0
  32. package/dist/integrations/vercel-ai.d.cts +224 -0
  33. package/dist/integrations/vercel-ai.d.ts +224 -0
  34. package/dist/integrations/vercel-ai.js +5273 -0
  35. package/dist/ml/index.cjs +207 -0
  36. package/dist/ml/index.d.cts +5 -2
  37. package/dist/ml/index.d.ts +5 -2
  38. package/dist/ml/index.js +203 -1
  39. package/dist/ml/transformers.cjs +5237 -0
  40. package/dist/ml/transformers.d.cts +232 -0
  41. package/dist/ml/transformers.d.ts +232 -0
  42. package/dist/ml/transformers.js +5231 -0
  43. package/dist/multimodal/audio.cjs +5269 -0
  44. package/dist/multimodal/audio.d.cts +255 -0
  45. package/dist/multimodal/audio.d.ts +255 -0
  46. package/dist/multimodal/audio.js +5264 -0
  47. package/dist/multimodal/index.cjs +5432 -0
  48. package/dist/multimodal/index.d.cts +4 -0
  49. package/dist/multimodal/index.d.ts +4 -0
  50. package/dist/multimodal/index.js +5422 -0
  51. package/dist/multimodal/ocr.cjs +5193 -0
  52. package/dist/multimodal/ocr.d.cts +157 -0
  53. package/dist/multimodal/ocr.d.ts +157 -0
  54. package/dist/multimodal/ocr.js +5187 -0
  55. package/dist/react.cjs +5133 -0
  56. package/dist/react.d.cts +13 -0
  57. package/dist/react.d.ts +13 -0
  58. package/dist/react.js +5131 -0
  59. package/dist/types-B9c_ik4k.d.cts +88 -0
  60. package/dist/types-B9c_ik4k.d.ts +88 -0
  61. package/dist/types-BuKh9tvV.d.ts +20 -0
  62. package/dist/types-Ct_ueYqw.d.cts +76 -0
  63. package/dist/types-Ct_ueYqw.d.ts +76 -0
  64. package/dist/types-DI8nzwWc.d.cts +20 -0
  65. package/package.json +170 -3
@@ -0,0 +1,224 @@
1
+ import { F as FilterConfig } from '../types-B9c_ik4k.cjs';
2
+ export { C as CheckProfanityResult, L as Language } from '../types-B9c_ik4k.cjs';
3
+
4
+ /**
5
+ * Vercel AI SDK Integration for glin-profanity
6
+ *
7
+ * Provides ready-to-use tools for the Vercel AI SDK.
8
+ * Compatible with Next.js, Remix, SvelteKit, and other frameworks.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { generateText } from 'ai';
13
+ * import { openai } from '@ai-sdk/openai';
14
+ * import { profanityTools } from 'glin-profanity/ai/vercel';
15
+ *
16
+ * const { text, toolCalls } = await generateText({
17
+ * model: openai('gpt-4o'),
18
+ * prompt: 'Check if "Hello world" contains profanity',
19
+ * tools: profanityTools,
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ * @module glin-profanity/ai/vercel
25
+ */
26
+
27
+ /**
28
+ * Vercel AI SDK tool definition
29
+ */
30
+ interface VercelAITool<TInput = unknown, TOutput = unknown> {
31
+ description: string;
32
+ inputSchema: unknown;
33
+ execute: (input: TInput) => Promise<TOutput>;
34
+ }
35
+ /**
36
+ * Tool input types
37
+ */
38
+ interface CheckProfanityInput {
39
+ text: string;
40
+ languages?: string[];
41
+ detectLeetspeak?: boolean;
42
+ normalizeUnicode?: boolean;
43
+ }
44
+ interface CensorTextInput {
45
+ text: string;
46
+ replacement?: string;
47
+ languages?: string[];
48
+ }
49
+ interface BatchCheckInput {
50
+ texts: string[];
51
+ languages?: string[];
52
+ detectLeetspeak?: boolean;
53
+ }
54
+ interface AnalyzeContextInput {
55
+ text: string;
56
+ languages?: string[];
57
+ contextWindow?: number;
58
+ confidenceThreshold?: number;
59
+ }
60
+ /**
61
+ * Tool output types
62
+ */
63
+ interface CheckProfanityOutput {
64
+ containsProfanity: boolean;
65
+ profaneWords: string[];
66
+ severityMap?: Record<string, number>;
67
+ wordCount: number;
68
+ }
69
+ interface CensorTextOutput {
70
+ originalText: string;
71
+ censoredText: string;
72
+ profaneWordsFound: string[];
73
+ wasModified: boolean;
74
+ }
75
+ interface BatchCheckOutput {
76
+ totalTexts: number;
77
+ flaggedCount: number;
78
+ cleanCount: number;
79
+ results: Array<{
80
+ index: number;
81
+ text: string;
82
+ containsProfanity: boolean;
83
+ profaneWords: string[];
84
+ }>;
85
+ }
86
+ interface AnalyzeContextOutput {
87
+ containsProfanity: boolean;
88
+ profaneWords: string[];
89
+ contextScore?: number;
90
+ matches?: unknown[];
91
+ reason?: string;
92
+ }
93
+ interface SupportedLanguagesOutput {
94
+ languages: string[];
95
+ count: number;
96
+ }
97
+ /**
98
+ * Creates a profanity check tool for Vercel AI SDK
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * import { generateText, tool } from 'ai';
103
+ * import { createCheckProfanityTool } from 'glin-profanity/ai/vercel';
104
+ *
105
+ * const { text } = await generateText({
106
+ * model: openai('gpt-4o'),
107
+ * prompt: 'Check this text for profanity: "Hello world"',
108
+ * tools: {
109
+ * checkProfanity: createCheckProfanityTool(),
110
+ * },
111
+ * });
112
+ * ```
113
+ */
114
+ declare function createCheckProfanityTool(): VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
115
+ /**
116
+ * Creates a censor text tool for Vercel AI SDK
117
+ */
118
+ declare function createCensorTextTool(): VercelAITool<CensorTextInput, CensorTextOutput>;
119
+ /**
120
+ * Creates a batch check tool for Vercel AI SDK
121
+ */
122
+ declare function createBatchCheckTool(): VercelAITool<BatchCheckInput, BatchCheckOutput>;
123
+ /**
124
+ * Creates a context analysis tool for Vercel AI SDK
125
+ */
126
+ declare function createContextAnalysisTool(): VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
127
+ /**
128
+ * Creates a supported languages tool for Vercel AI SDK
129
+ */
130
+ declare function createSupportedLanguagesTool(): VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
131
+ /**
132
+ * Pre-built profanity tools for Vercel AI SDK
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * import { generateText } from 'ai';
137
+ * import { openai } from '@ai-sdk/openai';
138
+ * import { profanityTools } from 'glin-profanity/ai/vercel';
139
+ *
140
+ * const { text, toolCalls } = await generateText({
141
+ * model: openai('gpt-4o'),
142
+ * prompt: 'Check if "Hello world" contains profanity',
143
+ * tools: profanityTools,
144
+ * });
145
+ * ```
146
+ */
147
+ declare const profanityTools: {
148
+ checkProfanity: VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
149
+ censorText: VercelAITool<CensorTextInput, CensorTextOutput>;
150
+ batchCheckProfanity: VercelAITool<BatchCheckInput, BatchCheckOutput>;
151
+ analyzeContext: VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
152
+ getSupportedLanguages: VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
153
+ };
154
+ /**
155
+ * Creates all profanity tools with custom configuration
156
+ *
157
+ * @returns Object containing all Vercel AI SDK-compatible tools
158
+ */
159
+ declare function createAllProfanityTools(): {
160
+ checkProfanity: VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
161
+ censorText: VercelAITool<CensorTextInput, CensorTextOutput>;
162
+ batchCheckProfanity: VercelAITool<BatchCheckInput, BatchCheckOutput>;
163
+ analyzeContext: VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
164
+ getSupportedLanguages: VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
165
+ };
166
+ /**
167
+ * Middleware for Next.js API routes to automatically check request bodies
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * // app/api/chat/route.ts
172
+ * import { profanityMiddleware } from 'glin-profanity/ai/vercel';
173
+ *
174
+ * export async function POST(req: Request) {
175
+ * const body = await req.json();
176
+ *
177
+ * // Check for profanity in user message
178
+ * const check = profanityMiddleware.checkMessage(body.message);
179
+ * if (check.blocked) {
180
+ * return Response.json({ error: check.reason }, { status: 400 });
181
+ * }
182
+ *
183
+ * // Continue with AI processing...
184
+ * }
185
+ * ```
186
+ */
187
+ declare const profanityMiddleware: {
188
+ /**
189
+ * Check a message for profanity
190
+ */
191
+ checkMessage(message: string, config?: Partial<FilterConfig>): {
192
+ blocked: boolean;
193
+ reason: string;
194
+ profaneWords: string[];
195
+ censoredMessage: string;
196
+ };
197
+ /**
198
+ * Censor a message (replace profanity with asterisks)
199
+ */
200
+ censorMessage(message: string, replacement?: string, config?: Partial<FilterConfig>): {
201
+ original: string;
202
+ censored: string;
203
+ wasModified: boolean;
204
+ profaneWords: string[];
205
+ };
206
+ /**
207
+ * Check array of messages (useful for chat history)
208
+ */
209
+ checkMessages(messages: Array<{
210
+ role: string;
211
+ content: string;
212
+ }>, config?: Partial<FilterConfig>): {
213
+ hasIssues: boolean;
214
+ flaggedMessages: {
215
+ index: number;
216
+ role: string;
217
+ containsProfanity: boolean;
218
+ profaneWords: string[];
219
+ }[];
220
+ totalMessages: number;
221
+ };
222
+ };
223
+
224
+ export { type AnalyzeContextInput, type AnalyzeContextOutput, type BatchCheckInput, type BatchCheckOutput, type CensorTextInput, type CensorTextOutput, type CheckProfanityInput, type CheckProfanityOutput, FilterConfig, type SupportedLanguagesOutput, type VercelAITool, createAllProfanityTools, createBatchCheckTool, createCensorTextTool, createCheckProfanityTool, createContextAnalysisTool, createSupportedLanguagesTool, profanityMiddleware, profanityTools };
@@ -0,0 +1,224 @@
1
+ import { F as FilterConfig } from '../types-B9c_ik4k.js';
2
+ export { C as CheckProfanityResult, L as Language } from '../types-B9c_ik4k.js';
3
+
4
+ /**
5
+ * Vercel AI SDK Integration for glin-profanity
6
+ *
7
+ * Provides ready-to-use tools for the Vercel AI SDK.
8
+ * Compatible with Next.js, Remix, SvelteKit, and other frameworks.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { generateText } from 'ai';
13
+ * import { openai } from '@ai-sdk/openai';
14
+ * import { profanityTools } from 'glin-profanity/ai/vercel';
15
+ *
16
+ * const { text, toolCalls } = await generateText({
17
+ * model: openai('gpt-4o'),
18
+ * prompt: 'Check if "Hello world" contains profanity',
19
+ * tools: profanityTools,
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ * @module glin-profanity/ai/vercel
25
+ */
26
+
27
+ /**
28
+ * Vercel AI SDK tool definition
29
+ */
30
+ interface VercelAITool<TInput = unknown, TOutput = unknown> {
31
+ description: string;
32
+ inputSchema: unknown;
33
+ execute: (input: TInput) => Promise<TOutput>;
34
+ }
35
+ /**
36
+ * Tool input types
37
+ */
38
+ interface CheckProfanityInput {
39
+ text: string;
40
+ languages?: string[];
41
+ detectLeetspeak?: boolean;
42
+ normalizeUnicode?: boolean;
43
+ }
44
+ interface CensorTextInput {
45
+ text: string;
46
+ replacement?: string;
47
+ languages?: string[];
48
+ }
49
+ interface BatchCheckInput {
50
+ texts: string[];
51
+ languages?: string[];
52
+ detectLeetspeak?: boolean;
53
+ }
54
+ interface AnalyzeContextInput {
55
+ text: string;
56
+ languages?: string[];
57
+ contextWindow?: number;
58
+ confidenceThreshold?: number;
59
+ }
60
+ /**
61
+ * Tool output types
62
+ */
63
+ interface CheckProfanityOutput {
64
+ containsProfanity: boolean;
65
+ profaneWords: string[];
66
+ severityMap?: Record<string, number>;
67
+ wordCount: number;
68
+ }
69
+ interface CensorTextOutput {
70
+ originalText: string;
71
+ censoredText: string;
72
+ profaneWordsFound: string[];
73
+ wasModified: boolean;
74
+ }
75
+ interface BatchCheckOutput {
76
+ totalTexts: number;
77
+ flaggedCount: number;
78
+ cleanCount: number;
79
+ results: Array<{
80
+ index: number;
81
+ text: string;
82
+ containsProfanity: boolean;
83
+ profaneWords: string[];
84
+ }>;
85
+ }
86
+ interface AnalyzeContextOutput {
87
+ containsProfanity: boolean;
88
+ profaneWords: string[];
89
+ contextScore?: number;
90
+ matches?: unknown[];
91
+ reason?: string;
92
+ }
93
+ interface SupportedLanguagesOutput {
94
+ languages: string[];
95
+ count: number;
96
+ }
97
+ /**
98
+ * Creates a profanity check tool for Vercel AI SDK
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * import { generateText, tool } from 'ai';
103
+ * import { createCheckProfanityTool } from 'glin-profanity/ai/vercel';
104
+ *
105
+ * const { text } = await generateText({
106
+ * model: openai('gpt-4o'),
107
+ * prompt: 'Check this text for profanity: "Hello world"',
108
+ * tools: {
109
+ * checkProfanity: createCheckProfanityTool(),
110
+ * },
111
+ * });
112
+ * ```
113
+ */
114
+ declare function createCheckProfanityTool(): VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
115
+ /**
116
+ * Creates a censor text tool for Vercel AI SDK
117
+ */
118
+ declare function createCensorTextTool(): VercelAITool<CensorTextInput, CensorTextOutput>;
119
+ /**
120
+ * Creates a batch check tool for Vercel AI SDK
121
+ */
122
+ declare function createBatchCheckTool(): VercelAITool<BatchCheckInput, BatchCheckOutput>;
123
+ /**
124
+ * Creates a context analysis tool for Vercel AI SDK
125
+ */
126
+ declare function createContextAnalysisTool(): VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
127
+ /**
128
+ * Creates a supported languages tool for Vercel AI SDK
129
+ */
130
+ declare function createSupportedLanguagesTool(): VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
131
+ /**
132
+ * Pre-built profanity tools for Vercel AI SDK
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * import { generateText } from 'ai';
137
+ * import { openai } from '@ai-sdk/openai';
138
+ * import { profanityTools } from 'glin-profanity/ai/vercel';
139
+ *
140
+ * const { text, toolCalls } = await generateText({
141
+ * model: openai('gpt-4o'),
142
+ * prompt: 'Check if "Hello world" contains profanity',
143
+ * tools: profanityTools,
144
+ * });
145
+ * ```
146
+ */
147
+ declare const profanityTools: {
148
+ checkProfanity: VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
149
+ censorText: VercelAITool<CensorTextInput, CensorTextOutput>;
150
+ batchCheckProfanity: VercelAITool<BatchCheckInput, BatchCheckOutput>;
151
+ analyzeContext: VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
152
+ getSupportedLanguages: VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
153
+ };
154
+ /**
155
+ * Creates all profanity tools with custom configuration
156
+ *
157
+ * @returns Object containing all Vercel AI SDK-compatible tools
158
+ */
159
+ declare function createAllProfanityTools(): {
160
+ checkProfanity: VercelAITool<CheckProfanityInput, CheckProfanityOutput>;
161
+ censorText: VercelAITool<CensorTextInput, CensorTextOutput>;
162
+ batchCheckProfanity: VercelAITool<BatchCheckInput, BatchCheckOutput>;
163
+ analyzeContext: VercelAITool<AnalyzeContextInput, AnalyzeContextOutput>;
164
+ getSupportedLanguages: VercelAITool<Record<string, never>, SupportedLanguagesOutput>;
165
+ };
166
+ /**
167
+ * Middleware for Next.js API routes to automatically check request bodies
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * // app/api/chat/route.ts
172
+ * import { profanityMiddleware } from 'glin-profanity/ai/vercel';
173
+ *
174
+ * export async function POST(req: Request) {
175
+ * const body = await req.json();
176
+ *
177
+ * // Check for profanity in user message
178
+ * const check = profanityMiddleware.checkMessage(body.message);
179
+ * if (check.blocked) {
180
+ * return Response.json({ error: check.reason }, { status: 400 });
181
+ * }
182
+ *
183
+ * // Continue with AI processing...
184
+ * }
185
+ * ```
186
+ */
187
+ declare const profanityMiddleware: {
188
+ /**
189
+ * Check a message for profanity
190
+ */
191
+ checkMessage(message: string, config?: Partial<FilterConfig>): {
192
+ blocked: boolean;
193
+ reason: string;
194
+ profaneWords: string[];
195
+ censoredMessage: string;
196
+ };
197
+ /**
198
+ * Censor a message (replace profanity with asterisks)
199
+ */
200
+ censorMessage(message: string, replacement?: string, config?: Partial<FilterConfig>): {
201
+ original: string;
202
+ censored: string;
203
+ wasModified: boolean;
204
+ profaneWords: string[];
205
+ };
206
+ /**
207
+ * Check array of messages (useful for chat history)
208
+ */
209
+ checkMessages(messages: Array<{
210
+ role: string;
211
+ content: string;
212
+ }>, config?: Partial<FilterConfig>): {
213
+ hasIssues: boolean;
214
+ flaggedMessages: {
215
+ index: number;
216
+ role: string;
217
+ containsProfanity: boolean;
218
+ profaneWords: string[];
219
+ }[];
220
+ totalMessages: number;
221
+ };
222
+ };
223
+
224
+ export { type AnalyzeContextInput, type AnalyzeContextOutput, type BatchCheckInput, type BatchCheckOutput, type CensorTextInput, type CensorTextOutput, type CheckProfanityInput, type CheckProfanityOutput, FilterConfig, type SupportedLanguagesOutput, type VercelAITool, createAllProfanityTools, createBatchCheckTool, createCensorTextTool, createCheckProfanityTool, createContextAnalysisTool, createSupportedLanguagesTool, profanityMiddleware, profanityTools };