@workglow/ai-provider 0.0.103 → 0.0.104
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/anthropic/common/Anthropic_JobRunFns.d.ts.map +1 -1
- package/dist/anthropic/common/Anthropic_ModelSchema.d.ts +9 -6
- package/dist/anthropic/common/Anthropic_ModelSchema.d.ts.map +1 -1
- package/dist/anthropic/index.js +6 -5
- package/dist/anthropic/index.js.map +3 -3
- package/dist/google-gemini/common/Gemini_JobRunFns.d.ts.map +1 -1
- package/dist/google-gemini/common/Gemini_ModelSchema.d.ts +12 -6
- package/dist/google-gemini/common/Gemini_ModelSchema.d.ts.map +1 -1
- package/dist/google-gemini/index.js +5 -4
- package/dist/google-gemini/index.js.map +3 -3
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts +21 -0
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/{index-p88ezt14.js → index-79rqre58.js} +5 -3
- package/dist/{index-p88ezt14.js.map → index-79rqre58.js.map} +3 -3
- package/dist/{index-edjqamf9.js → index-c5z3v9gn.js} +4 -3
- package/dist/{index-edjqamf9.js.map → index-c5z3v9gn.js.map} +3 -3
- package/dist/{index-qy5ksm4w.js → index-gjc388y4.js} +5 -3
- package/dist/{index-qy5ksm4w.js.map → index-gjc388y4.js.map} +3 -3
- package/dist/{index-3tvpdt0s.js → index-t54dgrfj.js} +5 -3
- package/dist/{index-3tvpdt0s.js.map → index-t54dgrfj.js.map} +3 -3
- package/dist/index.js +4 -4
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts.map +1 -1
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts +12 -6
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts.map +1 -1
- package/dist/provider-hf-inference/index.js +5 -4
- package/dist/provider-hf-inference/index.js.map +3 -3
- package/dist/provider-openai/common/OpenAI_JobRunFns.d.ts.map +1 -1
- package/dist/provider-openai/common/OpenAI_ModelSchema.d.ts +12 -6
- package/dist/provider-openai/common/OpenAI_ModelSchema.d.ts.map +1 -1
- package/dist/provider-openai/index.js +7 -6
- package/dist/provider-openai/index.js.map +3 -3
- package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts +16 -0
- package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"sources": ["../src/provider-openai/common/OpenAI_Constants.ts", "../src/provider-openai/common/OpenAI_ModelSchema.ts", "../src/provider-openai/OpenAiProvider.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
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
|
|
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 credential_key: {\n type: \"string\",\n format: \"credential\",\n description:\n \"Key to look up in the credential store for the API key.\",\n \"x-ui-hidden\": true,\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
7
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} 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 \"CountTokensTask\",\n \"StructuredGenerationTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, OpenAiModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, OpenAiModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, OpenAiModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n}\n"
|
|
8
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,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"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AA,EAEA,WAAW,CACT,OACA,aACA,eACA;AAAA,IACA,MAAM,OAAO,aAAa,aAAa;AAAA;AAE3C;",
|
|
10
|
+
"debugId": "34B030CB7BA9410C64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -18,9 +18,10 @@ var AnthropicModelSchema = {
|
|
|
18
18
|
type: "string",
|
|
19
19
|
description: "The Anthropic model identifier (e.g., 'claude-sonnet-4-20250514', 'claude-3-5-haiku-20241022')."
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
credential_key: {
|
|
22
22
|
type: "string",
|
|
23
|
-
|
|
23
|
+
format: "credential",
|
|
24
|
+
description: "Key to look up in the credential store for the API key.",
|
|
24
25
|
"x-ui-hidden": true
|
|
25
26
|
},
|
|
26
27
|
base_url: {
|
|
@@ -80,4 +81,4 @@ class AnthropicProvider extends AiProvider {
|
|
|
80
81
|
|
|
81
82
|
export { ANTHROPIC, AnthropicModelSchema, AnthropicModelRecordSchema, AnthropicModelConfigSchema, AnthropicProvider };
|
|
82
83
|
|
|
83
|
-
//# debugId=
|
|
84
|
+
//# debugId=11334428D1B4D66F64756E2164756E21
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"sources": ["../src/anthropic/common/Anthropic_Constants.ts", "../src/anthropic/common/Anthropic_ModelSchema.ts", "../src/anthropic/AnthropicProvider.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
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
|
|
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 credential_key: {\n type: \"string\",\n format: \"credential\",\n description:\n \"Key to look up in the credential store for the API key.\",\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
7
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} 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, ANTHROPIC_STREAM_TASKS, ANTHROPIC_REACTIVE_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class AnthropicProvider extends AiProvider<AnthropicModelConfig> {\n readonly name = ANTHROPIC;\n\n readonly taskTypes = [\n \"CountTokensTask\",\n \"TextGenerationTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n \"StructuredGenerationTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, AnthropicModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, AnthropicModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, AnthropicModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n}\n"
|
|
8
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,
|
|
10
|
-
"debugId": "
|
|
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,gBAAgB;AAAA,UACd,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,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;;;AClEA;AAAA;AAAA;AAmCO,MAAM,0BAA0B,WAAiC;AAAA,EAC7D,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA,eACA;AAAA,IACA,MAAM,OAAO,aAAa,aAAa;AAAA;AAE3C;",
|
|
10
|
+
"debugId": "11334428D1B4D66F64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -18,9 +18,11 @@ var GeminiModelSchema = {
|
|
|
18
18
|
type: "string",
|
|
19
19
|
description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004')."
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
credential_key: {
|
|
22
22
|
type: "string",
|
|
23
|
-
|
|
23
|
+
format: "credential",
|
|
24
|
+
description: "Key to look up in the credential store for the API key.",
|
|
25
|
+
"x-ui-hidden": true
|
|
24
26
|
},
|
|
25
27
|
embedding_task_type: {
|
|
26
28
|
oneOf: [
|
|
@@ -87,4 +89,4 @@ class GoogleGeminiProvider extends AiProvider {
|
|
|
87
89
|
|
|
88
90
|
export { GOOGLE_GEMINI, GeminiModelSchema, GeminiModelRecordSchema, GeminiModelConfigSchema, GoogleGeminiProvider };
|
|
89
91
|
|
|
90
|
-
//# debugId=
|
|
92
|
+
//# debugId=1DD20092AEAA8D5F64756E2164756E21
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"sources": ["../src/google-gemini/common/Gemini_Constants.ts", "../src/google-gemini/common/Gemini_ModelSchema.ts", "../src/google-gemini/GoogleGeminiProvider.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const GOOGLE_GEMINI = \"GOOGLE_GEMINI\";\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 { GOOGLE_GEMINI } from \"./Gemini_Constants\";\n\nexport const GeminiModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: GOOGLE_GEMINI,\n description: \"Discriminator: Google Gemini cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Google Gemini-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description:\n \"The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').\",\n },\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 { GOOGLE_GEMINI } from \"./Gemini_Constants\";\n\nexport const GeminiModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: GOOGLE_GEMINI,\n description: \"Discriminator: Google Gemini cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Google Gemini-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description:\n \"The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').\",\n },\n credential_key: {\n type: \"string\",\n format: \"credential\",\n description:\n \"Key to look up in the credential store for the API key.\",\n \"x-ui-hidden\": true,\n },\n embedding_task_type: {\n oneOf: [\n { type: \"null\" },\n {\n type: \"string\",\n enum: [\n \"RETRIEVAL_QUERY\",\n \"RETRIEVAL_DOCUMENT\",\n \"SEMANTIC_SIMILARITY\",\n \"CLASSIFICATION\",\n \"CLUSTERING\",\n ],\n },\n ],\n description: \"Task type hint for embedding models.\",\n default: null,\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 GeminiModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...GeminiModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...GeminiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type GeminiModelRecord = FromSchema<typeof GeminiModelRecordSchema>;\n\nexport const GeminiModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...GeminiModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...GeminiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type GeminiModelConfig = FromSchema<typeof GeminiModelConfigSchema>;\n",
|
|
7
7
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} from \"@workglow/ai\";\nimport { GOOGLE_GEMINI } from \"./common/Gemini_Constants\";\nimport type { GeminiModelConfig } from \"./common/Gemini_ModelSchema\";\n\n/**\n * AI provider for Google Gemini cloud models.\n *\n * Supports text generation, text embedding, text rewriting, and text summarization\n * via the Google Generative AI API using the `@google/generative-ai` SDK.\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 GoogleGeminiProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_gemini.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { GEMINI_TASKS } from \"@workglow/ai-provider/google-gemini\";\n * await new GoogleGeminiProvider(GEMINI_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class GoogleGeminiProvider extends AiProvider<GeminiModelConfig> {\n readonly name = GOOGLE_GEMINI;\n\n readonly taskTypes = [\n \"CountTokensTask\",\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n \"StructuredGenerationTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, GeminiModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, GeminiModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, GeminiModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AAMO,IAAM,gBAAgB;;;ACA7B;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,aACE;AAAA,QACJ;AAAA,QACA,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";AAMO,IAAM,gBAAgB;;;ACA7B;AAIO,IAAM,oBAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,I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M,OAAO,aAAa,aAAa;AAAA;AAE3C;",
|
|
10
|
+
"debugId": "1DD20092AEAA8D5F64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -18,9 +18,11 @@ var HfInferenceModelSchema = {
|
|
|
18
18
|
type: "string",
|
|
19
19
|
description: "The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct')."
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
credential_key: {
|
|
22
22
|
type: "string",
|
|
23
|
-
|
|
23
|
+
format: "credential",
|
|
24
|
+
description: "Key to look up in the credential store for the API key.",
|
|
25
|
+
"x-ui-hidden": true
|
|
24
26
|
},
|
|
25
27
|
provider: {
|
|
26
28
|
type: "string",
|
|
@@ -72,4 +74,4 @@ class HfInferenceProvider extends AiProvider {
|
|
|
72
74
|
|
|
73
75
|
export { HF_INFERENCE, HfInferenceModelSchema, HfInferenceModelRecordSchema, HfInferenceModelConfigSchema, HfInferenceProvider };
|
|
74
76
|
|
|
75
|
-
//# debugId=
|
|
77
|
+
//# debugId=3211789BD54616A564756E2164756E21
|
|
@@ -3,10 +3,10 @@
|
|
|
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
4
|
"sourcesContent": [
|
|
5
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:\n \"The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').\",\n },\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:\n \"The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').\",\n },\n credential_key: {\n type: \"string\",\n format: \"credential\",\n description:\n \"Key to look up in the credential store for the API key.\",\n \"x-ui-hidden\": true,\n },\n provider: {\n type: \"string\",\n description:\n \"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
7
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} 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, AiProviderStreamFn<any, any, HfInferenceModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, HfInferenceModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AAMO,IAAM,eAAe;;;ACA5B;AAIO,IAAM,yBAAyB;AAAA,EACpC,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,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";AAMO,IAAM,eAAe;;;ACA5B;AAIO,IAAM,yBAAyB;AAAA,EACpC,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,gBAAgB;AAAA,UACd,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,aACE;AAAA,UACF,eAAe;AAAA,QACjB;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aACE;AAAA,QACJ;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,+BAA+B;AAAA,EAC1C,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,uBAAuB;AAAA,EAC5B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,uBAAuB,QAAQ;AAAA,EAC5E,sBAAsB;AACxB;AAIO,IAAM,+BAA+B;AAAA,EAC1C,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,uBAAuB;AAAA,EAC5B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,uBAAuB,QAAQ;AAAA,EAC5E,sBAAsB;AACxB;;;AC7DA;AAAA;AAAA;AAoCO,MAAM,4BAA4B,WAAmC;AAAA,EACjE,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA,eACA;AAAA,IACA,MAAM,OAAO,aAAa,aAAa;AAAA;AAE3C;",
|
|
10
|
+
"debugId": "3211789BD54616A564756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
AnthropicModelRecordSchema,
|
|
5
5
|
AnthropicModelSchema,
|
|
6
6
|
AnthropicProvider
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-c5z3v9gn.js";
|
|
8
8
|
import {
|
|
9
9
|
GOOGLE_GEMINI,
|
|
10
10
|
GeminiModelConfigSchema,
|
|
11
11
|
GeminiModelRecordSchema,
|
|
12
12
|
GeminiModelSchema,
|
|
13
13
|
GoogleGeminiProvider
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-gjc388y4.js";
|
|
15
15
|
import {
|
|
16
16
|
HuggingFaceTransformersProvider
|
|
17
17
|
} from "./index-795ethaq.js";
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
HfInferenceModelRecordSchema,
|
|
43
43
|
HfInferenceModelSchema,
|
|
44
44
|
HfInferenceProvider
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-t54dgrfj.js";
|
|
46
46
|
import {
|
|
47
47
|
OLLAMA,
|
|
48
48
|
OLLAMA_DEFAULT_BASE_URL,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
OpenAiModelRecordSchema,
|
|
58
58
|
OpenAiModelSchema,
|
|
59
59
|
OpenAiProvider
|
|
60
|
-
} from "./index-
|
|
60
|
+
} from "./index-79rqre58.js";
|
|
61
61
|
import"./index-6j5pq722.js";
|
|
62
62
|
// src/tf-mediapipe/common/TFMP_Constants.ts
|
|
63
63
|
var TENSORFLOW_MEDIAPIPE = "TENSORFLOW_MEDIAPIPE";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-hf-inference/common/HFI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"HFI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-hf-inference/common/HFI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAoDhE,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,CA2BvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAAe,CAC7C,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,CAyCvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAC5C,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,CAqBvB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAAe,CAC3C,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,CAqBvB,CAAC;AAMF,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CACxD,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,CA0BvB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CACtD,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,CAyBvB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CACrD,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,CAyBvB,CAAC;AAMF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,sBAAsB,CAAC,CAKvF,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,sBAAsB,CAAC,CAKrD,CAAC"}
|
|
@@ -19,9 +19,11 @@ export declare const HfInferenceModelSchema: {
|
|
|
19
19
|
readonly type: "string";
|
|
20
20
|
readonly description: "The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').";
|
|
21
21
|
};
|
|
22
|
-
readonly
|
|
22
|
+
readonly credential_key: {
|
|
23
23
|
readonly type: "string";
|
|
24
|
-
readonly
|
|
24
|
+
readonly format: "credential";
|
|
25
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
26
|
+
readonly "x-ui-hidden": true;
|
|
25
27
|
};
|
|
26
28
|
readonly provider: {
|
|
27
29
|
readonly type: "string";
|
|
@@ -50,9 +52,11 @@ export declare const HfInferenceModelRecordSchema: {
|
|
|
50
52
|
readonly type: "string";
|
|
51
53
|
readonly description: "The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').";
|
|
52
54
|
};
|
|
53
|
-
readonly
|
|
55
|
+
readonly credential_key: {
|
|
54
56
|
readonly type: "string";
|
|
55
|
-
readonly
|
|
57
|
+
readonly format: "credential";
|
|
58
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
59
|
+
readonly "x-ui-hidden": true;
|
|
56
60
|
};
|
|
57
61
|
readonly provider: {
|
|
58
62
|
readonly type: "string";
|
|
@@ -104,9 +108,11 @@ export declare const HfInferenceModelConfigSchema: {
|
|
|
104
108
|
readonly type: "string";
|
|
105
109
|
readonly description: "The Hugging Face model identifier (e.g., 'meta-llama/Llama-3.3-70B-Instruct').";
|
|
106
110
|
};
|
|
107
|
-
readonly
|
|
111
|
+
readonly credential_key: {
|
|
108
112
|
readonly type: "string";
|
|
109
|
-
readonly
|
|
113
|
+
readonly format: "credential";
|
|
114
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
115
|
+
readonly "x-ui-hidden": true;
|
|
110
116
|
};
|
|
111
117
|
readonly provider: {
|
|
112
118
|
readonly type: "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/provider-hf-inference/common/HFI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"HFI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/provider-hf-inference/common/HFI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCM,CAAC;AAE1C,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQA,CAAC;AAE1C,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAErF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQA,CAAC;AAE1C,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HfInferenceModelRecordSchema,
|
|
5
5
|
HfInferenceModelSchema,
|
|
6
6
|
HfInferenceProvider
|
|
7
|
-
} from "../index-
|
|
7
|
+
} from "../index-t54dgrfj.js";
|
|
8
8
|
import {
|
|
9
9
|
__require
|
|
10
10
|
} from "../index-6j5pq722.js";
|
|
@@ -23,9 +23,10 @@ async function loadHfInferenceSDK() {
|
|
|
23
23
|
}
|
|
24
24
|
async function getClient(model) {
|
|
25
25
|
const sdk = await loadHfInferenceSDK();
|
|
26
|
-
const
|
|
26
|
+
const config = model?.provider_config;
|
|
27
|
+
const apiKey = config?.credential_key || config?.api_key || (typeof process !== "undefined" ? process.env?.HF_TOKEN : undefined);
|
|
27
28
|
if (!apiKey) {
|
|
28
|
-
throw new Error("Missing Hugging Face API key: set provider_config.
|
|
29
|
+
throw new Error("Missing Hugging Face API key: set provider_config.credential_key or the HF_TOKEN environment variable.");
|
|
29
30
|
}
|
|
30
31
|
return new sdk.InferenceClient(apiKey);
|
|
31
32
|
}
|
|
@@ -216,4 +217,4 @@ export {
|
|
|
216
217
|
HFI_STREAM_TASKS
|
|
217
218
|
};
|
|
218
219
|
|
|
219
|
-
//# debugId=
|
|
220
|
+
//# debugId=D7AEC113CA81907264756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/provider-hf-inference/common/HFI_JobRunFns.ts", "../src/provider-hf-inference/HFI_Worker.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { InferenceProviderOrPolicy } from \"@huggingface/inference\";\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n} from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport { getLogger } from \"@workglow/util\";\nimport type { HfInferenceModelConfig } from \"./HFI_ModelSchema\";\n\nlet _sdk: typeof import(\"@huggingface/inference\") | undefined;\nasync function loadHfInferenceSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"@huggingface/inference\");\n } catch {\n throw new Error(\n \"@huggingface/inference is required for Hugging Face Inference tasks. Install it with: bun add @huggingface/inference\"\n );\n }\n }\n return _sdk;\n}\n\nasync function getClient(model: HfInferenceModelConfig | undefined) {\n const sdk = await loadHfInferenceSDK();\n const apiKey =\n model?.provider_config?.api_key ||\n (typeof process !== \"undefined\" ? process.env?.HF_TOKEN : undefined);\n if (!apiKey) {\n throw new Error(\n \"Missing Hugging Face API key: set provider_config.api_key or the HF_TOKEN environment variable.\"\n );\n }\n return new sdk.InferenceClient(apiKey);\n}\n\nfunction getModelName(model: HfInferenceModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nfunction getProvider(\n model: HfInferenceModelConfig | undefined\n): InferenceProviderOrPolicy | undefined {\n return model?.provider_config?.provider as InferenceProviderOrPolicy | undefined;\n}\n\nexport const HFI_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n const logger = getLogger();\n const timerLabel = `hfi:TextGeneration:${model?.provider_config?.model_name}`;\n logger.time(timerLabel, { model: model?.provider_config?.model_name });\n\n update_progress(0, \"Starting HF Inference text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text generation\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name });\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n const logger = getLogger();\n const timerLabel = `hfi:TextEmbedding:${model?.provider_config?.model_name}`;\n logger.time(timerLabel, { model: model?.provider_config?.model_name });\n\n update_progress(0, \"Starting HF Inference text embedding\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n if (Array.isArray(input.text)) {\n const embeddings = await Promise.all(\n input.text.map((text) =>\n client.featureExtraction(\n {\n model: modelName,\n inputs: text,\n },\n { signal }\n )\n )\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name, batch: true });\n return {\n vector: embeddings.map((embedding) => new Float32Array(embedding as unknown as number[])),\n };\n }\n\n const embedding = await client.featureExtraction(\n {\n model: modelName,\n inputs: input.text,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name });\n return { vector: new Float32Array(embedding as unknown as number[]) };\n};\n\nexport const HFI_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text rewriting\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text summarization\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const HFI_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n};\n\nexport const HFI_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n};\n\nexport const HFI_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const HFI_TASKS: Record<string, AiProviderRunFn<any, any, HfInferenceModelConfig>> = {\n TextGenerationTask: HFI_TextGeneration,\n TextEmbeddingTask: HFI_TextEmbedding,\n TextRewriterTask: HFI_TextRewriter,\n TextSummaryTask: HFI_TextSummary,\n};\n\nexport const HFI_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, HfInferenceModelConfig>\n> = {\n TextGenerationTask: HFI_TextGeneration_Stream,\n TextRewriterTask: HFI_TextRewriter_Stream,\n TextSummaryTask: HFI_TextSummary_Stream,\n};\n",
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { InferenceProviderOrPolicy } from \"@huggingface/inference\";\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n} from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport { getLogger } from \"@workglow/util\";\nimport type { HfInferenceModelConfig } from \"./HFI_ModelSchema\";\n\nlet _sdk: typeof import(\"@huggingface/inference\") | undefined;\nasync function loadHfInferenceSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"@huggingface/inference\");\n } catch {\n throw new Error(\n \"@huggingface/inference is required for Hugging Face Inference tasks. Install it with: bun add @huggingface/inference\"\n );\n }\n }\n return _sdk;\n}\n\ninterface ResolvedProviderConfig {\n readonly credential_key?: string;\n readonly api_key?: string;\n readonly model_name?: string;\n readonly provider?: string;\n}\n\nasync function getClient(model: HfInferenceModelConfig | undefined) {\n const sdk = await loadHfInferenceSDK();\n const config = model?.provider_config as ResolvedProviderConfig | undefined;\n const apiKey =\n config?.credential_key ||\n config?.api_key ||\n (typeof process !== \"undefined\" ? process.env?.HF_TOKEN : undefined);\n if (!apiKey) {\n throw new Error(\n \"Missing Hugging Face API key: set provider_config.credential_key or the HF_TOKEN environment variable.\"\n );\n }\n return new sdk.InferenceClient(apiKey);\n}\n\nfunction getModelName(model: HfInferenceModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nfunction getProvider(\n model: HfInferenceModelConfig | undefined\n): InferenceProviderOrPolicy | undefined {\n return model?.provider_config?.provider as InferenceProviderOrPolicy | undefined;\n}\n\nexport const HFI_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n const logger = getLogger();\n const timerLabel = `hfi:TextGeneration:${model?.provider_config?.model_name}`;\n logger.time(timerLabel, { model: model?.provider_config?.model_name });\n\n update_progress(0, \"Starting HF Inference text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text generation\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name });\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n const logger = getLogger();\n const timerLabel = `hfi:TextEmbedding:${model?.provider_config?.model_name}`;\n logger.time(timerLabel, { model: model?.provider_config?.model_name });\n\n update_progress(0, \"Starting HF Inference text embedding\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n if (Array.isArray(input.text)) {\n const embeddings = await Promise.all(\n input.text.map((text) =>\n client.featureExtraction(\n {\n model: modelName,\n inputs: text,\n },\n { signal }\n )\n )\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name, batch: true });\n return {\n vector: embeddings.map((embedding) => new Float32Array(embedding as unknown as number[])),\n };\n }\n\n const embedding = await client.featureExtraction(\n {\n model: modelName,\n inputs: input.text,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n logger.timeEnd(timerLabel, { model: model?.provider_config?.model_name });\n return { vector: new Float32Array(embedding as unknown as number[]) };\n};\n\nexport const HFI_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text rewriting\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text summarization\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const HFI_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n};\n\nexport const HFI_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n};\n\nexport const HFI_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const HFI_TASKS: Record<string, AiProviderRunFn<any, any, HfInferenceModelConfig>> = {\n TextGenerationTask: HFI_TextGeneration,\n TextEmbeddingTask: HFI_TextEmbedding,\n TextRewriterTask: HFI_TextRewriter,\n TextSummaryTask: HFI_TextSummary,\n};\n\nexport const HFI_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, HfInferenceModelConfig>\n> = {\n TextGenerationTask: HFI_TextGeneration_Stream,\n TextRewriterTask: HFI_TextRewriter_Stream,\n TextSummaryTask: HFI_TextSummary_Stream,\n};\n",
|
|
6
6
|
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { globalServiceRegistry, WORKER_SERVER } from \"@workglow/util\";\nimport { HFI_STREAM_TASKS, HFI_TASKS } from \"./common/HFI_JobRunFns\";\nimport { HfInferenceProvider } from \"./HfInferenceProvider\";\n\nexport function HFI_WORKER_JOBRUN_REGISTER() {\n const workerServer = globalServiceRegistry.get(WORKER_SERVER);\n new HfInferenceProvider(HFI_TASKS, HFI_STREAM_TASKS).registerOnWorkerServer(workerServer);\n workerServer.sendReady();\n console.log(\"HFI_WORKER_JOBRUN registered\");\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;AAoBA;AAGA,IAAI;AACJ,eAAe,kBAAkB,GAAG;AAAA,EAClC,IAAI,CAAC,MAAM;AAAA,IACT,IAAI;AAAA,MACF,OAAO,MAAa;AAAA,MACpB,MAAM;AAAA,MACN,MAAM,IAAI,MACR,sHACF;AAAA;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA;
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;AAoBA;AAGA,IAAI;AACJ,eAAe,kBAAkB,GAAG;AAAA,EAClC,IAAI,CAAC,MAAM;AAAA,IACT,IAAI;AAAA,MACF,OAAO,MAAa;AAAA,MACpB,MAAM;AAAA,MACN,MAAM,IAAI,MACR,sHACF;AAAA;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA;AAUT,eAAe,SAAS,CAAC,OAA2C;AAAA,EAClE,MAAM,MAAM,MAAM,mBAAmB;AAAA,EACrC,MAAM,SAAS,OAAO;AAAA,EACtB,MAAM,SACJ,QAAQ,kBACR,QAAQ,YACP,OAAO,YAAY,cAAc,QAAQ,KAAK,WAAW;AAAA,EAC5D,IAAI,CAAC,QAAQ;AAAA,IACX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AAA,IACA;AAAA,EACF,GACA,EAAE,OAAO,CACX;AAAA,EAEA,iBAAiB,SAAS,QAAQ;AAAA,IAChC,MAAM,QAAQ,MAAM,QAAQ,IAAI,OAAO,WAAW;AAAA,IAClD,IAAI,OAAO;AAAA,MACT,MAAM,EAAE,MAAM,cAAc,MAAM,QAAQ,WAAW,MAAM;AAAA,IAC7D;AAAA,EACF;AAAA,EACA,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC,EAA2B;AAAA;AAOrD,IAAM,YAA+E;AAAA,EAC1F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;AAEO,IAAM,mBAGT;AAAA,EACF,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;;ACtTA;AAIO,SAAS,0BAA0B,GAAG;AAAA,EAC3C,MAAM,eAAe,sBAAsB,IAAI,aAAa;AAAA,EAC5D,IAAI,oBAAoB,WAAW,gBAAgB,EAAE,uBAAuB,YAAY;AAAA,EACxF,aAAa,UAAU;AAAA,EACvB,QAAQ,IAAI,8BAA8B;AAAA;",
|
|
9
|
+
"debugId": "D7AEC113CA81907264756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"OpenAI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkD9D,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,CA0BlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAChD,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,CA6BlB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAC/C,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,CAmBlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAmBlB,CAAC;AAMF,eAAO,MAAM,4BAA4B,EAAE,kBAAkB,CAC3D,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,CA0BlB,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CACzD,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,CAwBlB,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CACxD,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAwBlB,CAAC;AAuBF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,UAAU,CAAC,GAAG,SAAS,GAAG,IAAI,CAGvF;AAsBD,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAKlB,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,uBAAuB,CAC/D,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAGlB,CAAC;AAMF,eAAO,MAAM,2BAA2B,EAAE,eAAe,CACvD,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,CA6BlB,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,kBAAkB,CACjE,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,CAkDlB,CAAC;AAMF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAOrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,MAAM,EACN,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAMhD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,MAAM,EACN,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAGrD,CAAC"}
|
|
@@ -19,9 +19,11 @@ export declare const OpenAiModelSchema: {
|
|
|
19
19
|
readonly type: "string";
|
|
20
20
|
readonly description: "The OpenAI model identifier (e.g., 'gpt-4o', 'text-embedding-3-small').";
|
|
21
21
|
};
|
|
22
|
-
readonly
|
|
22
|
+
readonly credential_key: {
|
|
23
23
|
readonly type: "string";
|
|
24
|
-
readonly
|
|
24
|
+
readonly format: "credential";
|
|
25
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
26
|
+
readonly "x-ui-hidden": true;
|
|
25
27
|
};
|
|
26
28
|
readonly base_url: {
|
|
27
29
|
readonly type: "string";
|
|
@@ -55,9 +57,11 @@ export declare const OpenAiModelRecordSchema: {
|
|
|
55
57
|
readonly type: "string";
|
|
56
58
|
readonly description: "The OpenAI model identifier (e.g., 'gpt-4o', 'text-embedding-3-small').";
|
|
57
59
|
};
|
|
58
|
-
readonly
|
|
60
|
+
readonly credential_key: {
|
|
59
61
|
readonly type: "string";
|
|
60
|
-
readonly
|
|
62
|
+
readonly format: "credential";
|
|
63
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
64
|
+
readonly "x-ui-hidden": true;
|
|
61
65
|
};
|
|
62
66
|
readonly base_url: {
|
|
63
67
|
readonly type: "string";
|
|
@@ -114,9 +118,11 @@ export declare const OpenAiModelConfigSchema: {
|
|
|
114
118
|
readonly type: "string";
|
|
115
119
|
readonly description: "The OpenAI model identifier (e.g., 'gpt-4o', 'text-embedding-3-small').";
|
|
116
120
|
};
|
|
117
|
-
readonly
|
|
121
|
+
readonly credential_key: {
|
|
118
122
|
readonly type: "string";
|
|
119
|
-
readonly
|
|
123
|
+
readonly format: "credential";
|
|
124
|
+
readonly description: "Key to look up in the credential store for the API key.";
|
|
125
|
+
readonly "x-ui-hidden": true;
|
|
120
126
|
};
|
|
121
127
|
readonly base_url: {
|
|
122
128
|
readonly type: "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"OpenAI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCW,CAAC;AAE1C,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQK,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQK,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
OpenAiModelRecordSchema,
|
|
5
5
|
OpenAiModelSchema,
|
|
6
6
|
OpenAiProvider
|
|
7
|
-
} from "../index-
|
|
7
|
+
} from "../index-79rqre58.js";
|
|
8
8
|
import {
|
|
9
9
|
__require
|
|
10
10
|
} from "../index-6j5pq722.js";
|
|
@@ -23,14 +23,15 @@ async function loadOpenAISDK() {
|
|
|
23
23
|
}
|
|
24
24
|
async function getClient(model) {
|
|
25
25
|
const OpenAI = await loadOpenAISDK();
|
|
26
|
-
const
|
|
26
|
+
const config = model?.provider_config;
|
|
27
|
+
const apiKey = config?.credential_key || config?.api_key || (typeof process !== "undefined" ? process.env?.OPENAI_API_KEY : undefined);
|
|
27
28
|
if (!apiKey) {
|
|
28
|
-
throw new Error("Missing OpenAI API key: set provider_config.
|
|
29
|
+
throw new Error("Missing OpenAI API key: set provider_config.credential_key or the OPENAI_API_KEY environment variable.");
|
|
29
30
|
}
|
|
30
31
|
return new OpenAI({
|
|
31
32
|
apiKey,
|
|
32
|
-
baseURL:
|
|
33
|
-
organization:
|
|
33
|
+
baseURL: config?.base_url || undefined,
|
|
34
|
+
organization: config?.organization || undefined,
|
|
34
35
|
dangerouslyAllowBrowser: true
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -317,4 +318,4 @@ export {
|
|
|
317
318
|
OPENAI
|
|
318
319
|
};
|
|
319
320
|
|
|
320
|
-
//# debugId=
|
|
321
|
+
//# debugId=EFF3A35E2BB4A50F64756E2164756E21
|