@workglow/ai-provider 0.0.97 → 0.0.98
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/HFT_JobRunFns-ajak33q5.js +60 -0
- package/dist/HFT_JobRunFns-ajak33q5.js.map +9 -0
- package/dist/anthropic/index.js +11 -92
- package/dist/anthropic/index.js.map +4 -7
- package/dist/google-gemini/index.js +11 -103
- package/dist/google-gemini/index.js.map +4 -7
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/hf-transformers/index.js +46 -1080
- package/dist/hf-transformers/index.js.map +4 -9
- package/dist/index-2pvfsjyx.js +857 -0
- package/dist/index-2pvfsjyx.js.map +10 -0
- package/dist/index-34rcjm0y.js +78 -0
- package/dist/index-34rcjm0y.js.map +12 -0
- package/dist/index-9w5hs4zc.js +73 -0
- package/dist/index-9w5hs4zc.js.map +12 -0
- package/dist/index-jd3bbc2x.js +11 -0
- package/dist/index-jd3bbc2x.js.map +9 -0
- package/dist/index-kctzvn3c.js +75 -0
- package/dist/index-kctzvn3c.js.map +12 -0
- package/dist/index-m0r2hvfz.js +57 -0
- package/dist/index-m0r2hvfz.js.map +10 -0
- package/dist/index-rmbnv0rw.js +169 -0
- package/dist/index-rmbnv0rw.js.map +11 -0
- package/dist/index-tn88s0ke.js +71 -0
- package/dist/index-tn88s0ke.js.map +12 -0
- package/dist/index-wnmajxg6.js +86 -0
- package/dist/index-wnmajxg6.js.map +12 -0
- package/dist/index-xyavfrb8.js +97 -0
- package/dist/index-xyavfrb8.js.map +12 -0
- package/dist/index.browser-jd3bbc2x.js +11 -0
- package/dist/index.browser-jd3bbc2x.js.map +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -1369
- package/dist/index.js.map +3 -20
- package/dist/provider-hf-inference/HFI_Worker.d.ts +7 -0
- package/dist/provider-hf-inference/HFI_Worker.d.ts.map +1 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts +40 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts +7 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts +17 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts +146 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.d.ts +11 -0
- package/dist/provider-hf-inference/index.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.js +209 -0
- package/dist/provider-hf-inference/index.js.map +11 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts +38 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts.map +1 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts +7 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts +8 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts +20 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts +209 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.d.ts +11 -0
- package/dist/provider-llamacpp/index.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.js +365 -0
- package/dist/provider-llamacpp/index.js.map +11 -0
- package/dist/provider-ollama/index.browser.js +4 -8
- package/dist/provider-ollama/index.browser.js.map +2 -2
- package/dist/provider-ollama/index.js +12 -88
- package/dist/provider-ollama/index.js.map +4 -7
- package/dist/provider-openai/index.js +11 -95
- package/dist/provider-openai/index.js.map +4 -7
- package/dist/tf-mediapipe/index.js +4 -8
- package/dist/tf-mediapipe/index.js.map +2 -2
- package/package.json +39 -18
- package/dist/ggml/server.d.ts +0 -2
- package/dist/ggml/server.d.ts.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/hf-transformers/common/HFT_JobRunFns.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n BackgroundRemovalPipeline,\n DocumentQuestionAnsweringSingle,\n FeatureExtractionPipeline,\n FillMaskPipeline,\n FillMaskSingle,\n ImageClassificationPipeline,\n ImageFeatureExtractionPipeline,\n ImageSegmentationPipeline,\n ImageToTextPipeline,\n ObjectDetectionPipeline,\n // @ts-ignore temporary \"fix\"\n PretrainedModelOptions,\n QuestionAnsweringPipeline,\n RawImage,\n SummarizationPipeline,\n SummarizationSingle,\n TextClassificationOutput,\n TextClassificationPipeline,\n TextGenerationPipeline,\n TextGenerationSingle,\n TokenClassificationPipeline,\n TokenClassificationSingle,\n TranslationPipeline,\n TranslationSingle,\n ZeroShotClassificationPipeline,\n ZeroShotImageClassificationPipeline,\n ZeroShotObjectDetectionPipeline,\n} from \"@sroussey/transformers\";\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n BackgroundRemovalTaskInput,\n BackgroundRemovalTaskOutput,\n DownloadModelTaskRunInput,\n DownloadModelTaskRunOutput,\n ImageClassificationTaskInput,\n ImageClassificationTaskOutput,\n ImageEmbeddingTaskInput,\n ImageEmbeddingTaskOutput,\n ImageSegmentationTaskInput,\n ImageSegmentationTaskOutput,\n ImageToTextTaskInput,\n ImageToTextTaskOutput,\n ObjectDetectionTaskInput,\n ObjectDetectionTaskOutput,\n TextClassificationTaskInput,\n TextClassificationTaskOutput,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextFillMaskTaskInput,\n TextFillMaskTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextLanguageDetectionTaskInput,\n TextLanguageDetectionTaskOutput,\n TextNamedEntityRecognitionTaskInput,\n TextNamedEntityRecognitionTaskOutput,\n TextQuestionAnswerTaskInput,\n TextQuestionAnswerTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n TextTranslationTaskInput,\n TextTranslationTaskOutput,\n UnloadModelTaskRunInput,\n UnloadModelTaskRunOutput,\n} from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\n\nlet _transformersSdk: typeof import(\"@sroussey/transformers\") | undefined;\nasync function loadTransformersSDK() {\n if (!_transformersSdk) {\n try {\n _transformersSdk = await import(\"@sroussey/transformers\");\n } catch {\n throw new Error(\n \"@sroussey/transformers is required for HuggingFace Transformers tasks. Install it with: bun add @sroussey/transformers\"\n );\n }\n }\n return _transformersSdk;\n}\n\nimport { TypedArray } from \"@workglow/util\";\nimport { CallbackStatus } from \"./HFT_CallbackStatus\";\nimport { HTF_CACHE_NAME } from \"./HFT_Constants\";\nimport { HfTransformersOnnxModelConfig } from \"./HFT_ModelSchema\";\n\nconst pipelines = new Map<string, any>();\n\n/** In-flight pipeline loads by cache key. Ensures only one load per model at a time to avoid corrupt ONNX files (Protobuf parsing failed). */\nconst pipelineLoadPromises = new Map<string, Promise<any>>();\n\n/**\n * Clear all cached pipelines\n */\nexport function clearPipelineCache(): void {\n pipelines.clear();\n}\n\n/**\n * Generate a cache key for a pipeline that includes all configuration options\n * that affect pipeline creation (model_path, pipeline, dtype, device)\n */\nfunction getPipelineCacheKey(model: HfTransformersOnnxModelConfig): string {\n const dtype = model.provider_config.dtype || \"q8\";\n const device = model.provider_config.device || \"\";\n return `${model.provider_config.model_path}:${model.provider_config.pipeline}:${dtype}:${device}`;\n}\n\n/**\n * Helper function to get a pipeline for a model\n * @param progressScaleMax - Maximum progress value for download phase (100 for download-only, 10 for download+run)\n */\nconst getPipeline = async (\n model: HfTransformersOnnxModelConfig,\n onProgress: (progress: number, message?: string, details?: any) => void,\n options: PretrainedModelOptions = {},\n progressScaleMax: number = 10\n) => {\n const cacheKey = getPipelineCacheKey(model);\n if (pipelines.has(cacheKey)) {\n return pipelines.get(cacheKey);\n }\n\n // Single-flight: only one load per model at a time to avoid concurrent writes to the same\n // ONNX cache path (which can yield \"Protobuf parsing failed\" when one process reads while another writes).\n const inFlight = pipelineLoadPromises.get(cacheKey);\n if (inFlight) {\n await inFlight;\n const cached = pipelines.get(cacheKey);\n if (cached) return cached;\n // Load failed for the other caller; fall through to retry (we remove from map in finally).\n }\n\n const loadPromise = doGetPipeline(model, onProgress, options, progressScaleMax, cacheKey).finally(\n () => {\n pipelineLoadPromises.delete(cacheKey);\n }\n );\n pipelineLoadPromises.set(cacheKey, loadPromise);\n return loadPromise;\n};\n\nconst doGetPipeline = async (\n model: HfTransformersOnnxModelConfig,\n onProgress: (progress: number, message?: string, details?: any) => void,\n options: PretrainedModelOptions,\n progressScaleMax: number,\n cacheKey: string\n) => {\n // Track file sizes and progress for weighted calculation\n const fileSizes = new Map<string, number>();\n const fileProgress = new Map<string, number>();\n const fileCompleted = new Set<string>();\n const fileFirstSent = new Set<string>();\n const fileLastSent = new Set<string>();\n const fileLastEventTime = new Map<string, number>();\n const pendingProgressByFile = new Map<\n string,\n { progress: number; file: string; fileProgress: number }\n >();\n let throttleTimer: ReturnType<typeof setTimeout> | null = null;\n const THROTTLE_MS = 160;\n\n // Pre-estimate total download size based on typical model structure:\n // 3 tiny files (~1KB each) + 1 medium file (~20MB) + 0-2 large files (~1GB each if present)\n const estimatedTinyFiles = 3;\n const estimatedMediumFiles = 1;\n const estimatedTinySize = 1024; // 1KB\n const estimatedMediumSize = 20 * 1024 * 1024; // 20MB\n const estimatedLargeSize = 1024 * 1024 * 1024; // 1GB\n\n // Start with minimum estimate (4 files), add large files dynamically as we discover them\n const baseEstimate =\n estimatedTinyFiles * estimatedTinySize + estimatedMediumFiles * estimatedMediumSize;\n\n /**\n * Sends a progress event, respecting throttling but always sending first/last per file\n */\n const sendProgress = (\n overallProgress: number,\n file: string,\n fileProgressValue: number,\n isFirst: boolean,\n isLast: boolean\n ): void => {\n const now = Date.now();\n const lastTime = fileLastEventTime.get(file) || 0;\n const timeSinceLastEvent = now - lastTime;\n const shouldThrottle = !isFirst && !isLast && timeSinceLastEvent < THROTTLE_MS;\n\n if (shouldThrottle) {\n // Store pending progress for this file\n pendingProgressByFile.set(file, {\n progress: overallProgress,\n file,\n fileProgress: fileProgressValue,\n });\n // Schedule sending if not already scheduled\n if (!throttleTimer) {\n const timeRemaining = Math.max(1, THROTTLE_MS - timeSinceLastEvent);\n throttleTimer = setTimeout(() => {\n // Send all pending progress events\n for (const [pendingFile, pending] of pendingProgressByFile.entries()) {\n onProgress(Math.round(pending.progress), \"Downloading model\", {\n file: pendingFile,\n progress: pending.fileProgress,\n });\n fileLastEventTime.set(pendingFile, Date.now());\n }\n pendingProgressByFile.clear();\n throttleTimer = null;\n }, timeRemaining);\n }\n return;\n }\n\n // Send immediately\n onProgress(Math.round(overallProgress), \"Downloading model\", {\n file,\n progress: fileProgressValue,\n });\n fileLastEventTime.set(file, now);\n // Clear any pending progress for this file since we're sending it now\n pendingProgressByFile.delete(file);\n if (throttleTimer && pendingProgressByFile.size === 0) {\n clearTimeout(throttleTimer);\n throttleTimer = null;\n }\n };\n\n // Track whether we've seen a substantial file (to avoid premature progress reports for tiny config files)\n let hasSeenSubstantialFile = false;\n const substantialFileThreshold = 1024 * 1024; // 1MB - files larger than this are substantial\n\n // Get the abort signal from options if provided\n const abortSignal = options.abort_signal;\n\n // Create a callback status object for progress tracking\n const progressCallback = (status: CallbackStatus) => {\n // Check if operation has been aborted before processing progress\n if (abortSignal?.aborted) {\n return; // Don't process progress for aborted operations\n }\n\n if (status.status === \"progress\") {\n const file = status.file;\n const fileTotal = status.total;\n const fileProgressValue = status.progress;\n\n // Track file size on first progress event\n if (!fileSizes.has(file)) {\n fileSizes.set(file, fileTotal);\n fileProgress.set(file, 0);\n\n // Check if this is a substantial file\n if (fileTotal >= substantialFileThreshold) {\n hasSeenSubstantialFile = true;\n }\n }\n\n // Update file progress\n fileProgress.set(file, fileProgressValue);\n\n // Check if file is complete\n const isComplete = fileProgressValue >= 100;\n if (isComplete && !fileCompleted.has(file)) {\n fileCompleted.add(file);\n fileProgress.set(file, 100);\n }\n\n // Calculate actual loaded bytes and adjust estimated total\n let actualLoadedSize = 0;\n let actualTotalSize = 0;\n\n // Categorize seen files and track their actual sizes\n const tinyThreshold = 100 * 1024; // 100KB - files smaller are config/vocab\n const mediumThreshold = 100 * 1024 * 1024; // 100MB - tokenizer and small models\n let seenTinyCount = 0;\n let seenMediumCount = 0;\n let seenLargeCount = 0;\n\n for (const [trackedFile, size] of fileSizes.entries()) {\n actualTotalSize += size;\n const progress = fileProgress.get(trackedFile) || 0;\n actualLoadedSize += (size * progress) / 100;\n\n // Categorize file\n if (size < tinyThreshold) {\n seenTinyCount++;\n } else if (size < mediumThreshold) {\n seenMediumCount++;\n } else {\n seenLargeCount++;\n }\n }\n\n // Adjust estimated total size:\n // - Start with actual sizes of seen files\n // - Add estimates for unseen tiny/medium files\n // - For large files: conservatively assume 1 until we've seen all expected files\n const unseenTinyFiles = Math.max(0, estimatedTinyFiles - seenTinyCount);\n const unseenMediumFiles = Math.max(0, estimatedMediumFiles - seenMediumCount);\n\n // Dynamically estimate large files:\n // - If we've seen a large file, assume up to 2 total\n // - Otherwise, conservatively assume 1 large file might exist to prevent premature 100% progress\n // - This prevents the progress from jumping when a large file appears unexpectedly\n let estimatedLargeFiles: number;\n if (seenLargeCount > 0) {\n estimatedLargeFiles = 2; // We've seen at least one, expect up to 2\n } else {\n estimatedLargeFiles = 1; // Haven't seen any large files yet, but assume 1 might exist\n }\n const unseenLargeFiles = Math.max(0, estimatedLargeFiles - seenLargeCount);\n\n const adjustedTotalSize =\n actualTotalSize +\n unseenTinyFiles * estimatedTinySize +\n unseenMediumFiles * estimatedMediumSize +\n unseenLargeFiles * estimatedLargeSize;\n\n // Scale progress to the configured range (0-100 for download-only, 0-10 for download+run)\n const rawProgress = adjustedTotalSize > 0 ? (actualLoadedSize / adjustedTotalSize) * 100 : 0;\n const overallProgress = (rawProgress * progressScaleMax) / 100;\n\n // Determine if this is first or last event for this file\n const isFirst = !fileFirstSent.has(file);\n const isLast = isComplete && !fileLastSent.has(file);\n\n if (isFirst) {\n fileFirstSent.add(file);\n }\n if (isLast) {\n fileLastSent.add(file);\n }\n\n // Only report progress if we've seen a substantial file (to avoid premature 100% for tiny config files)\n if (hasSeenSubstantialFile) {\n sendProgress(overallProgress, file, fileProgressValue, isFirst, isLast);\n }\n } else if (status.status === \"done\" || status.status === \"download\") {\n // Handle file completion from bookend events\n const file = status.file;\n\n // Check if this file should mark the start of substantial downloads\n const fileSize = fileSizes.get(file) || 0;\n if (fileSize >= substantialFileThreshold) {\n hasSeenSubstantialFile = true;\n }\n\n if (!fileCompleted.has(file)) {\n fileCompleted.add(file);\n fileProgress.set(file, 100);\n\n // Recalculate overall progress using same logic as progress handler\n let actualLoadedSize = 0;\n let actualTotalSize = 0;\n\n const tinyThreshold = 100 * 1024; // 100KB - files smaller are config/vocab\n const mediumThreshold = 100 * 1024 * 1024; // 100MB - tokenizer and small models\n let seenTinyCount = 0;\n let seenMediumCount = 0;\n let seenLargeCount = 0;\n\n for (const [trackedFile, size] of fileSizes.entries()) {\n actualTotalSize += size;\n const progress = fileProgress.get(trackedFile) || 0;\n actualLoadedSize += (size * progress) / 100;\n\n // Categorize file\n if (size < tinyThreshold) {\n seenTinyCount++;\n } else if (size < mediumThreshold) {\n seenMediumCount++;\n } else {\n seenLargeCount++;\n }\n }\n\n // Adjust estimated total size (same logic as progress handler)\n const unseenTinyFiles = Math.max(0, estimatedTinyFiles - seenTinyCount);\n const unseenMediumFiles = Math.max(0, estimatedMediumFiles - seenMediumCount);\n\n // Dynamically estimate large files (same logic as progress handler)\n let estimatedLargeFiles: number;\n if (seenLargeCount > 0) {\n estimatedLargeFiles = 2;\n } else {\n estimatedLargeFiles = 1;\n }\n const unseenLargeFiles = Math.max(0, estimatedLargeFiles - seenLargeCount);\n\n const adjustedTotalSize =\n actualTotalSize +\n unseenTinyFiles * estimatedTinySize +\n unseenMediumFiles * estimatedMediumSize +\n unseenLargeFiles * estimatedLargeSize;\n\n // Scale progress to the configured range (0-100 for download-only, 0-10 for download+run)\n const rawProgress =\n adjustedTotalSize > 0 ? (actualLoadedSize / adjustedTotalSize) * 100 : 0;\n const overallProgress = (rawProgress * progressScaleMax) / 100;\n const isLast = !fileLastSent.has(file);\n if (isLast) {\n fileLastSent.add(file);\n // Only report if we've seen a substantial file\n if (hasSeenSubstantialFile) {\n sendProgress(overallProgress, file, 100, false, true);\n }\n }\n }\n }\n };\n\n const pipelineOptions: PretrainedModelOptions = {\n dtype: model.provider_config.dtype || \"q8\",\n ...(model.provider_config.use_external_data_format\n ? { useExternalDataFormat: model.provider_config.use_external_data_format }\n : {}),\n ...(model.provider_config.device ? { device: model.provider_config.device as any } : {}),\n ...options,\n progress_callback: progressCallback,\n };\n\n // Check if already aborted before starting\n if (abortSignal?.aborted) {\n throw new Error(\"Operation aborted before pipeline creation\");\n }\n\n const pipelineType = model.provider_config.pipeline;\n\n // Wrap the pipeline call with abort handling\n // Create a promise that rejects when aborted\n const abortPromise = new Promise<never>((_, reject) => {\n if (abortSignal) {\n const handleAbort = () => {\n reject(new Error(\"Pipeline download aborted\"));\n };\n\n if (abortSignal.aborted) {\n handleAbort();\n } else {\n abortSignal.addEventListener(\"abort\", handleAbort, { once: true });\n }\n }\n });\n\n // Race between pipeline creation and abort\n const { pipeline } = await loadTransformersSDK();\n const pipelinePromise = pipeline(pipelineType, model.provider_config.model_path, pipelineOptions);\n\n try {\n const result = await (abortSignal\n ? Promise.race([pipelinePromise, abortPromise])\n : pipelinePromise);\n\n // Check if aborted after pipeline creation\n if (abortSignal?.aborted) {\n throw new Error(\"Operation aborted after pipeline creation\");\n }\n\n pipelines.set(cacheKey, result);\n return result;\n } catch (error: any) {\n // If aborted, throw a clean abort error rather than internal stream errors\n if (abortSignal?.aborted) {\n throw new Error(\"Pipeline download aborted\");\n }\n // Otherwise, re-throw the original error\n throw error;\n }\n};\n\n/**\n * Core implementation for downloading and caching a Hugging Face Transformers model.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_Download: AiProviderRunFn<\n DownloadModelTaskRunInput,\n DownloadModelTaskRunOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n // Download the model by creating a pipeline\n // Use 100 as progressScaleMax since this is download-only (0-100%)\n await getPipeline(model!, onProgress, { abort_signal: signal }, 100);\n\n return {\n model: input.model!,\n };\n};\n\n/**\n * Core implementation for unloading a Hugging Face Transformers model.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_Unload: AiProviderRunFn<\n UnloadModelTaskRunInput,\n UnloadModelTaskRunOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n // Delete the pipeline from the in-memory map\n const cacheKey = getPipelineCacheKey(model!);\n if (pipelines.has(cacheKey)) {\n pipelines.delete(cacheKey);\n onProgress(50, \"Pipeline removed from memory\");\n }\n\n // Delete model cache entries\n const model_path = model!.provider_config.model_path;\n await deleteModelCache(model_path);\n onProgress(100, \"Model cache deleted\");\n\n return {\n model: input.model!,\n };\n};\n\n/**\n * Deletes all cache entries for a given model path\n * @param model_path - The model path to delete from cache\n */\nconst deleteModelCache = async (model_path: string): Promise<void> => {\n const cache = await caches.open(HTF_CACHE_NAME);\n const keys = await cache.keys();\n const prefix = `/${model_path}/`;\n\n // Collect all matching requests first\n const requestsToDelete: Request[] = [];\n for (const request of keys) {\n const url = new URL(request.url);\n if (url.pathname.startsWith(prefix)) {\n requestsToDelete.push(request);\n }\n }\n\n // Delete all matching requests\n let deletedCount = 0;\n for (const request of requestsToDelete) {\n try {\n const deleted = await cache.delete(request);\n if (deleted) {\n deletedCount++;\n } else {\n // If delete returns false, try with URL string as fallback\n const deletedByUrl = await cache.delete(request.url);\n if (deletedByUrl) {\n deletedCount++;\n }\n }\n } catch (error) {\n console.error(`Failed to delete cache entry: ${request.url}`, error);\n }\n }\n};\n\n/**\n * Core implementation for text embedding using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\n\nexport const HFT_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const generateEmbedding: FeatureExtractionPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n // Generate the embedding\n const hfVector = await generateEmbedding(input.text, {\n pooling: model?.provider_config.pooling || \"mean\",\n normalize: model?.provider_config.normalize,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const isArrayInput = Array.isArray(input.text);\n const embeddingDim = model?.provider_config.native_dimensions;\n\n // If the input is an array, the tensor will have multiple dimensions (e.g., [10, 384])\n // We need to split it into separate vectors for each input text\n if (isArrayInput && hfVector.dims.length > 1) {\n const [numTexts, vectorDim] = hfVector.dims;\n\n // Validate that the number of texts matches\n if (numTexts !== input.text.length) {\n throw new Error(\n `HuggingFace Embedding tensor batch size does not match input array length: ${numTexts} != ${input.text.length}`\n );\n }\n\n // Validate dimensions\n if (vectorDim !== embeddingDim) {\n throw new Error(\n `HuggingFace Embedding vector dimension does not match model dimensions: ${vectorDim} != ${embeddingDim}`\n );\n }\n\n // Extract each embedding vector using tensor indexing\n // hfVector[i] returns a sub-tensor for the i-th text\n const vectors: TypedArray[] = Array.from(\n { length: numTexts },\n (_, i) => (hfVector as any)[i].data as TypedArray\n );\n\n return { vector: vectors };\n }\n\n // Single text input - validate dimensions\n if (hfVector.size !== embeddingDim) {\n console.warn(\n `HuggingFace Embedding vector length does not match model dimensions v${hfVector.size} != m${embeddingDim}`,\n input,\n hfVector\n );\n throw new Error(\n `HuggingFace Embedding vector length does not match model dimensions v${hfVector.size} != m${embeddingDim}`\n );\n }\n\n return { vector: hfVector.data as TypedArray };\n};\n\nexport const HFT_TextClassification: AiProviderRunFn<\n TextClassificationTaskInput,\n TextClassificationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n if (model?.provider_config?.pipeline === \"zero-shot-classification\") {\n if (\n !input.candidateLabels ||\n !Array.isArray(input.candidateLabels) ||\n input.candidateLabels.length === 0\n ) {\n throw new Error(\"Zero-shot text classification requires candidate labels\");\n }\n\n const zeroShotClassifier: ZeroShotClassificationPipeline = await getPipeline(\n model!,\n onProgress,\n {\n abort_signal: signal,\n }\n );\n const result: any = await zeroShotClassifier(input.text, input.candidateLabels as string[], {});\n\n return {\n categories: result.labels.map((label: string, idx: number) => ({\n label,\n score: result.scores[idx],\n })),\n };\n }\n\n const TextClassification: TextClassificationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const result = await TextClassification(input.text, {\n top_k: input.maxCategories || undefined,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n if (Array.isArray(result[0])) {\n return {\n categories: result[0].map((category) => ({\n label: category.label,\n score: category.score,\n })),\n };\n }\n\n return {\n categories: (result as TextClassificationOutput).map((category) => ({\n label: category.label,\n score: category.score,\n })),\n };\n};\n\nexport const HFT_TextLanguageDetection: AiProviderRunFn<\n TextLanguageDetectionTaskInput,\n TextLanguageDetectionTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const TextClassification: TextClassificationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const result = await TextClassification(input.text, {\n top_k: input.maxLanguages || undefined,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n if (Array.isArray(result[0])) {\n return {\n languages: result[0].map((category) => ({\n language: category.label,\n score: category.score,\n })),\n };\n }\n\n return {\n languages: (result as TextClassificationOutput).map((category) => ({\n language: category.label,\n score: category.score,\n })),\n };\n};\n\nexport const HFT_TextNamedEntityRecognition: AiProviderRunFn<\n TextNamedEntityRecognitionTaskInput,\n TextNamedEntityRecognitionTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const textNamedEntityRecognition: TokenClassificationPipeline = await getPipeline(\n model!,\n onProgress,\n {\n abort_signal: signal,\n }\n );\n let results = await textNamedEntityRecognition(input.text, {\n ignore_labels: input.blockList as string[] | undefined,\n ...(signal ? { abort_signal: signal } : {}),\n });\n let entities: TokenClassificationSingle[] = [];\n if (!Array.isArray(results)) {\n entities = [results];\n } else {\n entities = results as TokenClassificationSingle[];\n }\n return {\n entities: entities.map((entity) => ({\n entity: entity.entity,\n score: entity.score,\n word: entity.word,\n })),\n };\n};\n\nexport const HFT_TextFillMask: AiProviderRunFn<\n TextFillMaskTaskInput,\n TextFillMaskTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const unmasker: FillMaskPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n let results = await unmasker(input.text);\n let predictions: FillMaskSingle[] = [];\n if (!Array.isArray(results)) {\n predictions = [results];\n } else {\n predictions = results as FillMaskSingle[];\n }\n return {\n predictions: predictions.map((prediction) => ({\n entity: prediction.token_str,\n score: prediction.score,\n sequence: prediction.sequence,\n })),\n };\n};\n\n/**\n * Core implementation for text generation using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const generateText: TextGenerationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n const streamer = createTextStreamer(generateText.tokenizer, onProgress, signal);\n\n let results = await generateText(input.prompt, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n if (!Array.isArray(results)) {\n results = [results];\n }\n let text = (results[0] as TextGenerationSingle)?.generated_text;\n\n if (Array.isArray(text)) {\n text = text[text.length - 1]?.content;\n }\n return {\n text,\n };\n};\n\n/**\n * Core implementation for text translation using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_TextTranslation: AiProviderRunFn<\n TextTranslationTaskInput,\n TextTranslationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const translate: TranslationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const streamer = createTextStreamer(translate.tokenizer, onProgress);\n\n const result = await translate(input.text, {\n src_lang: input.source_lang,\n tgt_lang: input.target_lang,\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any);\n\n const translatedText = Array.isArray(result)\n ? (result[0] as TranslationSingle)?.translation_text || \"\"\n : (result as TranslationSingle)?.translation_text || \"\";\n\n return {\n text: translatedText,\n target_lang: input.target_lang,\n };\n};\n\n/**\n * Core implementation for text rewriting using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const generateText: TextGenerationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const streamer = createTextStreamer(generateText.tokenizer, onProgress);\n\n // This lib doesn't support this kind of rewriting with a separate prompt vs text\n const promptedText = (input.prompt ? input.prompt + \"\\n\" : \"\") + input.text;\n\n let results = await generateText(promptedText, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n if (!Array.isArray(results)) {\n results = [results];\n }\n\n let text = (results[0] as TextGenerationSingle)?.generated_text;\n if (Array.isArray(text)) {\n text = text[text.length - 1]?.content;\n }\n\n if (text === promptedText) {\n throw new Error(\"Rewriter failed to generate new text\");\n }\n\n return {\n text,\n };\n};\n\n/**\n * Core implementation for text summarization using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const generateSummary: SummarizationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const streamer = createTextStreamer(generateSummary.tokenizer, onProgress);\n\n let result = await generateSummary(input.text, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any);\n\n let summaryText = \"\";\n if (Array.isArray(result)) {\n summaryText = (result[0] as SummarizationSingle)?.summary_text || \"\";\n } else {\n summaryText = (result as SummarizationSingle)?.summary_text || \"\";\n }\n\n return {\n text: summaryText,\n };\n};\n\n/**\n * Core implementation for question answering using Hugging Face Transformers.\n * This is shared between inline and worker implementations.\n */\nexport const HFT_TextQuestionAnswer: AiProviderRunFn<\n TextQuestionAnswerTaskInput,\n TextQuestionAnswerTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n // Get the question answering pipeline\n const generateAnswer: QuestionAnsweringPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const streamer = createTextStreamer(generateAnswer.tokenizer, onProgress);\n\n const result = await generateAnswer(input.question, input.context, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any);\n\n let answerText = \"\";\n if (Array.isArray(result)) {\n answerText = (result[0] as DocumentQuestionAnsweringSingle)?.answer || \"\";\n } else {\n answerText = (result as DocumentQuestionAnsweringSingle)?.answer || \"\";\n }\n\n return {\n text: answerText,\n };\n};\n\n/**\n * Core implementation for image segmentation using Hugging Face Transformers.\n */\nexport const HFT_ImageSegmentation: AiProviderRunFn<\n ImageSegmentationTaskInput,\n ImageSegmentationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const segmenter: ImageSegmentationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n const result = await segmenter(input.image as any, {\n threshold: input.threshold,\n mask_threshold: input.maskThreshold,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const masks = Array.isArray(result) ? result : [result];\n\n const processedMasks = await Promise.all(\n masks.map(async (mask) => ({\n label: mask.label || \"\",\n score: mask.score || 0,\n mask: {} as { [x: string]: unknown },\n }))\n );\n\n return {\n masks: processedMasks,\n };\n};\n\n/**\n * Core implementation for image to text using Hugging Face Transformers.\n */\nexport const HFT_ImageToText: AiProviderRunFn<\n ImageToTextTaskInput,\n ImageToTextTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const captioner: ImageToTextPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n const result: any = await captioner(input.image as string, {\n max_new_tokens: input.maxTokens,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const text = Array.isArray(result) ? result[0]?.generated_text : result?.generated_text;\n\n return {\n text: text || \"\",\n };\n};\n\n/**\n * Core implementation for background removal using Hugging Face Transformers.\n */\nexport const HFT_BackgroundRemoval: AiProviderRunFn<\n BackgroundRemovalTaskInput,\n BackgroundRemovalTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const remover: BackgroundRemovalPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n const result = await remover(input.image as string, {\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const resultImage = Array.isArray(result) ? result[0] : result;\n\n return {\n image: imageToBase64(resultImage),\n };\n};\n\n/**\n * Core implementation for image embedding using Hugging Face Transformers.\n */\nexport const HFT_ImageEmbedding: AiProviderRunFn<\n ImageEmbeddingTaskInput,\n ImageEmbeddingTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n const embedder: ImageFeatureExtractionPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n\n const result: any = await embedder(input.image as string);\n\n return {\n vector: result.data as TypedArray,\n } as ImageEmbeddingTaskOutput;\n};\n\n/**\n * Core implementation for image classification using Hugging Face Transformers.\n * Auto-selects between regular and zero-shot classification.\n */\nexport const HFT_ImageClassification: AiProviderRunFn<\n ImageClassificationTaskInput,\n ImageClassificationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n if (model?.provider_config?.pipeline === \"zero-shot-image-classification\") {\n if (!input.categories || !Array.isArray(input.categories) || input.categories.length === 0) {\n console.warn(\"Zero-shot image classification requires categories\", input);\n throw new Error(\"Zero-shot image classification requires categories\");\n }\n const zeroShotClassifier: ZeroShotImageClassificationPipeline = await getPipeline(\n model!,\n onProgress,\n {\n abort_signal: signal,\n }\n );\n const result: any = await zeroShotClassifier(\n input.image as string,\n input.categories! as string[],\n {}\n );\n\n const results = Array.isArray(result) ? result : [result];\n\n return {\n categories: results.map((r: any) => ({\n label: r.label,\n score: r.score,\n })),\n };\n }\n\n const classifier: ImageClassificationPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const result: any = await classifier(input.image as string, {\n top_k: (input as any).maxCategories,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const results = Array.isArray(result) ? result : [result];\n\n return {\n categories: results.map((r: any) => ({\n label: r.label,\n score: r.score,\n })),\n };\n};\n\n/**\n * Core implementation for object detection using Hugging Face Transformers.\n * Auto-selects between regular and zero-shot detection.\n */\nexport const HFT_ObjectDetection: AiProviderRunFn<\n ObjectDetectionTaskInput,\n ObjectDetectionTaskOutput,\n HfTransformersOnnxModelConfig\n> = async (input, model, onProgress, signal) => {\n if (model?.provider_config?.pipeline === \"zero-shot-object-detection\") {\n if (!input.labels || !Array.isArray(input.labels) || input.labels.length === 0) {\n throw new Error(\"Zero-shot object detection requires labels\");\n }\n const zeroShotDetector: ZeroShotObjectDetectionPipeline = await getPipeline(\n model!,\n onProgress,\n {\n abort_signal: signal,\n }\n );\n const result: any = await zeroShotDetector(input.image as string, Array.from(input.labels!), {\n threshold: (input as any).threshold,\n });\n\n const detections = Array.isArray(result) ? result : [result];\n\n return {\n detections: detections.map((d: any) => ({\n label: d.label,\n score: d.score,\n box: d.box,\n })),\n };\n }\n\n const detector: ObjectDetectionPipeline = await getPipeline(model!, onProgress, {\n abort_signal: signal,\n });\n const result: any = await detector(input.image as string, {\n threshold: (input as any).threshold,\n ...(signal ? { abort_signal: signal } : {}),\n });\n\n const detections = Array.isArray(result) ? result : [result];\n\n return {\n detections: detections.map((d: any) => ({\n label: d.label,\n score: d.score,\n box: d.box,\n })),\n };\n};\n/**\n * Helper function to convert RawImage to base64 PNG\n */\nfunction imageToBase64(image: RawImage): string {\n // Convert RawImage to base64 PNG\n // This is a simplified version - actual implementation would use canvas or similar\n return (image as any).toBase64?.() || \"\";\n}\n\n/**\n * Create a text streamer for a given tokenizer and update progress function\n * @param tokenizer - The tokenizer to use for the streamer\n * @param updateProgress - The function to call to update the progress\n * @param signal - The signal to use for the streamer for aborting\n * @returns The text streamer\n */\nfunction createTextStreamer(\n tokenizer: any,\n updateProgress: (progress: number, message?: string, details?: any) => void,\n signal?: AbortSignal\n) {\n const { TextStreamer } = _transformersSdk!;\n let count = 0;\n return new TextStreamer(tokenizer, {\n skip_prompt: true,\n decode_kwargs: { skip_special_tokens: true },\n callback_function: (text: string) => {\n count++;\n const result = 100 * (1 - Math.exp(-0.05 * count));\n const progress = Math.round(Math.min(result, 100));\n updateProgress(progress, \"Generating\", { text, progress });\n },\n ...(signal ? { abort_signal: signal } : {}),\n });\n}\n\n// ========================================================================\n// Streaming support: converts TextStreamer callback to AsyncIterable\n// ========================================================================\n\ntype StreamEventQueue<T> = {\n push: (event: T) => void;\n done: () => void;\n error: (err: Error) => void;\n iterable: AsyncIterable<T>;\n};\n\nfunction createStreamEventQueue<T>(): StreamEventQueue<T> {\n const buffer: T[] = [];\n let resolve: ((value: IteratorResult<T>) => void) | null = null;\n let finished = false;\n let err: Error | null = null;\n\n const push = (event: T) => {\n if (resolve) {\n const r = resolve;\n resolve = null;\n r({ value: event, done: false });\n } else {\n buffer.push(event);\n }\n };\n\n const done = () => {\n finished = true;\n if (resolve) {\n const r = resolve;\n resolve = null;\n r({ value: undefined as any, done: true });\n }\n };\n\n const error = (e: Error) => {\n err = e;\n if (resolve) {\n const r = resolve;\n resolve = null;\n r({ value: undefined as any, done: true });\n }\n };\n\n const iterable: AsyncIterable<T> = {\n [Symbol.asyncIterator]() {\n return {\n next(): Promise<IteratorResult<T>> {\n if (err) return Promise.reject(err);\n if (buffer.length > 0) {\n return Promise.resolve({ value: buffer.shift()!, done: false });\n }\n if (finished) {\n return Promise.resolve({ value: undefined as any, done: true });\n }\n return new Promise<IteratorResult<T>>((r) => {\n resolve = r;\n });\n },\n };\n },\n };\n\n return { push, done, error, iterable };\n}\n\n/**\n * Creates a TextStreamer that pushes StreamEvents into an async queue.\n * The pipeline runs to completion and updates the queue; the caller\n * consumes the queue as an AsyncIterable<StreamEvent>.\n */\nfunction createStreamingTextStreamer(\n tokenizer: any,\n queue: StreamEventQueue<StreamEvent<any>>,\n signal?: AbortSignal\n) {\n const { TextStreamer } = _transformersSdk!;\n return new TextStreamer(tokenizer, {\n skip_prompt: true,\n decode_kwargs: { skip_special_tokens: true },\n callback_function: (text: string) => {\n queue.push({ type: \"text-delta\", port: \"text\", textDelta: text });\n },\n ...(signal ? { abort_signal: signal } : {}),\n });\n}\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const HFT_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const noopProgress = () => {};\n const generateText: TextGenerationPipeline = await getPipeline(model!, noopProgress, {\n abort_signal: signal,\n });\n\n const queue = createStreamEventQueue<StreamEvent<TextGenerationTaskOutput>>();\n const streamer = createStreamingTextStreamer(generateText.tokenizer, queue, signal);\n\n const pipelinePromise = generateText(input.prompt, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n }).then(\n () => queue.done(),\n (err: Error) => queue.error(err)\n );\n\n yield* queue.iterable;\n await pipelinePromise;\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n};\n\nexport const HFT_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfTransformersOnnxModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const noopProgress = () => {};\n const generateText: TextGenerationPipeline = await getPipeline(model!, noopProgress, {\n abort_signal: signal,\n });\n\n const queue = createStreamEventQueue<StreamEvent<TextRewriterTaskOutput>>();\n const streamer = createStreamingTextStreamer(generateText.tokenizer, queue);\n\n const promptedText = (input.prompt ? input.prompt + \"\\n\" : \"\") + input.text;\n\n const pipelinePromise = generateText(promptedText, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n }).then(\n () => queue.done(),\n (err: Error) => queue.error(err)\n );\n\n yield* queue.iterable;\n await pipelinePromise;\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n};\n\nexport const HFT_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfTransformersOnnxModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const noopProgress = () => {};\n const generateSummary: SummarizationPipeline = await getPipeline(model!, noopProgress, {\n abort_signal: signal,\n });\n\n const queue = createStreamEventQueue<StreamEvent<TextSummaryTaskOutput>>();\n const streamer = createStreamingTextStreamer(generateSummary.tokenizer, queue);\n\n const pipelinePromise = generateSummary(input.text, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any).then(\n () => queue.done(),\n (err: Error) => queue.error(err)\n );\n\n yield* queue.iterable;\n await pipelinePromise;\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n};\n\nexport const HFT_TextQuestionAnswer_Stream: AiProviderStreamFn<\n TextQuestionAnswerTaskInput,\n TextQuestionAnswerTaskOutput,\n HfTransformersOnnxModelConfig\n> = async function* (\n input,\n model,\n signal\n): AsyncIterable<StreamEvent<TextQuestionAnswerTaskOutput>> {\n const noopProgress = () => {};\n const generateAnswer: QuestionAnsweringPipeline = await getPipeline(model!, noopProgress, {\n abort_signal: signal,\n });\n\n const queue = createStreamEventQueue<StreamEvent<TextQuestionAnswerTaskOutput>>();\n const streamer = createStreamingTextStreamer(generateAnswer.tokenizer, queue);\n\n let pipelineResult:\n | DocumentQuestionAnsweringSingle\n | DocumentQuestionAnsweringSingle[]\n | undefined;\n const pipelinePromise = generateAnswer(input.question, input.context, {\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any).then(\n (result) => {\n pipelineResult = result;\n queue.done();\n },\n (err: Error) => queue.error(err)\n );\n\n yield* queue.iterable;\n await pipelinePromise;\n\n let answerText = \"\";\n if (pipelineResult !== undefined) {\n if (Array.isArray(pipelineResult)) {\n answerText = (pipelineResult[0] as DocumentQuestionAnsweringSingle)?.answer ?? \"\";\n } else {\n answerText = (pipelineResult as DocumentQuestionAnsweringSingle)?.answer ?? \"\";\n }\n }\n yield { type: \"finish\", data: { text: answerText } as TextQuestionAnswerTaskOutput };\n};\n\nexport const HFT_TextTranslation_Stream: AiProviderStreamFn<\n TextTranslationTaskInput,\n TextTranslationTaskOutput,\n HfTransformersOnnxModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextTranslationTaskOutput>> {\n const noopProgress = () => {};\n const translate: TranslationPipeline = await getPipeline(model!, noopProgress, {\n abort_signal: signal,\n });\n\n const queue = createStreamEventQueue<StreamEvent<TextTranslationTaskOutput>>();\n const streamer = createStreamingTextStreamer(translate.tokenizer, queue);\n\n const pipelinePromise = translate(input.text, {\n src_lang: input.source_lang,\n tgt_lang: input.target_lang,\n streamer,\n ...(signal ? { abort_signal: signal } : {}),\n } as any).then(\n () => queue.done(),\n (err: Error) => queue.error(err)\n );\n\n yield* queue.iterable;\n await pipelinePromise;\n yield { type: \"finish\", data: { target_lang: input.target_lang } as TextTranslationTaskOutput };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\n/**\n * All HuggingFace Transformers task run functions, keyed by task type name.\n * Pass this to `new HuggingFaceTransformersProvider(HFT_TASKS)` when the\n * actual run function implementations are needed (inline mode, worker server).\n */\nexport const HFT_TASKS = {\n DownloadModelTask: HFT_Download,\n UnloadModelTask: HFT_Unload,\n TextEmbeddingTask: HFT_TextEmbedding,\n TextGenerationTask: HFT_TextGeneration,\n TextQuestionAnswerTask: HFT_TextQuestionAnswer,\n TextLanguageDetectionTask: HFT_TextLanguageDetection,\n TextClassificationTask: HFT_TextClassification,\n TextFillMaskTask: HFT_TextFillMask,\n TextNamedEntityRecognitionTask: HFT_TextNamedEntityRecognition,\n TextRewriterTask: HFT_TextRewriter,\n TextSummaryTask: HFT_TextSummary,\n TextTranslationTask: HFT_TextTranslation,\n ImageSegmentationTask: HFT_ImageSegmentation,\n ImageToTextTask: HFT_ImageToText,\n BackgroundRemovalTask: HFT_BackgroundRemoval,\n ImageEmbeddingTask: HFT_ImageEmbedding,\n ImageClassificationTask: HFT_ImageClassification,\n ObjectDetectionTask: HFT_ObjectDetection,\n} as const;\n\n/**\n * Streaming variants of HuggingFace Transformers task run functions.\n * Pass this as the second argument to `new HuggingFaceTransformersProvider(HFT_TASKS, HFT_STREAM_TASKS)`.\n */\nexport const HFT_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, HfTransformersOnnxModelConfig>\n> = {\n TextGenerationTask: HFT_TextGeneration_Stream,\n TextRewriterTask: HFT_TextRewriter_Stream,\n TextSummaryTask: HFT_TextSummary_Stream,\n TextQuestionAnswerTask: HFT_TextQuestionAnswer_Stream,\n TextTranslationTask: HFT_TextTranslation_Stream,\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;AA6EA,IAAI;AACJ,eAAe,mBAAmB,GAAG;AAAA,EACnC,IAAI,CAAC,kBAAkB;AAAA,IACrB,IAAI;AAAA,MACF,mBAAmB,MAAa;AAAA,MAChC,MAAM;AAAA,MACN,MAAM,IAAI,MACR,wHACF;AAAA;AAAA,EAEJ;A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,EAAE,MAAM,UAAU,MAAM,EAAE,aAAa,MAAM,YAAY,EAA+B;AAAA;AAYzF,IAAM,YAAY;AAAA,EACvB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,gCAAgC;AAAA,EAChC,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,EACzB,qBAAqB;AACvB;AAMO,IAAM,mBAGT;AAAA,EACF,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,qBAAqB;AACvB;",
|
|
8
|
+
"debugId": "4AF2ECA21E0D4F3464756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/provider-openai/common/OpenAI_Constants.ts
|
|
2
|
+
var OPENAI = "OPENAI";
|
|
3
|
+
|
|
4
|
+
// src/provider-openai/common/OpenAI_ModelSchema.ts
|
|
5
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
6
|
+
var OpenAiModelSchema = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
provider: {
|
|
10
|
+
const: OPENAI,
|
|
11
|
+
description: "Discriminator: OpenAI cloud provider."
|
|
12
|
+
},
|
|
13
|
+
provider_config: {
|
|
14
|
+
type: "object",
|
|
15
|
+
description: "OpenAI-specific configuration.",
|
|
16
|
+
properties: {
|
|
17
|
+
model_name: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The OpenAI model identifier (e.g., 'gpt-4o', 'text-embedding-3-small')."
|
|
20
|
+
},
|
|
21
|
+
api_key: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "OpenAI API key. Falls back to default API key if not set."
|
|
24
|
+
},
|
|
25
|
+
base_url: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Base URL for the OpenAI API. Useful for Azure OpenAI or proxy servers.",
|
|
28
|
+
default: "https://api.openai.com/v1"
|
|
29
|
+
},
|
|
30
|
+
organization: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "OpenAI organization ID (optional)."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ["model_name"],
|
|
36
|
+
additionalProperties: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
required: ["provider", "provider_config"],
|
|
40
|
+
additionalProperties: true
|
|
41
|
+
};
|
|
42
|
+
var OpenAiModelRecordSchema = {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
...ModelRecordSchema.properties,
|
|
46
|
+
...OpenAiModelSchema.properties
|
|
47
|
+
},
|
|
48
|
+
required: [...ModelRecordSchema.required, ...OpenAiModelSchema.required],
|
|
49
|
+
additionalProperties: false
|
|
50
|
+
};
|
|
51
|
+
var OpenAiModelConfigSchema = {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: {
|
|
54
|
+
...ModelConfigSchema.properties,
|
|
55
|
+
...OpenAiModelSchema.properties
|
|
56
|
+
},
|
|
57
|
+
required: [...ModelConfigSchema.required, ...OpenAiModelSchema.required],
|
|
58
|
+
additionalProperties: false
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/provider-openai/OpenAiProvider.ts
|
|
62
|
+
import { AiProvider } from "@workglow/ai";
|
|
63
|
+
class OpenAiProvider extends AiProvider {
|
|
64
|
+
name = OPENAI;
|
|
65
|
+
taskTypes = [
|
|
66
|
+
"TextGenerationTask",
|
|
67
|
+
"TextEmbeddingTask",
|
|
68
|
+
"TextRewriterTask",
|
|
69
|
+
"TextSummaryTask"
|
|
70
|
+
];
|
|
71
|
+
constructor(tasks, streamTasks) {
|
|
72
|
+
super(tasks, streamTasks);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { OPENAI, OpenAiModelSchema, OpenAiModelRecordSchema, OpenAiModelConfigSchema, OpenAiProvider };
|
|
77
|
+
|
|
78
|
+
//# debugId=024D8CD4A709515064756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/provider-openai/common/OpenAI_Constants.ts", "../src/provider-openai/common/OpenAI_ModelSchema.ts", "../src/provider-openai/OpenAiProvider.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const OPENAI = \"OPENAI\";\n",
|
|
6
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { OPENAI } from \"./OpenAI_Constants\";\n\nexport const OpenAiModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: OPENAI,\n description: \"Discriminator: OpenAI cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"OpenAI-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description: \"The OpenAI model identifier (e.g., 'gpt-4o', 'text-embedding-3-small').\",\n },\n api_key: {\n type: \"string\",\n description: \"OpenAI API key. Falls back to default API key if not set.\",\n },\n base_url: {\n type: \"string\",\n description: \"Base URL for the OpenAI API. Useful for Azure OpenAI or proxy servers.\",\n default: \"https://api.openai.com/v1\",\n },\n organization: {\n type: \"string\",\n description: \"OpenAI organization ID (optional).\",\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const OpenAiModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...OpenAiModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...OpenAiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type OpenAiModelRecord = FromSchema<typeof OpenAiModelRecordSchema>;\n\nexport const OpenAiModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...OpenAiModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...OpenAiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type OpenAiModelConfig = FromSchema<typeof OpenAiModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { OPENAI } from \"./common/OpenAI_Constants\";\nimport type { OpenAiModelConfig } from \"./common/OpenAI_ModelSchema\";\n\n/**\n * AI provider for OpenAI cloud models.\n *\n * Supports text generation, text embedding, text rewriting, and text summarization\n * via the OpenAI API using the `openai` SDK.\n *\n * Task run functions are injected via the constructor so that the `openai` SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new OpenAiProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_openai.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { OPENAI_TASKS } from \"@workglow/ai-provider/openai\";\n * await new OpenAiProvider(OPENAI_TASKS).register({ mode: \"inline\" });\n *\n * // Worker side -- caller provides the tasks:\n * import { OPENAI_TASKS } from \"@workglow/ai-provider/openai\";\n * new OpenAiProvider(OPENAI_TASKS).registerOnWorkerServer(workerServer);\n * ```\n */\nexport class OpenAiProvider extends AiProvider<OpenAiModelConfig> {\n readonly name = OPENAI;\n\n readonly taskTypes = [\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, OpenAiModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, OpenAiModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAMO,IAAM,SAAS;;;ACAtB;AAIO,IAAM,oBAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,cAAc;AAAA,UACZ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,MACvB,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;AAIO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;;;AC7DA;AA+BO,MAAM,uBAAuB,WAA8B;AAAA,EACvD,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA;AAAA,IACA,MAAM,OAAO,WAAW;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "024D8CD4A709515064756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/provider-hf-inference/common/HFI_Constants.ts
|
|
2
|
+
var HF_INFERENCE = "HF_INFERENCE";
|
|
3
|
+
|
|
4
|
+
// src/provider-hf-inference/common/HFI_ModelSchema.ts
|
|
5
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
6
|
+
var HfInferenceModelSchema = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
provider: {
|
|
10
|
+
const: HF_INFERENCE,
|
|
11
|
+
description: "Discriminator: Hugging Face Inference API provider."
|
|
12
|
+
},
|
|
13
|
+
provider_config: {
|
|
14
|
+
type: "object",
|
|
15
|
+
description: "Hugging Face Inference-specific configuration.",
|
|
16
|
+
properties: {
|
|
17
|
+
model_name: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct')."
|
|
20
|
+
},
|
|
21
|
+
api_key: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Hugging Face API key. Falls back to HF_TOKEN environment variable if not set."
|
|
24
|
+
},
|
|
25
|
+
provider: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Optional provider to route to specific HF inference providers (e.g., 'fal-ai', 'fireworks-ai')."
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: ["model_name"],
|
|
31
|
+
additionalProperties: false
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
required: ["provider", "provider_config"],
|
|
35
|
+
additionalProperties: true
|
|
36
|
+
};
|
|
37
|
+
var HfInferenceModelRecordSchema = {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
...ModelRecordSchema.properties,
|
|
41
|
+
...HfInferenceModelSchema.properties
|
|
42
|
+
},
|
|
43
|
+
required: [...ModelRecordSchema.required, ...HfInferenceModelSchema.required],
|
|
44
|
+
additionalProperties: false
|
|
45
|
+
};
|
|
46
|
+
var HfInferenceModelConfigSchema = {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
...ModelConfigSchema.properties,
|
|
50
|
+
...HfInferenceModelSchema.properties
|
|
51
|
+
},
|
|
52
|
+
required: [...ModelConfigSchema.required, ...HfInferenceModelSchema.required],
|
|
53
|
+
additionalProperties: false
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/provider-hf-inference/HfInferenceProvider.ts
|
|
57
|
+
import { AiProvider } from "@workglow/ai";
|
|
58
|
+
class HfInferenceProvider extends AiProvider {
|
|
59
|
+
name = HF_INFERENCE;
|
|
60
|
+
taskTypes = [
|
|
61
|
+
"TextGenerationTask",
|
|
62
|
+
"TextEmbeddingTask",
|
|
63
|
+
"TextRewriterTask",
|
|
64
|
+
"TextSummaryTask"
|
|
65
|
+
];
|
|
66
|
+
constructor(tasks, streamTasks) {
|
|
67
|
+
super(tasks, streamTasks);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { HF_INFERENCE, HfInferenceModelSchema, HfInferenceModelRecordSchema, HfInferenceModelConfigSchema, HfInferenceProvider };
|
|
72
|
+
|
|
73
|
+
//# debugId=CE9336C8A59B293064756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/provider-hf-inference/common/HFI_Constants.ts", "../src/provider-hf-inference/common/HFI_ModelSchema.ts", "../src/provider-hf-inference/HfInferenceProvider.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const HF_INFERENCE = \"HF_INFERENCE\";\n",
|
|
6
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { HF_INFERENCE } from \"./HFI_Constants\";\n\nexport const HfInferenceModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: HF_INFERENCE,\n description: \"Discriminator: Hugging Face Inference API provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Hugging Face Inference-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description: \"The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').\",\n },\n api_key: {\n type: \"string\",\n description: \"Hugging Face API key. Falls back to HF_TOKEN environment variable if not set.\",\n },\n provider: {\n type: \"string\",\n description: \"Optional provider to route to specific HF inference providers (e.g., 'fal-ai', 'fireworks-ai').\",\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const HfInferenceModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...HfInferenceModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...HfInferenceModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfInferenceModelRecord = FromSchema<typeof HfInferenceModelRecordSchema>;\n\nexport const HfInferenceModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...HfInferenceModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...HfInferenceModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfInferenceModelConfig = FromSchema<typeof HfInferenceModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { HF_INFERENCE } from \"./common/HFI_Constants\";\nimport type { HfInferenceModelConfig } from \"./common/HFI_ModelSchema\";\n\n/**\n * AI provider for Hugging Face Inference API.\n *\n * Supports text generation, text embedding, text rewriting, and text summarization\n * via the Hugging Face Inference API using the `@huggingface/inference` SDK.\n *\n * Task run functions are injected via the constructor so that the `@huggingface/inference` SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new HfInferenceProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_hfi.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { HFI_TASKS } from \"@workglow/ai-provider/hf-inference\";\n * await new HfInferenceProvider(HFI_TASKS).register({ mode: \"inline\" });\n *\n * // Worker side -- caller provides the tasks:\n * import { HFI_TASKS } from \"@workglow/ai-provider/hf-inference\";\n * new HfInferenceProvider(HFI_TASKS).registerOnWorkerServer(workerServer);\n * ```\n */\nexport class HfInferenceProvider extends AiProvider<HfInferenceModelConfig> {\n readonly name = HF_INFERENCE;\n\n readonly taskTypes = [\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, HfInferenceModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamF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;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "CE9336C8A59B293064756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { __require };
|
|
10
|
+
|
|
11
|
+
//# debugId=4DD4036FF577483964756E2164756E21
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/anthropic/common/Anthropic_Constants.ts
|
|
2
|
+
var ANTHROPIC = "ANTHROPIC";
|
|
3
|
+
|
|
4
|
+
// src/anthropic/common/Anthropic_ModelSchema.ts
|
|
5
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
6
|
+
var AnthropicModelSchema = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
provider: {
|
|
10
|
+
const: ANTHROPIC,
|
|
11
|
+
description: "Discriminator: Anthropic cloud provider."
|
|
12
|
+
},
|
|
13
|
+
provider_config: {
|
|
14
|
+
type: "object",
|
|
15
|
+
description: "Anthropic-specific configuration.",
|
|
16
|
+
properties: {
|
|
17
|
+
model_name: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The Anthropic model identifier (e.g., 'claude-sonnet-4-20250514', 'claude-3-5-haiku-20241022')."
|
|
20
|
+
},
|
|
21
|
+
api_key: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Anthropic API key. Falls back to ANTHROPIC_API_KEY environment variable if not set.",
|
|
24
|
+
"x-ui-hidden": true
|
|
25
|
+
},
|
|
26
|
+
base_url: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Base URL for the Anthropic API (optional)."
|
|
29
|
+
},
|
|
30
|
+
max_tokens: {
|
|
31
|
+
type: "integer",
|
|
32
|
+
description: "Default max tokens for responses. Anthropic requires this parameter.",
|
|
33
|
+
default: 1024,
|
|
34
|
+
minimum: 1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
required: ["model_name"],
|
|
38
|
+
additionalProperties: false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: ["provider", "provider_config"],
|
|
42
|
+
additionalProperties: true
|
|
43
|
+
};
|
|
44
|
+
var AnthropicModelRecordSchema = {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
...ModelRecordSchema.properties,
|
|
48
|
+
...AnthropicModelSchema.properties
|
|
49
|
+
},
|
|
50
|
+
required: [...ModelRecordSchema.required, ...AnthropicModelSchema.required],
|
|
51
|
+
additionalProperties: false
|
|
52
|
+
};
|
|
53
|
+
var AnthropicModelConfigSchema = {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
...ModelConfigSchema.properties,
|
|
57
|
+
...AnthropicModelSchema.properties
|
|
58
|
+
},
|
|
59
|
+
required: [...ModelConfigSchema.required, ...AnthropicModelSchema.required],
|
|
60
|
+
additionalProperties: false
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/anthropic/AnthropicProvider.ts
|
|
64
|
+
import { AiProvider } from "@workglow/ai";
|
|
65
|
+
class AnthropicProvider extends AiProvider {
|
|
66
|
+
name = ANTHROPIC;
|
|
67
|
+
taskTypes = ["TextGenerationTask", "TextRewriterTask", "TextSummaryTask"];
|
|
68
|
+
constructor(tasks, streamTasks) {
|
|
69
|
+
super(tasks, streamTasks);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { ANTHROPIC, AnthropicModelSchema, AnthropicModelRecordSchema, AnthropicModelConfigSchema, AnthropicProvider };
|
|
74
|
+
|
|
75
|
+
//# debugId=75A83D6346B7767164756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/anthropic/common/Anthropic_Constants.ts", "../src/anthropic/common/Anthropic_ModelSchema.ts", "../src/anthropic/AnthropicProvider.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const ANTHROPIC = \"ANTHROPIC\";\n",
|
|
6
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { ANTHROPIC } from \"./Anthropic_Constants\";\n\nexport const AnthropicModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: ANTHROPIC,\n description: \"Discriminator: Anthropic cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Anthropic-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description:\n \"The Anthropic model identifier (e.g., 'claude-sonnet-4-20250514', 'claude-3-5-haiku-20241022').\",\n },\n api_key: {\n type: \"string\",\n description:\n \"Anthropic API key. Falls back to ANTHROPIC_API_KEY environment variable if not set.\",\n \"x-ui-hidden\": true,\n },\n base_url: {\n type: \"string\",\n description: \"Base URL for the Anthropic API (optional).\",\n },\n max_tokens: {\n type: \"integer\",\n description: \"Default max tokens for responses. Anthropic requires this parameter.\",\n default: 1024,\n minimum: 1,\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const AnthropicModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...AnthropicModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...AnthropicModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type AnthropicModelRecord = FromSchema<typeof AnthropicModelRecordSchema>;\n\nexport const AnthropicModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...AnthropicModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...AnthropicModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type AnthropicModelConfig = FromSchema<typeof AnthropicModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { ANTHROPIC } from \"./common/Anthropic_Constants\";\nimport type { AnthropicModelConfig } from \"./common/Anthropic_ModelSchema\";\n\n/**\n * AI provider for Anthropic cloud models.\n *\n * Supports text generation, text rewriting, and text summarization via the\n * Anthropic Messages API using the `@anthropic-ai/sdk` SDK.\n *\n * Note: Anthropic does not offer an embeddings API, so TextEmbeddingTask\n * is not supported by this provider.\n *\n * Task run functions are injected via the constructor so that the SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new AnthropicProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_anthropic.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { ANTHROPIC_TASKS } from \"@workglow/ai-provider/anthropic\";\n * await new AnthropicProvider(ANTHROPIC_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class AnthropicProvider extends AiProvider<AnthropicModelConfig> {\n readonly name = ANTHROPIC;\n\n readonly taskTypes = [\"TextGenerationTask\", \"TextRewriterTask\", \"TextSummaryTask\"] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, AnthropicModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, AnthropicModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAMO,IAAM,YAAY;;;ACAzB;AAIO,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aACE;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,aACE;AAAA,UACF,eAAe;AAAA,QACjB;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,UACT,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,MACvB,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,6BAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,qBAAqB;AAAA,EAC1B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,qBAAqB,QAAQ;AAAA,EAC1E,sBAAsB;AACxB;AAIO,IAAM,6BAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,qBAAqB;AAAA,EAC1B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,qBAAqB,QAAQ;AAAA,EAC1E,sBAAsB;AACxB;;;ACjEA;AA8BO,MAAM,0BAA0B,WAAiC;AAAA,EAC7D,OAAO;AAAA,EAEP,YAAY,CAAC,sBAAsB,oBAAoB,iBAAiB;AAAA,EAEjF,WAAW,CACT,OACA,aACA;AAAA,IACA,MAAM,OAAO,WAAW;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "75A83D6346B7767164756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/hf-transformers/common/HFT_Constants.ts
|
|
2
|
+
var HF_TRANSFORMERS_ONNX = "HF_TRANSFORMERS_ONNX";
|
|
3
|
+
var HTF_CACHE_NAME = "transformers-cache";
|
|
4
|
+
var QuantizationDataType = {
|
|
5
|
+
auto: "auto",
|
|
6
|
+
fp32: "fp32",
|
|
7
|
+
fp16: "fp16",
|
|
8
|
+
q8: "q8",
|
|
9
|
+
int8: "int8",
|
|
10
|
+
uint8: "uint8",
|
|
11
|
+
q4: "q4",
|
|
12
|
+
bnb4: "bnb4",
|
|
13
|
+
q4f16: "q4f16"
|
|
14
|
+
};
|
|
15
|
+
var TextPipelineUseCase = {
|
|
16
|
+
"fill-mask": "fill-mask",
|
|
17
|
+
"token-classification": "token-classification",
|
|
18
|
+
"text-generation": "text-generation",
|
|
19
|
+
"text2text-generation": "text2text-generation",
|
|
20
|
+
"text-classification": "text-classification",
|
|
21
|
+
summarization: "summarization",
|
|
22
|
+
translation: "translation",
|
|
23
|
+
"feature-extraction": "feature-extraction",
|
|
24
|
+
"zero-shot-classification": "zero-shot-classification",
|
|
25
|
+
"question-answering": "question-answering"
|
|
26
|
+
};
|
|
27
|
+
var VisionPipelineUseCase = {
|
|
28
|
+
"background-removal": "background-removal",
|
|
29
|
+
"image-segmentation": "image-segmentation",
|
|
30
|
+
"depth-estimation": "depth-estimation",
|
|
31
|
+
"image-classification": "image-classification",
|
|
32
|
+
"image-to-image": "image-to-image",
|
|
33
|
+
"object-detection": "object-detection",
|
|
34
|
+
"image-feature-extraction": "image-feature-extraction"
|
|
35
|
+
};
|
|
36
|
+
var AudioPipelineUseCase = {
|
|
37
|
+
"audio-classification": "audio-classification",
|
|
38
|
+
"automatic-speech-recognition": "automatic-speech-recognition",
|
|
39
|
+
"text-to-speech": "text-to-speech"
|
|
40
|
+
};
|
|
41
|
+
var MultimodalPipelineUseCase = {
|
|
42
|
+
"document-question-answering": "document-question-answering",
|
|
43
|
+
"image-to-text": "image-to-text",
|
|
44
|
+
"zero-shot-audio-classification": "zero-shot-audio-classification",
|
|
45
|
+
"zero-shot-image-classification": "zero-shot-image-classification",
|
|
46
|
+
"zero-shot-object-detection": "zero-shot-object-detection"
|
|
47
|
+
};
|
|
48
|
+
var PipelineUseCase = {
|
|
49
|
+
...TextPipelineUseCase,
|
|
50
|
+
...VisionPipelineUseCase,
|
|
51
|
+
...AudioPipelineUseCase,
|
|
52
|
+
...MultimodalPipelineUseCase
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { HF_TRANSFORMERS_ONNX, HTF_CACHE_NAME, QuantizationDataType, TextPipelineUseCase, VisionPipelineUseCase, AudioPipelineUseCase, MultimodalPipelineUseCase, PipelineUseCase };
|
|
56
|
+
|
|
57
|
+
//# debugId=297B2C0A21F958E264756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/hf-transformers/common/HFT_Constants.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const HF_TRANSFORMERS_ONNX = \"HF_TRANSFORMERS_ONNX\";\nexport const HTF_CACHE_NAME = \"transformers-cache\";\n\nexport type QuantizationDataType =\n | \"auto\" // Auto-detect based on environment\n | \"fp32\"\n | \"fp16\"\n | \"q8\"\n | \"int8\"\n | \"uint8\"\n | \"q4\"\n | \"bnb4\"\n | \"q4f16\"; // fp16 model with int4 block weight quantization\n\nexport const QuantizationDataType = {\n auto: \"auto\",\n fp32: \"fp32\",\n fp16: \"fp16\",\n q8: \"q8\",\n int8: \"int8\",\n uint8: \"uint8\",\n q4: \"q4\",\n bnb4: \"bnb4\",\n q4f16: \"q4f16\",\n} as const satisfies Record<QuantizationDataType, QuantizationDataType>;\n\nexport type TextPipelineUseCase =\n | \"fill-mask\" // https://huggingface.co/tasks/fill-mask\n | \"token-classification\" // https://huggingface.co/tasks/token-classification\n | \"text-generation\" // https://huggingface.co/tasks/text-generation#completion-generation-models\n | \"text2text-generation\" // https://huggingface.co/tasks/text-generation#text-to-text-generation-models\n | \"text-classification\" // https://huggingface.co/tasks/text-classification\n | \"summarization\" // https://huggingface.co/tasks/sentence-similarity\n | \"translation\" // https://huggingface.co/tasks/translation\n | \"feature-extraction\" // https://huggingface.co/tasks/feature-extraction\n | \"zero-shot-classification\" // https://huggingface.co/tasks/zero-shot-classification\n | \"question-answering\"; // https://huggingface.co/tasks/question-answering\n\nexport const TextPipelineUseCase = {\n \"fill-mask\": \"fill-mask\",\n \"token-classification\": \"token-classification\",\n \"text-generation\": \"text-generation\",\n \"text2text-generation\": \"text2text-generation\",\n \"text-classification\": \"text-classification\",\n summarization: \"summarization\",\n translation: \"translation\",\n \"feature-extraction\": \"feature-extraction\",\n \"zero-shot-classification\": \"zero-shot-classification\",\n \"question-answering\": \"question-answering\",\n} as const satisfies Record<TextPipelineUseCase, TextPipelineUseCase>;\n\nexport type VisionPipelineUseCase =\n | \"background-removal\" // https://huggingface.co/tasks/image-segmentation#background-removal\n | \"image-segmentation\" // https://huggingface.co/tasks/image-segmentation\n | \"depth-estimation\" // https://huggingface.co/tasks/depth-estimation\n | \"image-classification\" // https://huggingface.co/tasks/image-classification\n | \"image-to-image\" // https://huggingface.co/tasks/image-to-image\n | \"object-detection\" // https://huggingface.co/tasks/object-detection\n | \"image-feature-extraction\"; // https://huggingface.co/tasks/image-feature-extraction\n\nexport const VisionPipelineUseCase = {\n \"background-removal\": \"background-removal\",\n \"image-segmentation\": \"image-segmentation\",\n \"depth-estimation\": \"depth-estimation\",\n \"image-classification\": \"image-classification\",\n \"image-to-image\": \"image-to-image\",\n \"object-detection\": \"object-detection\",\n \"image-feature-extraction\": \"image-feature-extraction\",\n} as const satisfies Record<VisionPipelineUseCase, VisionPipelineUseCase>;\n\nexport type AudioPipelineUseCase =\n | \"audio-classification\" // https://huggingface.co/tasks/audio-classification\n | \"automatic-speech-recognition\" // https://huggingface.co/tasks/automatic-speech-recognition\n | \"text-to-speech\"; // https://huggingface.co/tasks/text-to-speech\n\nexport const AudioPipelineUseCase = {\n \"audio-classification\": \"audio-classification\",\n \"automatic-speech-recognition\": \"automatic-speech-recognition\",\n \"text-to-speech\": \"text-to-speech\",\n} as const satisfies Record<AudioPipelineUseCase, AudioPipelineUseCase>;\n\nexport type MultimodalPipelineUseCase =\n | \"document-question-answering\" // https://huggingface.co/tasks/document-question-answering\n | \"image-to-text\" // https://huggingface.co/tasks/image-to-text\n | \"zero-shot-audio-classification\" // https://huggingface.co/tasks/zero-shot-audio-classification\n | \"zero-shot-image-classification\" // https://huggingface.co/tasks/zero-shot-image-classification\n | \"zero-shot-object-detection\"; // https://huggingface.co/tasks/zero-shot-object-detection\n\nexport const MultimodalPipelineUseCase = {\n \"document-question-answering\": \"document-question-answering\",\n \"image-to-text\": \"image-to-text\",\n \"zero-shot-audio-classification\": \"zero-shot-audio-classification\",\n \"zero-shot-image-classification\": \"zero-shot-image-classification\",\n \"zero-shot-object-detection\": \"zero-shot-object-detection\",\n} as const satisfies Record<MultimodalPipelineUseCase, MultimodalPipelineUseCase>;\n\nexport type PipelineUseCase =\n | TextPipelineUseCase\n | VisionPipelineUseCase\n | AudioPipelineUseCase\n | MultimodalPipelineUseCase;\n\nexport const PipelineUseCase = {\n ...TextPipelineUseCase,\n ...VisionPipelineUseCase,\n ...AudioPipelineUseCase,\n ...MultimodalPipelineUseCase,\n} as const satisfies Record<PipelineUseCase, PipelineUseCase>;\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAMO,IAAM,uBAAuB;AAC7B,IAAM,iBAAiB;AAavB,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AACT;AAcO,IAAM,sBAAsB;AAAA,EACjC,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,4BAA4B;AAAA,EAC5B,sBAAsB;AACxB;AAWO,IAAM,wBAAwB;AAAA,EACnC,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,4BAA4B;AAC9B;AAOO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB;AAAA,EACxB,gCAAgC;AAAA,EAChC,kBAAkB;AACpB;AASO,IAAM,4BAA4B;AAAA,EACvC,+BAA+B;AAAA,EAC/B,iBAAiB;AAAA,EACjB,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAChC;AAQO,IAAM,kBAAkB;AAAA,KAC1B;AAAA,KACA;AAAA,KACA;AAAA,KACA;AACL;",
|
|
8
|
+
"debugId": "297B2C0A21F958E264756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|