@perkos/service-ai 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ AIService: () => AIService
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/service.ts
38
+ var import_openai = __toESM(require("openai"));
39
+ var import_replicate = __toESM(require("replicate"));
40
+ var AIService = class {
41
+ constructor(config = {}) {
42
+ this.replicate = null;
43
+ const openrouterKey = config.openrouterApiKey || process.env.OPENROUTER_API_KEY;
44
+ const openaiKey = config.openaiApiKey || process.env.OPENAI_API_KEY;
45
+ const replicateToken = config.replicateApiToken || process.env.REPLICATE_API_TOKEN;
46
+ this.useOpenRouter = !!openrouterKey;
47
+ this.useReplicate = !!replicateToken;
48
+ this.imageModel = config.imageModel || process.env.OPENAI_IMAGE_MODEL || "dall-e-3";
49
+ this.ttsModel = config.ttsModel || process.env.OPENAI_TTS_MODEL || "tts-1";
50
+ this.whisperModel = config.whisperModel || process.env.OPENAI_WHISPER_MODEL || "whisper-1";
51
+ this.moderationModel = config.moderationModel || process.env.OPENAI_MODERATION_MODEL || "omni-moderation-latest";
52
+ this.chatModel = config.chatModel || "openai/gpt-4o";
53
+ if (openrouterKey) {
54
+ this.openrouter = new import_openai.default({
55
+ apiKey: openrouterKey,
56
+ baseURL: config.openrouterBaseUrl || process.env.OPENROUTER_BASE_URL || "https://openrouter.ai/api/v1",
57
+ defaultHeaders: {
58
+ "HTTP-Referer": config.openrouterReferer || process.env.OPENROUTER_REFERER || "http://localhost:3000",
59
+ "X-Title": config.openrouterTitle || process.env.OPENROUTER_TITLE || "PerkOS AI Service"
60
+ }
61
+ });
62
+ } else {
63
+ this.openrouter = new import_openai.default({ apiKey: "dummy" });
64
+ }
65
+ if (replicateToken) {
66
+ this.replicate = new import_replicate.default({ auth: replicateToken });
67
+ }
68
+ if (openaiKey) {
69
+ this.openai = new import_openai.default({ apiKey: openaiKey });
70
+ } else if (!openrouterKey) {
71
+ throw new Error("Either OPENROUTER_API_KEY or OPENAI_API_KEY must be set");
72
+ } else {
73
+ this.openai = new import_openai.default({ apiKey: "dummy" });
74
+ }
75
+ }
76
+ getChatClient() {
77
+ return this.useOpenRouter ? this.openrouter : this.openai;
78
+ }
79
+ getChatModel() {
80
+ return this.useOpenRouter ? this.chatModel : "gpt-4o";
81
+ }
82
+ // Vision & Audio Methods
83
+ async analyzeImage(imageInput, question = "What is in this image?") {
84
+ let url = imageInput;
85
+ if (!imageInput.startsWith("http") && !imageInput.startsWith("data:")) {
86
+ url = `data:image/jpeg;base64,${imageInput}`;
87
+ }
88
+ const response = await this.getChatClient().chat.completions.create({
89
+ model: this.getChatModel(),
90
+ messages: [{ role: "user", content: [{ type: "text", text: question }, { type: "image_url", image_url: { url } }] }]
91
+ });
92
+ return response.choices[0].message.content || "Unable to analyze the image";
93
+ }
94
+ async generateImage(prompt, size = "1024x1024") {
95
+ try {
96
+ const response = await this.openai.images.generate({
97
+ model: this.imageModel,
98
+ prompt,
99
+ n: 1,
100
+ size,
101
+ response_format: "b64_json"
102
+ });
103
+ if (!response.data || response.data.length === 0) throw new Error("No image generated");
104
+ const image = response.data[0];
105
+ return { base64: image.b64_json, revisedPrompt: image.revised_prompt };
106
+ } catch (error) {
107
+ if ((error?.status === 403 || error?.message?.includes("does not have access")) && this.useReplicate && this.replicate) {
108
+ return this.generateImageWithReplicate(prompt, size);
109
+ }
110
+ throw error;
111
+ }
112
+ }
113
+ async generateImageWithReplicate(prompt, size = "1024x1024") {
114
+ if (!this.replicate) throw new Error("Replicate client not initialized");
115
+ const [width, height] = size.split("x").map(Number);
116
+ const aspectRatio = width === height ? "1:1" : width > height ? "16:9" : "9:16";
117
+ const output = await this.replicate.run(
118
+ "black-forest-labs/flux-schnell",
119
+ { input: { prompt, aspect_ratio: aspectRatio, output_format: "png", output_quality: 90 } }
120
+ );
121
+ if (!output || output.length === 0) throw new Error("No image generated by Replicate");
122
+ const imageUrl = output[0];
123
+ const imageResponse = await fetch(imageUrl);
124
+ const arrayBuffer = await imageResponse.arrayBuffer();
125
+ const base64 = Buffer.from(arrayBuffer).toString("base64");
126
+ return { base64, url: imageUrl, revisedPrompt: prompt };
127
+ }
128
+ async transcribeAudio(audioInput) {
129
+ if (!this.replicate) throw new Error("Replicate API token required for audio transcription");
130
+ return this.transcribeWithReplicate(audioInput);
131
+ }
132
+ async transcribeWithReplicate(audioInput) {
133
+ if (!this.replicate) throw new Error("Replicate client not initialized");
134
+ let dataUri;
135
+ if (typeof audioInput === "string") {
136
+ if (audioInput.startsWith("http")) {
137
+ const response = await fetch(audioInput);
138
+ const arrayBuffer = await response.arrayBuffer();
139
+ const base64 = Buffer.from(arrayBuffer).toString("base64");
140
+ const mimeType = response.headers.get("content-type") || "audio/mpeg";
141
+ dataUri = `data:${mimeType};base64,${base64}`;
142
+ } else if (audioInput.startsWith("data:")) {
143
+ dataUri = audioInput;
144
+ } else {
145
+ throw new Error("Invalid string input for transcription");
146
+ }
147
+ } else {
148
+ const arrayBuffer = await audioInput.arrayBuffer();
149
+ const base64 = Buffer.from(arrayBuffer).toString("base64");
150
+ const mimeType = audioInput.type || "audio/mpeg";
151
+ dataUri = `data:${mimeType};base64,${base64}`;
152
+ }
153
+ const output = await this.replicate.run(
154
+ "openai/whisper:4d50797290df275329f202e48c76360b3f22b08d28c196cbc54600319435f8d2",
155
+ { input: { audio: dataUri, model: "large-v3", language: "en", translate: false } }
156
+ );
157
+ return output.transcription || "";
158
+ }
159
+ async synthesizeSpeech(text, voice = "alloy") {
160
+ if (!this.replicate) throw new Error("Replicate API token required for speech synthesis");
161
+ return this.synthesizeWithReplicate(text);
162
+ }
163
+ async synthesizeWithReplicate(text) {
164
+ if (!this.replicate) throw new Error("Replicate client not initialized");
165
+ const output = await this.replicate.run(
166
+ "minimax/speech-02-turbo",
167
+ { input: { text, voice_id: "Friendly_Person" } }
168
+ );
169
+ if (!output) throw new Error("No audio generated by Replicate");
170
+ const audioResponse = await fetch(output);
171
+ const arrayBuffer = await audioResponse.arrayBuffer();
172
+ return Buffer.from(arrayBuffer);
173
+ }
174
+ // NLP Methods
175
+ async summarizeText(text, length = "medium") {
176
+ const lengthInstructions = { short: "in 2-3 sentences", medium: "in 1-2 paragraphs", long: "in 3-4 paragraphs with key points" };
177
+ const response = await this.getChatClient().chat.completions.create({
178
+ model: this.getChatModel(),
179
+ messages: [
180
+ { role: "system", content: "You are a professional summarization assistant." },
181
+ { role: "user", content: `Summarize the following text ${lengthInstructions[length]}:
182
+
183
+ ${text}` }
184
+ ],
185
+ temperature: 0.3
186
+ });
187
+ return response.choices[0].message.content || "Unable to generate summary";
188
+ }
189
+ async translateText(text, sourceLang, targetLang) {
190
+ const response = await this.getChatClient().chat.completions.create({
191
+ model: this.getChatModel(),
192
+ messages: [
193
+ { role: "system", content: `Translate accurately from ${sourceLang} to ${targetLang}.` },
194
+ { role: "user", content: text }
195
+ ],
196
+ temperature: 0.2
197
+ });
198
+ return { translation: response.choices[0].message.content || "", confidence: 0.95 };
199
+ }
200
+ async analyzeSentiment(text) {
201
+ const response = await this.getChatClient().chat.completions.create({
202
+ model: this.getChatModel(),
203
+ messages: [
204
+ { role: "system", content: 'Analyze sentiment. Respond with JSON: {"sentiment": "positive"|"negative"|"neutral", "score": 0.0-1.0, "emotions": []}' },
205
+ { role: "user", content: text }
206
+ ],
207
+ temperature: 0.1,
208
+ response_format: { type: "json_object" }
209
+ });
210
+ const result = JSON.parse(response.choices[0].message.content || "{}");
211
+ return { sentiment: result.sentiment || "neutral", score: result.score || 0.5, emotions: result.emotions || [] };
212
+ }
213
+ async moderateContent(content) {
214
+ try {
215
+ const moderation = await this.openai.moderations.create({ input: content, model: this.moderationModel });
216
+ const result = moderation.results[0];
217
+ return {
218
+ flagged: result.flagged,
219
+ categories: result.categories,
220
+ categoryScores: result.category_scores
221
+ };
222
+ } catch {
223
+ const response = await this.getChatClient().chat.completions.create({
224
+ model: this.getChatModel(),
225
+ messages: [
226
+ { role: "system", content: 'Analyze content for policy violations. Respond with JSON: {"flagged": bool, "categories": {}, "categoryScores": {}}' },
227
+ { role: "user", content: `Analyze: ${content}` }
228
+ ],
229
+ temperature: 0.1,
230
+ response_format: { type: "json_object" }
231
+ });
232
+ return JSON.parse(response.choices[0].message.content || '{"flagged":false,"categories":{},"categoryScores":{}}');
233
+ }
234
+ }
235
+ async simplifyText(text, readingLevel = "middle") {
236
+ const levelInstructions = {
237
+ elementary: "5th grade reading level",
238
+ middle: "8th grade reading level",
239
+ high: "high school reading level"
240
+ };
241
+ const response = await this.getChatClient().chat.completions.create({
242
+ model: this.getChatModel(),
243
+ messages: [
244
+ { role: "system", content: `Rewrite at ${levelInstructions[readingLevel]}.` },
245
+ { role: "user", content: text }
246
+ ],
247
+ temperature: 0.3
248
+ });
249
+ return response.choices[0].message.content || text;
250
+ }
251
+ async extractEntities(text) {
252
+ const response = await this.getChatClient().chat.completions.create({
253
+ model: this.getChatModel(),
254
+ messages: [
255
+ { role: "system", content: 'Extract entities. Respond with JSON: {"entities": [{"text": "", "type": "", "position": 0}]}' },
256
+ { role: "user", content: text }
257
+ ],
258
+ temperature: 0.1,
259
+ response_format: { type: "json_object" }
260
+ });
261
+ return JSON.parse(response.choices[0].message.content || '{"entities":[]}');
262
+ }
263
+ // Business Tools
264
+ async generateEmail(purpose, tone = "formal", keyPoints) {
265
+ const response = await this.getChatClient().chat.completions.create({
266
+ model: this.getChatModel(),
267
+ messages: [
268
+ { role: "system", content: `Generate ${tone} email. Respond with JSON: {"subject": "", "body": ""}` },
269
+ { role: "user", content: `Purpose: ${purpose}
270
+ Key points:
271
+ ${keyPoints.map((p) => `- ${p}`).join("\n")}` }
272
+ ],
273
+ temperature: 0.4,
274
+ response_format: { type: "json_object" }
275
+ });
276
+ return JSON.parse(response.choices[0].message.content || '{"subject":"","body":""}');
277
+ }
278
+ async generateProductDescription(productName, features, targetAudience) {
279
+ const audienceText = targetAudience ? `
280
+ Target audience: ${targetAudience}` : "";
281
+ const response = await this.getChatClient().chat.completions.create({
282
+ model: this.getChatModel(),
283
+ messages: [
284
+ { role: "system", content: "Create compelling, SEO-optimized product descriptions." },
285
+ { role: "user", content: `Product: ${productName}
286
+ Features:
287
+ ${features.map((f) => `- ${f}`).join("\n")}${audienceText}` }
288
+ ],
289
+ temperature: 0.5
290
+ });
291
+ return response.choices[0].message.content || "";
292
+ }
293
+ async optimizeSEO(content, keywords) {
294
+ const response = await this.getChatClient().chat.completions.create({
295
+ model: this.getChatModel(),
296
+ messages: [
297
+ { role: "system", content: 'Optimize for SEO. Respond with JSON: {"optimizedContent": "", "analysis": ""}' },
298
+ { role: "user", content: `Content:
299
+ ${content}
300
+
301
+ Keywords: ${keywords.join(", ")}` }
302
+ ],
303
+ temperature: 0.4,
304
+ response_format: { type: "json_object" }
305
+ });
306
+ return JSON.parse(response.choices[0].message.content || '{"optimizedContent":"","analysis":""}');
307
+ }
308
+ // Developer Tools
309
+ async generateCode(description, language, framework) {
310
+ const frameworkText = framework ? ` using ${framework}` : "";
311
+ const response = await this.getChatClient().chat.completions.create({
312
+ model: this.getChatModel(),
313
+ messages: [
314
+ { role: "system", content: `Generate ${language} code. Respond with JSON: {"code": "", "explanation": ""}` },
315
+ { role: "user", content: `Generate ${language} code${frameworkText}: ${description}` }
316
+ ],
317
+ temperature: 0.2,
318
+ response_format: { type: "json_object" }
319
+ });
320
+ return JSON.parse(response.choices[0].message.content || '{"code":"","explanation":""}');
321
+ }
322
+ async reviewCode(code, language) {
323
+ const response = await this.getChatClient().chat.completions.create({
324
+ model: this.getChatModel(),
325
+ messages: [
326
+ { role: "system", content: `Review ${language} code. Respond with JSON: {"issues": [], "suggestions": [], "securityConcerns": []}` },
327
+ { role: "user", content: code }
328
+ ],
329
+ temperature: 0.1,
330
+ response_format: { type: "json_object" }
331
+ });
332
+ return JSON.parse(response.choices[0].message.content || '{"issues":[],"suggestions":[],"securityConcerns":[]}');
333
+ }
334
+ async generateSQLQuery(schema, query) {
335
+ const response = await this.getChatClient().chat.completions.create({
336
+ model: this.getChatModel(),
337
+ messages: [
338
+ { role: "system", content: 'Generate SQL. Respond with JSON: {"query": "", "explanation": ""}' },
339
+ { role: "user", content: `Schema:
340
+ ${schema}
341
+
342
+ Generate SQL for: ${query}` }
343
+ ],
344
+ temperature: 0.1,
345
+ response_format: { type: "json_object" }
346
+ });
347
+ return JSON.parse(response.choices[0].message.content || '{"query":"","explanation":""}');
348
+ }
349
+ async generateRegex(description) {
350
+ const response = await this.getChatClient().chat.completions.create({
351
+ model: this.getChatModel(),
352
+ messages: [
353
+ { role: "system", content: 'Generate regex. Respond with JSON: {"pattern": "", "explanation": "", "examples": []}' },
354
+ { role: "user", content: description }
355
+ ],
356
+ temperature: 0.1,
357
+ response_format: { type: "json_object" }
358
+ });
359
+ return JSON.parse(response.choices[0].message.content || '{"pattern":"","explanation":"","examples":[]}');
360
+ }
361
+ async generateAPIDocs(code, framework) {
362
+ const response = await this.getChatClient().chat.completions.create({
363
+ model: this.getChatModel(),
364
+ messages: [
365
+ { role: "system", content: `Generate API docs for ${framework}. Respond with JSON: {"documentation": "", "openapi": ""}` },
366
+ { role: "user", content: code }
367
+ ],
368
+ temperature: 0.3,
369
+ response_format: { type: "json_object" }
370
+ });
371
+ return JSON.parse(response.choices[0].message.content || '{"documentation":""}');
372
+ }
373
+ async extractTextOCR(image) {
374
+ const url = image.startsWith("data:image") ? image : `data:image/jpeg;base64,${image}`;
375
+ const response = await this.getChatClient().chat.completions.create({
376
+ model: this.getChatModel(),
377
+ messages: [
378
+ { role: "system", content: "Extract all text from the image accurately." },
379
+ { role: "user", content: [{ type: "text", text: "Extract all text:" }, { type: "image_url", image_url: { url } }] }
380
+ ]
381
+ });
382
+ return { text: response.choices[0].message.content || "", confidence: 0.95 };
383
+ }
384
+ async generateQuiz(topic, numQuestions = 5, difficulty = "medium") {
385
+ const response = await this.getChatClient().chat.completions.create({
386
+ model: this.getChatModel(),
387
+ messages: [
388
+ { role: "system", content: `Generate ${difficulty} quiz. Respond with JSON: {"questions": [{"question": "", "options": [], "correctIndex": 0, "explanation": ""}]}` },
389
+ { role: "user", content: `Topic: ${topic}
390
+ Questions: ${numQuestions}` }
391
+ ],
392
+ temperature: 0.5,
393
+ response_format: { type: "json_object" }
394
+ });
395
+ return JSON.parse(response.choices[0].message.content || '{"questions":[]}');
396
+ }
397
+ };
398
+ // Annotate the CommonJS export names for ESM import in node:
399
+ 0 && (module.exports = {
400
+ AIService
401
+ });
402
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/service.ts"],"sourcesContent":["/**\n * @perkos/ai-service\n * Multi-provider AI service abstraction with OpenRouter, Replicate, and OpenAI support\n */\n\nexport { AIService } from \"./service\";\nexport type {\n AIServiceConfig,\n AIProvider,\n ImageGenerateResult,\n TranscriptionResult,\n TranslationResult,\n SentimentResult,\n ModerationResult,\n EntityExtractionResult,\n CodeGenerationResult,\n CodeReviewResult,\n OCRResult,\n QuizResult,\n ImageAnalysisOptions,\n ImageGenerateOptions,\n TranscribeOptions,\n SpeechOptions,\n SummarizeOptions,\n TranslateOptions,\n SentimentOptions,\n ModerationOptions,\n SimplifyOptions,\n EntityOptions,\n EmailOptions,\n ProductDescriptionOptions,\n SEOOptions,\n CodeGenerateOptions,\n CodeReviewOptions,\n SQLQueryOptions,\n RegexOptions,\n APIDocsOptions,\n OCROptions,\n QuizOptions,\n} from \"./types\";\n","/**\n * AI Service Implementation\n * Multi-provider AI service with OpenRouter, Replicate, and OpenAI support\n */\n\nimport OpenAI from \"openai\";\nimport Replicate from \"replicate\";\nimport type {\n AIServiceConfig,\n ImageGenerateResult,\n TranslationResult,\n SentimentResult,\n ModerationResult,\n EntityResult,\n EmailResult,\n CodeGenerateResult,\n CodeReviewResult,\n SQLResult,\n RegexResult,\n SEOResult,\n APIDocsResult,\n OCRResult,\n QuizResult,\n SummaryLength,\n ReadingLevel,\n EmailTone,\n Difficulty,\n Voice,\n} from \"./types\";\n\nexport class AIService {\n private openai: OpenAI;\n private openrouter: OpenAI;\n private replicate: Replicate | null = null;\n private useOpenRouter: boolean;\n private useReplicate: boolean;\n\n private imageModel: string;\n private ttsModel: string;\n private whisperModel: string;\n private moderationModel: string;\n private chatModel: string;\n\n constructor(config: AIServiceConfig = {}) {\n const openrouterKey = config.openrouterApiKey || process.env.OPENROUTER_API_KEY;\n const openaiKey = config.openaiApiKey || process.env.OPENAI_API_KEY;\n const replicateToken = config.replicateApiToken || process.env.REPLICATE_API_TOKEN;\n\n this.useOpenRouter = !!openrouterKey;\n this.useReplicate = !!replicateToken;\n\n // Model configuration\n this.imageModel = config.imageModel || process.env.OPENAI_IMAGE_MODEL || \"dall-e-3\";\n this.ttsModel = config.ttsModel || process.env.OPENAI_TTS_MODEL || \"tts-1\";\n this.whisperModel = config.whisperModel || process.env.OPENAI_WHISPER_MODEL || \"whisper-1\";\n this.moderationModel = config.moderationModel || process.env.OPENAI_MODERATION_MODEL || \"omni-moderation-latest\";\n this.chatModel = config.chatModel || \"openai/gpt-4o\";\n\n if (openrouterKey) {\n this.openrouter = new OpenAI({\n apiKey: openrouterKey,\n baseURL: config.openrouterBaseUrl || process.env.OPENROUTER_BASE_URL || \"https://openrouter.ai/api/v1\",\n defaultHeaders: {\n \"HTTP-Referer\": config.openrouterReferer || process.env.OPENROUTER_REFERER || \"http://localhost:3000\",\n \"X-Title\": config.openrouterTitle || process.env.OPENROUTER_TITLE || \"PerkOS AI Service\",\n },\n });\n } else {\n this.openrouter = new OpenAI({ apiKey: \"dummy\" });\n }\n\n if (replicateToken) {\n this.replicate = new Replicate({ auth: replicateToken });\n }\n\n if (openaiKey) {\n this.openai = new OpenAI({ apiKey: openaiKey });\n } else if (!openrouterKey) {\n throw new Error(\"Either OPENROUTER_API_KEY or OPENAI_API_KEY must be set\");\n } else {\n this.openai = new OpenAI({ apiKey: \"dummy\" });\n }\n }\n\n private getChatClient(): OpenAI {\n return this.useOpenRouter ? this.openrouter : this.openai;\n }\n\n private getChatModel(): string {\n return this.useOpenRouter ? this.chatModel : \"gpt-4o\";\n }\n\n // Vision & Audio Methods\n\n async analyzeImage(imageInput: string, question: string = \"What is in this image?\"): Promise<string> {\n let url = imageInput;\n if (!imageInput.startsWith(\"http\") && !imageInput.startsWith(\"data:\")) {\n url = `data:image/jpeg;base64,${imageInput}`;\n }\n\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [{ role: \"user\", content: [{ type: \"text\", text: question }, { type: \"image_url\", image_url: { url } }] }],\n });\n\n return response.choices[0].message.content || \"Unable to analyze the image\";\n }\n\n async generateImage(prompt: string, size: \"1024x1024\" = \"1024x1024\"): Promise<ImageGenerateResult> {\n try {\n const response = await this.openai.images.generate({\n model: this.imageModel,\n prompt, n: 1, size, response_format: \"b64_json\",\n });\n if (!response.data || response.data.length === 0) throw new Error(\"No image generated\");\n const image = response.data[0];\n return { base64: image.b64_json, revisedPrompt: image.revised_prompt };\n } catch (error: any) {\n if ((error?.status === 403 || error?.message?.includes(\"does not have access\")) && this.useReplicate && this.replicate) {\n return this.generateImageWithReplicate(prompt, size);\n }\n throw error;\n }\n }\n\n private async generateImageWithReplicate(prompt: string, size: \"1024x1024\" = \"1024x1024\"): Promise<ImageGenerateResult> {\n if (!this.replicate) throw new Error(\"Replicate client not initialized\");\n\n const [width, height] = size.split(\"x\").map(Number);\n const aspectRatio = width === height ? \"1:1\" : width > height ? \"16:9\" : \"9:16\";\n\n const output = await this.replicate.run(\n \"black-forest-labs/flux-schnell\",\n { input: { prompt, aspect_ratio: aspectRatio, output_format: \"png\", output_quality: 90 } }\n ) as string[];\n\n if (!output || output.length === 0) throw new Error(\"No image generated by Replicate\");\n\n const imageUrl = output[0];\n const imageResponse = await fetch(imageUrl);\n const arrayBuffer = await imageResponse.arrayBuffer();\n const base64 = Buffer.from(arrayBuffer).toString(\"base64\");\n\n return { base64, url: imageUrl, revisedPrompt: prompt };\n }\n\n async transcribeAudio(audioInput: File | Blob | string): Promise<string> {\n if (!this.replicate) throw new Error(\"Replicate API token required for audio transcription\");\n return this.transcribeWithReplicate(audioInput);\n }\n\n private async transcribeWithReplicate(audioInput: File | Blob | string): Promise<string> {\n if (!this.replicate) throw new Error(\"Replicate client not initialized\");\n\n let dataUri: string;\n\n if (typeof audioInput === \"string\") {\n if (audioInput.startsWith(\"http\")) {\n const response = await fetch(audioInput);\n const arrayBuffer = await response.arrayBuffer();\n const base64 = Buffer.from(arrayBuffer).toString(\"base64\");\n const mimeType = response.headers.get(\"content-type\") || \"audio/mpeg\";\n dataUri = `data:${mimeType};base64,${base64}`;\n } else if (audioInput.startsWith(\"data:\")) {\n dataUri = audioInput;\n } else {\n throw new Error(\"Invalid string input for transcription\");\n }\n } else {\n const arrayBuffer = await audioInput.arrayBuffer();\n const base64 = Buffer.from(arrayBuffer).toString(\"base64\");\n const mimeType = audioInput.type || \"audio/mpeg\";\n dataUri = `data:${mimeType};base64,${base64}`;\n }\n\n const output = await this.replicate.run(\n \"openai/whisper:4d50797290df275329f202e48c76360b3f22b08d28c196cbc54600319435f8d2\",\n { input: { audio: dataUri, model: \"large-v3\", language: \"en\", translate: false } }\n ) as { transcription: string };\n\n return output.transcription || \"\";\n }\n\n async synthesizeSpeech(text: string, voice: Voice = \"alloy\"): Promise<Buffer> {\n if (!this.replicate) throw new Error(\"Replicate API token required for speech synthesis\");\n return this.synthesizeWithReplicate(text);\n }\n\n private async synthesizeWithReplicate(text: string): Promise<Buffer> {\n if (!this.replicate) throw new Error(\"Replicate client not initialized\");\n\n const output = await this.replicate.run(\n \"minimax/speech-02-turbo\",\n { input: { text, voice_id: \"Friendly_Person\" } }\n ) as unknown as string;\n\n if (!output) throw new Error(\"No audio generated by Replicate\");\n\n const audioResponse = await fetch(output);\n const arrayBuffer = await audioResponse.arrayBuffer();\n return Buffer.from(arrayBuffer);\n }\n\n // NLP Methods\n\n async summarizeText(text: string, length: SummaryLength = \"medium\"): Promise<string> {\n const lengthInstructions = { short: \"in 2-3 sentences\", medium: \"in 1-2 paragraphs\", long: \"in 3-4 paragraphs with key points\" };\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: \"You are a professional summarization assistant.\" },\n { role: \"user\", content: `Summarize the following text ${lengthInstructions[length]}:\\n\\n${text}` }\n ],\n temperature: 0.3,\n });\n return response.choices[0].message.content || \"Unable to generate summary\";\n }\n\n async translateText(text: string, sourceLang: string, targetLang: string): Promise<TranslationResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Translate accurately from ${sourceLang} to ${targetLang}.` },\n { role: \"user\", content: text }\n ],\n temperature: 0.2,\n });\n return { translation: response.choices[0].message.content || \"\", confidence: 0.95 };\n }\n\n async analyzeSentiment(text: string): Promise<SentimentResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Analyze sentiment. Respond with JSON: {\"sentiment\": \"positive\"|\"negative\"|\"neutral\", \"score\": 0.0-1.0, \"emotions\": []}' },\n { role: \"user\", content: text }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n const result = JSON.parse(response.choices[0].message.content || \"{}\");\n return { sentiment: result.sentiment || \"neutral\", score: result.score || 0.5, emotions: result.emotions || [] };\n }\n\n async moderateContent(content: string): Promise<ModerationResult> {\n try {\n const moderation = await this.openai.moderations.create({ input: content, model: this.moderationModel });\n const result = moderation.results[0];\n return {\n flagged: result.flagged,\n categories: result.categories as unknown as Record<string, boolean>,\n categoryScores: result.category_scores as unknown as Record<string, number>,\n };\n } catch {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Analyze content for policy violations. Respond with JSON: {\"flagged\": bool, \"categories\": {}, \"categoryScores\": {}}' },\n { role: \"user\", content: `Analyze: ${content}` }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"flagged\":false,\"categories\":{},\"categoryScores\":{}}');\n }\n }\n\n async simplifyText(text: string, readingLevel: ReadingLevel = \"middle\"): Promise<string> {\n const levelInstructions = {\n elementary: \"5th grade reading level\",\n middle: \"8th grade reading level\",\n high: \"high school reading level\"\n };\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Rewrite at ${levelInstructions[readingLevel]}.` },\n { role: \"user\", content: text }\n ],\n temperature: 0.3,\n });\n return response.choices[0].message.content || text;\n }\n\n async extractEntities(text: string): Promise<EntityResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Extract entities. Respond with JSON: {\"entities\": [{\"text\": \"\", \"type\": \"\", \"position\": 0}]}' },\n { role: \"user\", content: text }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"entities\":[]}');\n }\n\n // Business Tools\n\n async generateEmail(purpose: string, tone: EmailTone = \"formal\", keyPoints: string[]): Promise<EmailResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Generate ${tone} email. Respond with JSON: {\"subject\": \"\", \"body\": \"\"}` },\n { role: \"user\", content: `Purpose: ${purpose}\\nKey points:\\n${keyPoints.map(p => `- ${p}`).join('\\n')}` }\n ],\n temperature: 0.4,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"subject\":\"\",\"body\":\"\"}');\n }\n\n async generateProductDescription(productName: string, features: string[], targetAudience?: string): Promise<string> {\n const audienceText = targetAudience ? `\\nTarget audience: ${targetAudience}` : '';\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: \"Create compelling, SEO-optimized product descriptions.\" },\n { role: \"user\", content: `Product: ${productName}\\nFeatures:\\n${features.map(f => `- ${f}`).join('\\n')}${audienceText}` }\n ],\n temperature: 0.5,\n });\n return response.choices[0].message.content || \"\";\n }\n\n async optimizeSEO(content: string, keywords: string[]): Promise<SEOResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Optimize for SEO. Respond with JSON: {\"optimizedContent\": \"\", \"analysis\": \"\"}' },\n { role: \"user\", content: `Content:\\n${content}\\n\\nKeywords: ${keywords.join(', ')}` }\n ],\n temperature: 0.4,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"optimizedContent\":\"\",\"analysis\":\"\"}');\n }\n\n // Developer Tools\n\n async generateCode(description: string, language: string, framework?: string): Promise<CodeGenerateResult> {\n const frameworkText = framework ? ` using ${framework}` : '';\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Generate ${language} code. Respond with JSON: {\"code\": \"\", \"explanation\": \"\"}` },\n { role: \"user\", content: `Generate ${language} code${frameworkText}: ${description}` }\n ],\n temperature: 0.2,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"code\":\"\",\"explanation\":\"\"}');\n }\n\n async reviewCode(code: string, language: string): Promise<CodeReviewResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Review ${language} code. Respond with JSON: {\"issues\": [], \"suggestions\": [], \"securityConcerns\": []}` },\n { role: \"user\", content: code }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"issues\":[],\"suggestions\":[],\"securityConcerns\":[]}');\n }\n\n async generateSQLQuery(schema: string, query: string): Promise<SQLResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Generate SQL. Respond with JSON: {\"query\": \"\", \"explanation\": \"\"}' },\n { role: \"user\", content: `Schema:\\n${schema}\\n\\nGenerate SQL for: ${query}` }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"query\":\"\",\"explanation\":\"\"}');\n }\n\n async generateRegex(description: string): Promise<RegexResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: 'Generate regex. Respond with JSON: {\"pattern\": \"\", \"explanation\": \"\", \"examples\": []}' },\n { role: \"user\", content: description }\n ],\n temperature: 0.1,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"pattern\":\"\",\"explanation\":\"\",\"examples\":[]}');\n }\n\n async generateAPIDocs(code: string, framework: string): Promise<APIDocsResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Generate API docs for ${framework}. Respond with JSON: {\"documentation\": \"\", \"openapi\": \"\"}` },\n { role: \"user\", content: code }\n ],\n temperature: 0.3,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"documentation\":\"\"}');\n }\n\n async extractTextOCR(image: string): Promise<OCRResult> {\n const url = image.startsWith(\"data:image\") ? image : `data:image/jpeg;base64,${image}`;\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: \"Extract all text from the image accurately.\" },\n { role: \"user\", content: [{ type: \"text\", text: \"Extract all text:\" }, { type: \"image_url\", image_url: { url } }] }\n ],\n });\n return { text: response.choices[0].message.content || \"\", confidence: 0.95 };\n }\n\n async generateQuiz(topic: string, numQuestions: number = 5, difficulty: Difficulty = \"medium\"): Promise<QuizResult> {\n const response = await this.getChatClient().chat.completions.create({\n model: this.getChatModel(),\n messages: [\n { role: \"system\", content: `Generate ${difficulty} quiz. Respond with JSON: {\"questions\": [{\"question\": \"\", \"options\": [], \"correctIndex\": 0, \"explanation\": \"\"}]}` },\n { role: \"user\", content: `Topic: ${topic}\\nQuestions: ${numQuestions}` }\n ],\n temperature: 0.5,\n response_format: { type: \"json_object\" }\n });\n return JSON.parse(response.choices[0].message.content || '{\"questions\":[]}');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,oBAAmB;AACnB,uBAAsB;AAwBf,IAAM,YAAN,MAAgB;AAAA,EAarB,YAAY,SAA0B,CAAC,GAAG;AAV1C,SAAQ,YAA8B;AAWpC,UAAM,gBAAgB,OAAO,oBAAoB,QAAQ,IAAI;AAC7D,UAAM,YAAY,OAAO,gBAAgB,QAAQ,IAAI;AACrD,UAAM,iBAAiB,OAAO,q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