@uploadista/flow-images-replicate 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/image-ai-plugin.ts +3 -3
- package/.turbo/turbo-build.log +0 -22
- package/tsconfig.tsbuildinfo +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -18,20 +18,20 @@ type PluginConfig = string | {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Create the Replicate ImageAI plugin
|
|
21
|
-
* Supports both static credentials (OSS) and dynamic credential providers (
|
|
21
|
+
* Supports both static credentials (OSS) and dynamic credential providers (UploadistaCloud)
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* // Static credentials (OSS)
|
|
25
25
|
* imageAiPlugin(process.env.REPLICATE_API_TOKEN)
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
* // Dynamic credentials with function (
|
|
28
|
+
* // Dynamic credentials with function (UploadistaCloud)
|
|
29
29
|
* imageAiPlugin({
|
|
30
30
|
* credentialProvider: (context) => Effect.succeed({ apiKey: "..." })
|
|
31
31
|
* })
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
-
* // Dynamic credentials with Effect service (
|
|
34
|
+
* // Dynamic credentials with Effect service (UploadistaCloud)
|
|
35
35
|
* imageAiPlugin({
|
|
36
36
|
* useCredentialProviderService: true
|
|
37
37
|
* })
|
package/dist/index.d.ts
CHANGED
|
@@ -18,20 +18,20 @@ type PluginConfig = string | {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Create the Replicate ImageAI plugin
|
|
21
|
-
* Supports both static credentials (OSS) and dynamic credential providers (
|
|
21
|
+
* Supports both static credentials (OSS) and dynamic credential providers (UploadistaCloud)
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* // Static credentials (OSS)
|
|
25
25
|
* imageAiPlugin(process.env.REPLICATE_API_TOKEN)
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
* // Dynamic credentials with function (
|
|
28
|
+
* // Dynamic credentials with function (UploadistaCloud)
|
|
29
29
|
* imageAiPlugin({
|
|
30
30
|
* credentialProvider: (context) => Effect.succeed({ apiKey: "..." })
|
|
31
31
|
* })
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
-
* // Dynamic credentials with Effect service (
|
|
34
|
+
* // Dynamic credentials with Effect service (UploadistaCloud)
|
|
35
35
|
* imageAiPlugin({
|
|
36
36
|
* useCredentialProviderService: true
|
|
37
37
|
* })
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["CredentialProviderService"],"sources":["../src/image-ai-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n CredentialProvider as CredentialProviderService,\n type ImageAiContext,\n ImageAiPlugin,\n} from \"@uploadista/core/flow\";\nimport { Effect, Layer, Option } from \"effect\";\nimport Replicate from \"replicate\";\n\ntype ModelId = `${string}/${string}` | `${string}/${string}:${string}`;\n\ntype RemoveBackgroundOutput = {\n url: () => string;\n};\n\ntype ReplicateCredentials = {\n apiKey: string;\n};\n\n// Credential provider function type\ntype CredentialProvider = (\n context: ImageAiContext & { serviceType: \"replicate\" },\n) => Effect.Effect<ReplicateCredentials, UploadistaError>;\n\n// Plugin configuration can be either a static API key or options with credential provider or service\ntype PluginConfig =\n | string\n | {\n credentialProvider?: CredentialProvider;\n useCredentialProviderService?: boolean;\n removeBackgroundModelId?: ModelId;\n describeImageModelId?: ModelId;\n };\n\n/**\n * Create the Replicate ImageAI plugin\n * Supports both static credentials (OSS) and dynamic credential providers (
|
|
1
|
+
{"version":3,"file":"index.js","names":["CredentialProviderService"],"sources":["../src/image-ai-plugin.ts"],"sourcesContent":["import { UploadistaError } from \"@uploadista/core/errors\";\nimport {\n CredentialProvider as CredentialProviderService,\n type ImageAiContext,\n ImageAiPlugin,\n} from \"@uploadista/core/flow\";\nimport { Effect, Layer, Option } from \"effect\";\nimport Replicate from \"replicate\";\n\ntype ModelId = `${string}/${string}` | `${string}/${string}:${string}`;\n\ntype RemoveBackgroundOutput = {\n url: () => string;\n};\n\ntype ReplicateCredentials = {\n apiKey: string;\n};\n\n// Credential provider function type\ntype CredentialProvider = (\n context: ImageAiContext & { serviceType: \"replicate\" },\n) => Effect.Effect<ReplicateCredentials, UploadistaError>;\n\n// Plugin configuration can be either a static API key or options with credential provider or service\ntype PluginConfig =\n | string\n | {\n credentialProvider?: CredentialProvider;\n useCredentialProviderService?: boolean;\n removeBackgroundModelId?: ModelId;\n describeImageModelId?: ModelId;\n };\n\n/**\n * Create the Replicate ImageAI plugin\n * Supports both static credentials (OSS) and dynamic credential providers (UploadistaCloud)\n *\n * @example\n * // Static credentials (OSS)\n * imageAiPlugin(process.env.REPLICATE_API_TOKEN)\n *\n * @example\n * // Dynamic credentials with function (UploadistaCloud)\n * imageAiPlugin({\n * credentialProvider: (context) => Effect.succeed({ apiKey: \"...\" })\n * })\n *\n * @example\n * // Dynamic credentials with Effect service (UploadistaCloud)\n * imageAiPlugin({\n * useCredentialProviderService: true\n * })\n */\nexport const imageAiPlugin = (\n config: PluginConfig,\n options?: {\n removeBackgroundModelId?: ModelId;\n describeImageModelId?: ModelId;\n },\n) => {\n // Parse configuration\n const isStatic = typeof config === \"string\";\n const staticApiKey = isStatic ? config : null;\n const credentialProvider = isStatic ? null : config.credentialProvider;\n const useCredentialProviderService = isStatic\n ? false\n : config.useCredentialProviderService;\n\n // Model IDs can come from either the config object or the options parameter\n const removeBackgroundModelId =\n (isStatic\n ? options?.removeBackgroundModelId\n : config.removeBackgroundModelId) ||\n \"lucataco/remove-bg:95fcc2a26d3899cd6c2691c900465aaeff466285a65c14638cc5f36f34befaf1\";\n const describeImageModelId =\n (isStatic ? options?.describeImageModelId : config.describeImageModelId) ||\n \"zsxkib/blip-3:499bec581d8f64060fd695ec0c34d7595c6824c4118259aa8b0788e0d2d903e1\";\n\n // Helper to get API token (either static, from provider function, or from service)\n const getApiToken = (context: ImageAiContext) => {\n if (staticApiKey) {\n return Effect.succeed(staticApiKey);\n }\n if (useCredentialProviderService) {\n return Effect.gen(function* () {\n const credentialProviderService = yield* Effect.serviceOption(\n CredentialProviderService,\n );\n\n if (Option.isNone(credentialProviderService)) {\n return yield* Effect.fail(\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: new Error(\"Credential provider service not found\"),\n }),\n );\n } else {\n const credentials =\n yield* credentialProviderService.value.getCredential({\n clientId: context.clientId,\n serviceType: \"replicate\",\n });\n\n if (\n typeof credentials === \"object\" &&\n credentials !== null &&\n \"apiKey\" in credentials &&\n typeof credentials.apiKey === \"string\"\n ) {\n return credentials.apiKey;\n }\n }\n\n return yield* Effect.fail(\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: new Error(\"Invalid credential format from service\"),\n }),\n );\n });\n }\n if (credentialProvider) {\n return Effect.gen(function* () {\n const credentials = yield* credentialProvider({\n ...context,\n serviceType: \"replicate\",\n });\n return credentials.apiKey;\n });\n }\n return Effect.fail(\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: new Error(\"No API credentials configured\"),\n }),\n );\n };\n\n return Layer.succeed(\n ImageAiPlugin,\n ImageAiPlugin.of({\n removeBackground: (inputUrl, context) => {\n return Effect.gen(function* () {\n // Get API token (static or from credential provider)\n const apiToken = yield* getApiToken(context);\n\n const output = yield* Effect.tryPromise({\n try: async () => {\n const replicate = new Replicate({\n auth: apiToken,\n });\n\n const input = {\n image: inputUrl,\n };\n\n console.log(\"input\", input);\n\n return (await replicate.run(removeBackgroundModelId, {\n input,\n })) as RemoveBackgroundOutput;\n },\n catch: (error) => {\n console.log(\"error\", error);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: error,\n });\n },\n });\n return { outputUrl: output.url() };\n });\n },\n describeImage: (inputUrl, context) => {\n return Effect.gen(function* () {\n // Get API token (static or from credential provider)\n const apiToken = yield* getApiToken(context);\n\n const output = yield* Effect.tryPromise({\n try: async () => {\n const replicate = new Replicate({\n auth: apiToken,\n });\n\n return (await replicate.run(describeImageModelId, {\n input: {\n image: inputUrl,\n top_k: 50,\n top_p: 1,\n caption: false,\n question: \"What is shown in the image?\",\n do_sample: false,\n num_beams: 1,\n temperature: 1,\n system_prompt:\n \"A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\",\n length_penalty: 1,\n max_new_tokens: 768,\n repetition_penalty: 1,\n },\n })) as unknown as string;\n },\n catch: (error) => {\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause: error,\n });\n },\n });\n return { description: output };\n });\n },\n }),\n );\n};\n"],"mappings":"wNAsDA,MAAa,GACX,EACA,IAIG,CAEH,IAAM,EAAW,OAAO,GAAW,SAC7B,EAAe,EAAW,EAAS,KACnC,EAAqB,EAAW,KAAO,EAAO,mBAC9C,EAA+B,EACjC,GACA,EAAO,6BAGL,GACH,EACG,GAAS,wBACT,EAAO,0BACX,sFACI,GACH,EAAW,GAAS,qBAAuB,EAAO,uBACnD,iFAGI,EAAe,GACf,EACK,EAAO,QAAQ,EAAa,CAEjC,EACK,EAAO,IAAI,WAAa,CAC7B,IAAM,EAA4B,MAAO,EAAO,cAC9CA,EACD,CAED,GAAI,EAAO,OAAO,EAA0B,CAC1C,OAAO,MAAO,EAAO,KACnB,EAAgB,SAAS,gBAAiB,CACxC,MAAW,MAAM,wCAAwC,CAC1D,CAAC,CACH,CACI,CACL,IAAM,EACJ,MAAO,EAA0B,MAAM,cAAc,CACnD,SAAU,EAAQ,SAClB,YAAa,YACd,CAAC,CAEJ,GACE,OAAO,GAAgB,UACvB,GACA,WAAY,GACZ,OAAO,EAAY,QAAW,SAE9B,OAAO,EAAY,OAIvB,OAAO,MAAO,EAAO,KACnB,EAAgB,SAAS,g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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/flow-images-replicate",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"description": "Replicate image AI processing service for Uploadista Flow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"replicate": "1.3.0",
|
|
17
17
|
"effect": "3.18.4",
|
|
18
18
|
"zod": "4.1.12",
|
|
19
|
-
"@uploadista/core": "0.0.
|
|
19
|
+
"@uploadista/core": "0.0.7"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "24.
|
|
22
|
+
"@types/node": "24.9.1",
|
|
23
23
|
"tsdown": "0.15.9",
|
|
24
|
-
"@uploadista/typescript-config": "0.0.
|
|
24
|
+
"@uploadista/typescript-config": "0.0.7"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsdown",
|
package/src/image-ai-plugin.ts
CHANGED
|
@@ -34,20 +34,20 @@ type PluginConfig =
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Create the Replicate ImageAI plugin
|
|
37
|
-
* Supports both static credentials (OSS) and dynamic credential providers (
|
|
37
|
+
* Supports both static credentials (OSS) and dynamic credential providers (UploadistaCloud)
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* // Static credentials (OSS)
|
|
41
41
|
* imageAiPlugin(process.env.REPLICATE_API_TOKEN)
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
|
-
* // Dynamic credentials with function (
|
|
44
|
+
* // Dynamic credentials with function (UploadistaCloud)
|
|
45
45
|
* imageAiPlugin({
|
|
46
46
|
* credentialProvider: (context) => Effect.succeed({ apiKey: "..." })
|
|
47
47
|
* })
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
|
-
* // Dynamic credentials with Effect service (
|
|
50
|
+
* // Dynamic credentials with Effect service (UploadistaCloud)
|
|
51
51
|
* imageAiPlugin({
|
|
52
52
|
* useCredentialProviderService: true
|
|
53
53
|
* })
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> @uploadista/flow-images-replicate@0.0.3 build /Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/images/replicate
|
|
4
|
-
> tsdown
|
|
5
|
-
|
|
6
|
-
[34mℹ[39m tsdown [2mv0.15.9[22m powered by rolldown [2mv1.0.0-beta.44[22m
|
|
7
|
-
[34mℹ[39m Using tsdown config: [4m/Users/denislaboureyras/Documents/uploadista/dev/uploadista-workspace/uploadista-sdk/packages/flow/images/replicate/tsdown.config.ts[24m
|
|
8
|
-
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
9
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
|
-
[34mℹ[39m Build start
|
|
11
|
-
[34mℹ[39m Cleaning 7 files
|
|
12
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m2.77 kB[22m [2m│ gzip: 1.31 kB[22m
|
|
13
|
-
[34mℹ[39m [33m[CJS][39m 1 files, total: 2.77 kB
|
|
14
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.js[22m [2m2.15 kB[22m [2m│ gzip: 1.08 kB[22m
|
|
15
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mindex.js.map [2m8.68 kB[22m [2m│ gzip: 2.65 kB[22m
|
|
16
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mindex.d.ts.map [2m0.51 kB[22m [2m│ gzip: 0.31 kB[22m
|
|
17
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m1.44 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
18
|
-
[34mℹ[39m [34m[ESM][39m 4 files, total: 12.78 kB
|
|
19
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mindex.d.cts.map [2m0.51 kB[22m [2m│ gzip: 0.31 kB[22m
|
|
20
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m1.44 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
21
|
-
[34mℹ[39m [33m[CJS][39m 2 files, total: 1.95 kB
|
|
22
|
-
[32m✔[39m Build complete in [32m13631ms[39m
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/image-ai-plugin.ts","./src/index.ts"],"version":"5.9.3"}
|