aigorithm commited on
Commit
2254a72
1 Parent(s): 7d16657
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. CONTRIBUTORS.md +10 -0
  2. Dockerfile +65 -0
  3. LICENCE.md +170 -0
  4. README.md +156 -8
  5. components.json +16 -0
  6. next.config.js +11 -0
  7. package-lock.json +0 -0
  8. package.json +76 -0
  9. postcss.config.js +6 -0
  10. public/.DS_Store +0 -0
  11. public/bubble.jpg +0 -0
  12. public/favicon.ico +0 -0
  13. public/favicon/Icon/r +0 -0
  14. public/favicon/favicon-114-precomposed.png +0 -0
  15. public/favicon/favicon-120-precomposed.png +0 -0
  16. public/favicon/favicon-144-precomposed.png +0 -0
  17. public/favicon/favicon-152-precomposed.png +0 -0
  18. public/favicon/favicon-180-precomposed.png +0 -0
  19. public/favicon/favicon-192.png +0 -0
  20. public/favicon/favicon-32.png +0 -0
  21. public/favicon/favicon-36.png +0 -0
  22. public/favicon/favicon-48.png +0 -0
  23. public/favicon/favicon-57.png +0 -0
  24. public/favicon/favicon-60.png +0 -0
  25. public/favicon/favicon-72-precomposed.png +0 -0
  26. public/favicon/favicon-72.png +0 -0
  27. public/favicon/favicon-76.png +0 -0
  28. public/favicon/favicon-96.png +0 -0
  29. public/favicon/favicon.ico +0 -0
  30. public/favicon/index.html +133 -0
  31. public/favicon/manifest.json +41 -0
  32. public/icon.png +0 -0
  33. public/layouts/layout0.jpg +0 -0
  34. public/layouts/layout0_hd.jpg +0 -0
  35. public/layouts/layout1.jpg +0 -0
  36. public/layouts/layout1_hd.jpg +0 -0
  37. public/layouts/layout2.jpg +0 -0
  38. public/layouts/layout2_hd.jpg +0 -0
  39. public/layouts/layout3 hd.jpg +0 -0
  40. public/layouts/layout3.jpg +0 -0
  41. public/layouts/layout4 hd.jpg +0 -0
  42. public/layouts/layout4.jpg +0 -0
  43. public/mask.png +0 -0
  44. public/next.svg +1 -0
  45. public/vercel.svg +1 -0
  46. src/app/engine/caption.ts +54 -0
  47. src/app/engine/censorship.ts +184 -0
  48. src/app/engine/community.ts +135 -0
  49. src/app/engine/forbidden.ts +6 -0
  50. src/app/engine/presets.ts +588 -0
CONTRIBUTORS.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ This project was developed by Julian Bilcke (@jbilcke-hf), as part of his work at Hugging Face.
2
+
3
+ ------------------------------------------
4
+
5
+ A huge thanks to external developers for their contributions!
6
+
7
+ 艾逗笔 (@idoubi):
8
+ - [feature] Added support for OpenAI: https://github.com/jbilcke-hf/ai-comic-factory/pull/6
9
+ - [bug] predict import error (use dynamic imports for the LLM provider): https://github.com/jbilcke-hf/ai-comic-factory/pull/9
10
+
Dockerfile ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine AS base
2
+
3
+ # Install dependencies only when needed
4
+ FROM base AS deps
5
+ # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6
+ RUN apk add --no-cache libc6-compat
7
+ WORKDIR /app
8
+
9
+ # Install dependencies based on the preferred package manager
10
+ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
11
+ RUN \
12
+ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13
+ elif [ -f package-lock.json ]; then npm ci; \
14
+ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
15
+ else echo "Lockfile not found." && exit 1; \
16
+ fi
17
+
18
+ # Uncomment the following lines if you want to use a secret at buildtime,
19
+ # for example to access your private npm packages
20
+ # RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true \
21
+ # $(cat /run/secrets/HF_EXAMPLE_SECRET)
22
+
23
+ # Rebuild the source code only when needed
24
+ FROM base AS builder
25
+ WORKDIR /app
26
+ COPY --from=deps /app/node_modules ./node_modules
27
+ COPY . .
28
+
29
+ # Next.js collects completely anonymous telemetry data about general usage.
30
+ # Learn more here: https://nextjs.org/telemetry
31
+ # Uncomment the following line in case you want to disable telemetry during the build.
32
+ # ENV NEXT_TELEMETRY_DISABLED 1
33
+
34
+ # RUN yarn build
35
+
36
+ # If you use yarn, comment out this line and use the line above
37
+ RUN npm run build
38
+
39
+ # Production image, copy all the files and run next
40
+ FROM base AS runner
41
+ WORKDIR /app
42
+
43
+ ENV NODE_ENV production
44
+ # Uncomment the following line in case you want to disable telemetry during runtime.
45
+ # ENV NEXT_TELEMETRY_DISABLED 1
46
+
47
+ RUN addgroup --system --gid 1001 nodejs
48
+ RUN adduser --system --uid 1001 nextjs
49
+
50
+ COPY --from=builder /app/public ./public
51
+
52
+ # Automatically leverage output traces to reduce image size
53
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
54
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
55
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
56
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
57
+ # COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
58
+
59
+ USER nextjs
60
+
61
+ EXPOSE 3000
62
+
63
+ ENV PORT 3000
64
+
65
+ CMD ["node", "server.js"]
LICENCE.md ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ ==============
3
+
4
+ _Version 2.0, January 2004_
5
+ _&lt;<http://www.apache.org/licenses/>&gt;_
6
+
7
+ ### Terms and Conditions for use, reproduction, and distribution
8
+
9
+ #### 1. Definitions
10
+
11
+ “License” shall mean the terms and conditions for use, reproduction, and
12
+ distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ “Licensor” shall mean the copyright owner or entity authorized by the copyright
15
+ owner that is granting the License.
16
+
17
+ “Legal Entity” shall mean the union of the acting entity and all other entities
18
+ that control, are controlled by, or are under common control with that entity.
19
+ For the purposes of this definition, “control” means **(i)** the power, direct or
20
+ indirect, to cause the direction or management of such entity, whether by
21
+ contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or **(iii)** beneficial ownership of such entity.
23
+
24
+ “You” (or “Your”) shall mean an individual or Legal Entity exercising
25
+ permissions granted by this License.
26
+
27
+ “Source” form shall mean the preferred form for making modifications, including
28
+ but not limited to software source code, documentation source, and configuration
29
+ files.
30
+
31
+ “Object” form shall mean any form resulting from mechanical transformation or
32
+ translation of a Source form, including but not limited to compiled object code,
33
+ generated documentation, and conversions to other media types.
34
+
35
+ “Work” shall mean the work of authorship, whether in Source or Object form, made
36
+ available under the License, as indicated by a copyright notice that is included
37
+ in or attached to the work (an example is provided in the Appendix below).
38
+
39
+ “Derivative Works” shall mean any work, whether in Source or Object form, that
40
+ is based on (or derived from) the Work and for which the editorial revisions,
41
+ annotations, elaborations, or other modifications represent, as a whole, an
42
+ original work of authorship. For the purposes of this License, Derivative Works
43
+ shall not include works that remain separable from, or merely link (or bind by
44
+ name) to the interfaces of, the Work and Derivative Works thereof.
45
+
46
+ “Contribution” shall mean any work of authorship, including the original version
47
+ of the Work and any modifications or additions to that Work or Derivative Works
48
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
49
+ by the copyright owner or by an individual or Legal Entity authorized to submit
50
+ on behalf of the copyright owner. For the purposes of this definition,
51
+ “submitted” means any form of electronic, verbal, or written communication sent
52
+ to the Licensor or its representatives, including but not limited to
53
+ communication on electronic mailing lists, source code control systems, and
54
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
55
+ the purpose of discussing and improving the Work, but excluding communication
56
+ that is conspicuously marked or otherwise designated in writing by the copyright
57
+ owner as “Not a Contribution.”
58
+
59
+ “Contributor” shall mean Licensor and any individual or Legal Entity on behalf
60
+ of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ #### 2. Grant of Copyright License
64
+
65
+ Subject to the terms and conditions of this License, each Contributor hereby
66
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
67
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
68
+ publicly display, publicly perform, sublicense, and distribute the Work and such
69
+ Derivative Works in Source or Object form.
70
+
71
+ #### 3. Grant of Patent License
72
+
73
+ Subject to the terms and conditions of this License, each Contributor hereby
74
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
75
+ irrevocable (except as stated in this section) patent license to make, have
76
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
77
+ such license applies only to those patent claims licensable by such Contributor
78
+ that are necessarily infringed by their Contribution(s) alone or by combination
79
+ of their Contribution(s) with the Work to which such Contribution(s) was
80
+ submitted. If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this License
84
+ for that Work shall terminate as of the date such litigation is filed.
85
+
86
+ #### 4. Redistribution
87
+
88
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
89
+ in any medium, with or without modifications, and in Source or Object form,
90
+ provided that You meet the following conditions:
91
+
92
+ * **(a)** You must give any other recipients of the Work or Derivative Works a copy of
93
+ this License; and
94
+ * **(b)** You must cause any modified files to carry prominent notices stating that You
95
+ changed the files; and
96
+ * **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
97
+ all copyright, patent, trademark, and attribution notices from the Source form
98
+ of the Work, excluding those notices that do not pertain to any part of the
99
+ Derivative Works; and
100
+ * **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
101
+ Derivative Works that You distribute must include a readable copy of the
102
+ attribution notices contained within such NOTICE file, excluding those notices
103
+ that do not pertain to any part of the Derivative Works, in at least one of the
104
+ following places: within a NOTICE text file distributed as part of the
105
+ Derivative Works; within the Source form or documentation, if provided along
106
+ with the Derivative Works; or, within a display generated by the Derivative
107
+ Works, if and wherever such third-party notices normally appear. The contents of
108
+ the NOTICE file are for informational purposes only and do not modify the
109
+ License. You may add Your own attribution notices within Derivative Works that
110
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
111
+ provided that such additional attribution notices cannot be construed as
112
+ modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may provide
115
+ additional or different license terms and conditions for use, reproduction, or
116
+ distribution of Your modifications, or for any such Derivative Works as a whole,
117
+ provided Your use, reproduction, and distribution of the Work otherwise complies
118
+ with the conditions stated in this License.
119
+
120
+ #### 5. Submission of Contributions
121
+
122
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
123
+ for inclusion in the Work by You to the Licensor shall be under the terms and
124
+ conditions of this License, without any additional terms or conditions.
125
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
126
+ any separate license agreement you may have executed with Licensor regarding
127
+ such Contributions.
128
+
129
+ #### 6. Trademarks
130
+
131
+ This License does not grant permission to use the trade names, trademarks,
132
+ service marks, or product names of the Licensor, except as required for
133
+ reasonable and customary use in describing the origin of the Work and
134
+ reproducing the content of the NOTICE file.
135
+
136
+ #### 7. Disclaimer of Warranty
137
+
138
+ Unless required by applicable law or agreed to in writing, Licensor provides the
139
+ Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
141
+ including, without limitation, any warranties or conditions of TITLE,
142
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
143
+ solely responsible for determining the appropriateness of using or
144
+ redistributing the Work and assume any risks associated with Your exercise of
145
+ permissions under this License.
146
+
147
+ #### 8. Limitation of Liability
148
+
149
+ In no event and under no legal theory, whether in tort (including negligence),
150
+ contract, or otherwise, unless required by applicable law (such as deliberate
151
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special, incidental,
153
+ or consequential damages of any character arising as a result of this License or
154
+ out of the use or inability to use the Work (including but not limited to
155
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
156
+ any and all other commercial damages or losses), even if such Contributor has
157
+ been advised of the possibility of such damages.
158
+
159
+ #### 9. Accepting Warranty or Additional Liability
160
+
161
+ While redistributing the Work or Derivative Works thereof, You may choose to
162
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
163
+ other liability obligations and/or rights consistent with this License. However,
164
+ in accepting such obligations, You may act only on Your own behalf and on Your
165
+ sole responsibility, not on behalf of any other Contributor, and only if You
166
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
167
+ incurred by, or claims asserted against, such Contributor by reason of your
168
+ accepting any such warranty or additional liability.
169
+
170
+ _END OF TERMS AND CONDITIONS_
README.md CHANGED
@@ -1,12 +1,160 @@
1
  ---
2
- title: Aicomicsbook
3
- emoji: 🦀
4
  colorFrom: red
5
- colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.27.2
8
- app_file: app.py
9
- pinned: false
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: AI Comic Factory
3
+ emoji: 👩‍🎨
4
  colorFrom: red
5
+ colorTo: yellow
6
+ sdk: docker
7
+ pinned: true
8
+ app_port: 3000
9
+ disable_embedding: true
10
  ---
11
 
12
+ # AI Comic Factory
13
+
14
+ *(note: the website "aicomicfactory.com" is not affiliated with the AI Comic Factory project, nor it is created or maintained by the AI Comic Factory team. If you see their website has an issue, please contact them directly)*
15
+
16
+ ## Running the project at home
17
+
18
+ First, I would like to highlight that everything is open-source (see [here](https://huggingface.co/spaces/jbilcke-hf/ai-comic-factory/tree/main), [here](https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/tree/main), [here](https://huggingface.co/spaces/hysts/SD-XL/tree/main), [here](https://github.com/huggingface/text-generation-inference)).
19
+
20
+ However the project isn't a monolithic Space that can be duplicated and ran immediately:
21
+ it requires various components to run for the frontend, backend, LLM, SDXL etc.
22
+
23
+ If you try to duplicate the project, open the `.env` you will see it requires some variables.
24
+
25
+ Provider config:
26
+ - `LLM_ENGINE`: can be one of: "INFERENCE_API", "INFERENCE_ENDPOINT", "OPENAI"
27
+ - `RENDERING_ENGINE`: can be one of: "INFERENCE_API", "INFERENCE_ENDPOINT", "REPLICATE", "VIDEOCHAIN" for now, unless you code your custom solution
28
+
29
+ Auth config:
30
+ - `AUTH_HF_API_TOKEN`: only if you decide to use OpenAI for the LLM engine necessary if you decide to use an inference api model or a custom inference endpoint
31
+ - `AUTH_OPENAI_TOKEN`: only if you decide to use OpenAI for the LLM engine
32
+ - `AITH_VIDEOCHAIN_API_TOKEN`: secret token to access the VideoChain API server
33
+ - `AUTH_REPLICATE_API_TOKEN`: in case you want to use Replicate.com
34
+
35
+ Rendering config:
36
+ - `RENDERING_HF_INFERENCE_ENDPOINT_URL`: necessary if you decide to use a custom inference endpoint
37
+ - `RENDERING_REPLICATE_API_MODEL_VERSION`: url to the VideoChain API server
38
+ - `RENDERING_HF_INFERENCE_ENDPOINT_URL`: optional, default to nothing
39
+ - `RENDERING_HF_INFERENCE_API_BASE_MODEL`: optional, defaults to "stabilityai/stable-diffusion-xl-base-1.0"
40
+ - `RENDERING_HF_INFERENCE_API_REFINER_MODEL`: optional, defaults to "stabilityai/stable-diffusion-xl-refiner-1.0"
41
+ - `RENDERING_REPLICATE_API_MODEL`: optional, defaults to "stabilityai/sdxl"
42
+ - `RENDERING_REPLICATE_API_MODEL_VERSION`: optional, in case you want to change the version
43
+
44
+ Language model config:
45
+ - `LLM_HF_INFERENCE_ENDPOINT_URL`: "https://llama-v2-70b-chat.ngrok.io"
46
+ - `LLM_HF_INFERENCE_API_MODEL`: "codellama/CodeLlama-7b-hf"
47
+
48
+ In addition, there are some community sharing variables that you can just ignore.
49
+ Those variables are not required to run the AI Comic Factory on your own website or computer
50
+ (they are meant to create a connection with the Hugging Face community,
51
+ and thus only make sense for official Hugging Face apps):
52
+ - `NEXT_PUBLIC_ENABLE_COMMUNITY_SHARING`: you don't need this
53
+ - `COMMUNITY_API_URL`: you don't need this
54
+ - `COMMUNITY_API_TOKEN`: you don't need this
55
+ - `COMMUNITY_API_ID`: you don't need this
56
+
57
+ Please read the `.env` default config file for more informations.
58
+ To customise a variable locally, you should create a `.env.local`
59
+ (do not commit this file as it will contain your secrets).
60
+
61
+ -> If you intend to run it with local, cloud-hosted and/or proprietary models **you are going to need to code 👨‍💻**.
62
+
63
+ ## The LLM API (Large Language Model)
64
+
65
+ Currently the AI Comic Factory uses [Llama-2 70b](https://huggingface.co/blog/llama2) through an [Inference Endpoint](https://huggingface.co/docs/inference-endpoints/index).
66
+
67
+ You have three options:
68
+
69
+ ### Option 1: Use an Inference API model
70
+
71
+ This is a new option added recently, where you can use one of the models from the Hugging Face Hub. By default we suggest to use CodeLlama 34b as it will provide better results than the 7b model.
72
+
73
+ To activate it, create a `.env.local` configuration file:
74
+
75
+ ```bash
76
+ LLM_ENGINE="INFERENCE_API"
77
+
78
+ HF_API_TOKEN="Your Hugging Face token"
79
+
80
+ # codellama/CodeLlama-7b-hf" is used by default, but you can change this
81
+ # note: You should use a model able to generate JSON responses,
82
+ # so it is storngly suggested to use at least the 34b model
83
+ HF_INFERENCE_API_MODEL="codellama/CodeLlama-7b-hf"
84
+ ```
85
+
86
+ ### Option 2: Use an Inference Endpoint URL
87
+
88
+ If you would like to run the AI Comic Factory on a private LLM running on the Hugging Face Inference Endpoint service, create a `.env.local` configuration file:
89
+
90
+ ```bash
91
+ LLM_ENGINE="INFERENCE_ENDPOINT"
92
+
93
+ HF_API_TOKEN="Your Hugging Face token"
94
+
95
+ HF_INFERENCE_ENDPOINT_URL="path to your inference endpoint url"
96
+ ```
97
+
98
+ To run this kind of LLM locally, you can use [TGI](https://github.com/huggingface/text-generation-inference) (Please read [this post](https://github.com/huggingface/text-generation-inference/issues/726) for more information about the licensing).
99
+
100
+ ### Option 3: Use an OpenAI API Key
101
+
102
+ This is a new option added recently, where you can use OpenAI API with an OpenAI API Key.
103
+
104
+ To activate it, create a `.env.local` configuration file:
105
+
106
+ ```bash
107
+ LLM_ENGINE="OPENAI"
108
+
109
+ # default openai api base url is: https://api.openai.com/v1
110
+ LLM_OPENAI_API_BASE_URL="Your OpenAI API Base URL"
111
+
112
+ LLM_OPENAI_API_MODEL="gpt-3.5-turbo"
113
+
114
+ AUTH_OPENAI_API_KEY="Your OpenAI API Key"
115
+ ```
116
+
117
+ ### Option 4: Fork and modify the code to use a different LLM system
118
+
119
+ Another option could be to disable the LLM completely and replace it with another LLM protocol and/or provider (eg. Claude, Replicate), or a human-generated story instead (by returning mock or static data).
120
+
121
+ ### Notes
122
+
123
+ It is possible that I modify the AI Comic Factory to make it easier in the future (eg. add support for Claude or Replicate)
124
+
125
+ ## The Rendering API
126
+
127
+ This API is used to generate the panel images. This is an API I created for my various projects at Hugging Face.
128
+
129
+ I haven't written documentation for it yet, but basically it is "just a wrapper ™" around other existing APIs:
130
+
131
+ - The [hysts/SD-XL](https://huggingface.co/spaces/hysts/SD-XL?duplicate=true) Space by [@hysts](https://huggingface.co/hysts)
132
+ - And other APIs for making videos, adding audio etc.. but you won't need them for the AI Comic Factory
133
+
134
+ ### Option 1: Deploy VideoChain yourself
135
+
136
+ You will have to [clone](https://huggingface.co/spaces/jbilcke-hf/VideoChain-API?duplicate=true) the [source-code](https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/tree/main)
137
+
138
+ Unfortunately, I haven't had the time to write the documentation for VideoChain yet.
139
+ (When I do I will update this document to point to the VideoChain's README)
140
+
141
+
142
+ ### Option 2: Use Replicate
143
+
144
+ To use Replicate, create a `.env.local` configuration file:
145
+
146
+ ```bash
147
+ RENDERING_ENGINE="REPLICATE"
148
+
149
+ RENDERING_REPLICATE_API_MODEL="stabilityai/sdxl"
150
+
151
+ RENDERING_REPLICATE_API_MODEL_VERSION="da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf"
152
+
153
+ AUTH_REPLICATE_API_TOKEN="Your Replicate token"
154
+ ```
155
+
156
+ ### Option 3: Use another SDXL API
157
+
158
+ If you fork the project you will be able to modify the code to use the Stable Diffusion technology of your choice (local, open-source, proprietary, your custom HF Space etc).
159
+
160
+ It would even be something else, such as Dall-E.
components.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "default",
4
+ "rsc": true,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "tailwind.config.js",
8
+ "css": "app/globals.css",
9
+ "baseColor": "stone",
10
+ "cssVariables": false
11
+ },
12
+ "aliases": {
13
+ "components": "@/components",
14
+ "utils": "@/lib/utils"
15
+ }
16
+ }
next.config.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ output: 'standalone',
4
+
5
+ experimental: {
6
+ serverActions: true,
7
+ serverActionsBodySizeLimit: '8mb',
8
+ },
9
+ }
10
+
11
+ module.exports = nextConfig
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@jbilcke/comic-factory",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "next lint"
10
+ },
11
+ "dependencies": {
12
+ "@huggingface/inference": "^2.6.1",
13
+ "@radix-ui/react-accordion": "^1.1.2",
14
+ "@radix-ui/react-avatar": "^1.0.3",
15
+ "@radix-ui/react-checkbox": "^1.0.4",
16
+ "@radix-ui/react-collapsible": "^1.0.3",
17
+ "@radix-ui/react-dialog": "^1.0.4",
18
+ "@radix-ui/react-dropdown-menu": "^2.0.5",
19
+ "@radix-ui/react-icons": "^1.3.0",
20
+ "@radix-ui/react-label": "^2.0.2",
21
+ "@radix-ui/react-menubar": "^1.0.3",
22
+ "@radix-ui/react-popover": "^1.0.6",
23
+ "@radix-ui/react-select": "^1.2.2",
24
+ "@radix-ui/react-separator": "^1.0.3",
25
+ "@radix-ui/react-slider": "^1.1.2",
26
+ "@radix-ui/react-slot": "^1.0.2",
27
+ "@radix-ui/react-switch": "^1.0.3",
28
+ "@radix-ui/react-toast": "^1.1.4",
29
+ "@radix-ui/react-tooltip": "^1.0.6",
30
+ "@react-pdf/renderer": "^3.1.12",
31
+ "@types/node": "20.4.2",
32
+ "@types/react": "18.2.15",
33
+ "@types/react-dom": "18.2.7",
34
+ "@types/uuid": "^9.0.2",
35
+ "autoprefixer": "10.4.14",
36
+ "class-variance-authority": "^0.6.1",
37
+ "clsx": "^2.0.0",
38
+ "cmdk": "^0.2.0",
39
+ "cookies-next": "^2.1.2",
40
+ "date-fns": "^2.30.0",
41
+ "encoding": "^0.1.13",
42
+ "eslint": "8.45.0",
43
+ "eslint-config-next": "13.4.10",
44
+ "html2canvas": "^1.4.1",
45
+ "konva": "^9.2.2",
46
+ "lucide-react": "^0.260.0",
47
+ "next": "13.4.10",
48
+ "openai": "^4.10.0",
49
+ "pick": "^0.0.1",
50
+ "postcss": "8.4.26",
51
+ "react": "18.2.0",
52
+ "react-circular-progressbar": "^2.1.0",
53
+ "react-dom": "18.2.0",
54
+ "react-icons": "^4.11.0",
55
+ "react-konva": "^18.2.10",
56
+ "react-virtualized-auto-sizer": "^1.0.20",
57
+ "replicate": "^0.17.0",
58
+ "sbd": "^1.0.19",
59
+ "sharp": "^0.32.5",
60
+ "styled-components": "^6.0.7",
61
+ "tailwind-merge": "^1.13.2",
62
+ "tailwindcss": "3.3.3",
63
+ "tailwindcss-animate": "^1.0.6",
64
+ "tesseract.js": "^4.1.2",
65
+ "ts-node": "^10.9.1",
66
+ "typescript": "5.1.6",
67
+ "usehooks-ts": "^2.9.1",
68
+ "uuid": "^9.0.0",
69
+ "zustand": "^4.4.1"
70
+ },
71
+ "devDependencies": {
72
+ "@types/qs": "^6.9.7",
73
+ "@types/react-virtualized": "^9.21.22",
74
+ "@types/sbd": "^1.0.3"
75
+ }
76
+ }
postcss.config.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
public/.DS_Store ADDED
Binary file (6.15 kB). View file
 
public/bubble.jpg ADDED
public/favicon.ico ADDED
public/favicon/Icon/r ADDED
File without changes
public/favicon/favicon-114-precomposed.png ADDED
public/favicon/favicon-120-precomposed.png ADDED
public/favicon/favicon-144-precomposed.png ADDED
public/favicon/favicon-152-precomposed.png ADDED
public/favicon/favicon-180-precomposed.png ADDED
public/favicon/favicon-192.png ADDED
public/favicon/favicon-32.png ADDED
public/favicon/favicon-36.png ADDED
public/favicon/favicon-48.png ADDED
public/favicon/favicon-57.png ADDED
public/favicon/favicon-60.png ADDED
public/favicon/favicon-72-precomposed.png ADDED
public/favicon/favicon-72.png ADDED
public/favicon/favicon-76.png ADDED
public/favicon/favicon-96.png ADDED
public/favicon/favicon.ico ADDED
public/favicon/index.html ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>
4
+ Favicons
5
+ </title>
6
+ <meta charset="utf-8" />
7
+
8
+ <!-- For old IEs -->
9
+ <link rel="shortcut icon" href="favicon.ico" />
10
+
11
+ <!-- For new browsers multisize ico -->
12
+ <link rel="icon" type="image/x-icon" sizes="16x16 32x32" href="favicon.ico">
13
+
14
+ <!-- Chrome for Android -->
15
+ <link rel="icon" sizes="192x192" href="favicon-192.png">
16
+
17
+ <!-- For iPhone 6+ downscaled for other devices -->
18
+ <link rel="apple-touch-icon" sizes="180x180" href="favicon-180-precomposed.png">
19
+
20
+ <!-- For IE10 Metro -->
21
+ <meta name="msapplication-TileColor" content="#FFFFFF">
22
+ <meta name="msapplication-TileImage" content="favicon-114-precomposed.png">
23
+
24
+ <style>
25
+
26
+ body {
27
+ background-color: #f5f5f5;
28
+ border: 0px;
29
+ margin: 0px;
30
+ padding: 0px;
31
+ font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
32
+ color: black;
33
+ }
34
+
35
+ pre {
36
+ margin: 0px;
37
+ color: black;
38
+ padding: 0px 5%;
39
+ }
40
+
41
+ code {
42
+
43
+ }
44
+
45
+ .container {
46
+ background-color: white;
47
+ max-width: 800px;
48
+ width: 100%;
49
+ margin: 0 auto;
50
+ padding: 1% 0;
51
+ height: 100%;
52
+ }
53
+
54
+ .comment {
55
+ color: gray;
56
+ padding: 0px;
57
+ margin: 0px;
58
+ }
59
+
60
+ hr {
61
+ width: 80%;
62
+ padding: 0 5%;
63
+ border-color: #f5f5f5;
64
+ background-color: #D1D1D1;
65
+ }
66
+
67
+ p {
68
+ padding: 1% 5%;
69
+ }
70
+
71
+ </style>
72
+
73
+ </head>
74
+ <body class="">
75
+
76
+ <div class="container">
77
+ <p>
78
+ To use the favicons insert into your head section some of these tags accordly to your needs.
79
+ </p>
80
+ <hr>
81
+ <pre>
82
+ <code>
83
+ <span class="comment">&lt;!-- For old IEs --&gt;</span>
84
+ &lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot; /&gt;
85
+
86
+ <span class="comment">&lt;!-- For new browsers - multisize ico --&gt;</span>
87
+ &lt;link rel=&quot;icon&quot; type=&quot;image/x-icon&quot; sizes=&quot;16x16 32x32&quot; href=&quot;favicon.ico&quot;&gt;
88
+
89
+ <span class="comment">&lt;!-- For iPad with high-resolution Retina display running iOS &ge; 7: --&gt;</span>
90
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;152x152&quot; href=&quot;favicon-152-precomposed.png&quot;&gt;
91
+
92
+ <span class="comment">&lt;!-- For iPad with high-resolution Retina display running iOS &le; 6: --&gt;</span>
93
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;144x144&quot; href=&quot;favicon-144-precomposed.png&quot;&gt;
94
+
95
+ <span class="comment">&lt;!-- For iPhone with high-resolution Retina display running iOS &ge; 7: --&gt;</span>
96
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;120x120&quot; href=&quot;favicon-120-precomposed.png&quot;&gt;
97
+
98
+ <span class="comment">&lt;!-- For iPhone with high-resolution Retina display running iOS &le; 6: --&gt;</span>
99
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;favicon-114-precomposed.png&quot;&gt;
100
+
101
+ <span class="comment">&lt;!-- For iPhone 6+ --&gt;</span>
102
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180x180&quot; href=&quot;favicon-180-precomposed.png&quot;&gt;
103
+
104
+ <span class="comment">&lt;!-- For first- and second-generation iPad: --&gt;</span>
105
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;favicon-72-precomposed.png&quot;&gt;
106
+
107
+ <span class="comment">&lt;!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: --&gt;</span>
108
+ &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;57x57&quot; href=&quot;favicon-57.png&quot;&gt;
109
+
110
+ <span class="comment">&lt;!-- For Old Chrome --&gt;</span>
111
+ &lt;link rel=&quot;icon&quot; sizes=&quot;32x32&quot; href=&quot;favicon-32.png&quot; &gt;
112
+
113
+ <span class="comment">&lt;!-- For IE10 Metro --&gt;</span>
114
+ &lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#FFFFFF&quot;&gt;
115
+ &lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;favicon-144.png&quot;&gt;
116
+ &lt;meta name=&quot;theme-color&quot; content=&quot;#ffffff&quot;&gt;
117
+
118
+ <span class="comment">&lt;!-- Chrome for Android --&gt;</span>
119
+ &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
120
+ &lt;link rel=&quot;icon&quot; sizes=&quot;192x192&quot; href=&quot;favicon-192.png&quot;&gt;
121
+
122
+ </code>
123
+ </pre>
124
+
125
+ <hr>
126
+
127
+ <p>
128
+ For more informations about favicons consult <a href="https://github.com/audreyr/favicon-cheat-sheet">The Favicon Cheat Sheet</a> by Audrey Roy.
129
+ </p>
130
+
131
+ </div>
132
+
133
+ </body>
public/favicon/manifest.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "pollo",
3
+ "icons": [
4
+ {
5
+ "src": "\/favicon-36.png",
6
+ "sizes": "36x36",
7
+ "type": "image\/png",
8
+ "density": 0.75
9
+ },
10
+ {
11
+ "src": "\/favicon-48.png",
12
+ "sizes": "48x48",
13
+ "type": "image\/png",
14
+ "density": 1
15
+ },
16
+ {
17
+ "src": "\/favicon-72.png",
18
+ "sizes": "72x72",
19
+ "type": "image\/png",
20
+ "density": 1.5
21
+ },
22
+ {
23
+ "src": "\/favicon-96.png",
24
+ "sizes": "96x96",
25
+ "type": "image\/png",
26
+ "density": 2
27
+ },
28
+ {
29
+ "src": "\/favicon-144.png",
30
+ "sizes": "144x144",
31
+ "type": "image\/png",
32
+ "density": 3
33
+ },
34
+ {
35
+ "src": "\/favicon-192.png",
36
+ "sizes": "192x192",
37
+ "type": "image\/png",
38
+ "density": 4
39
+ }
40
+ ]
41
+ }
public/icon.png ADDED
public/layouts/layout0.jpg ADDED
public/layouts/layout0_hd.jpg ADDED
public/layouts/layout1.jpg ADDED
public/layouts/layout1_hd.jpg ADDED
public/layouts/layout2.jpg ADDED
public/layouts/layout2_hd.jpg ADDED
public/layouts/layout3 hd.jpg ADDED
public/layouts/layout3.jpg ADDED
public/layouts/layout4 hd.jpg ADDED
public/layouts/layout4.jpg ADDED
public/mask.png ADDED
public/next.svg ADDED
public/vercel.svg ADDED
src/app/engine/caption.ts ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use server"
2
+
3
+ import { ImageAnalysisRequest, ImageAnalysisResponse } from "@/types"
4
+
5
+ const apiUrl = `${process.env.RENDERING_VIDEOCHAIN_API_URL || ""}`
6
+
7
+ export async function see({
8
+ prompt,
9
+ imageBase64
10
+ }: {
11
+ prompt: string
12
+ imageBase64: string
13
+ }): Promise<string> {
14
+ if (!prompt) {
15
+ console.error(`cannot call the API without an image, aborting..`)
16
+ throw new Error(`cannot call the API without an image, aborting..`)
17
+ }
18
+
19
+ try {
20
+ const request = {
21
+ prompt,
22
+ image: imageBase64
23
+
24
+ } as ImageAnalysisRequest
25
+
26
+ console.log(`calling ${apiUrl}/analyze called with: `, {
27
+ prompt: request.prompt,
28
+ image: request.image.slice(0, 20)
29
+ })
30
+
31
+ const res = await fetch(`${apiUrl}/analyze`, {
32
+ method: "POST",
33
+ headers: {
34
+ Accept: "application/json",
35
+ "Content-Type": "application/json",
36
+ // Authorization: `Bearer ${videochainApi}`,
37
+ },
38
+ body: JSON.stringify(request),
39
+ cache: 'no-store',
40
+ // we can also use this (see https://vercel.com/blog/vercel-cache-api-nextjs-cache)
41
+ // next: { revalidate: 1 }
42
+ })
43
+
44
+ if (res.status !== 200) {
45
+ throw new Error('Failed to fetch data')
46
+ }
47
+
48
+ const response = (await res.json()) as ImageAnalysisResponse
49
+ return response.result
50
+ } catch (err) {
51
+ console.error(err)
52
+ return ""
53
+ }
54
+ }
src/app/engine/censorship.ts ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // I don't want to be banned by Replicate because bad actors are asking
3
+ // for some naked anime stuff or whatever
4
+ // I also want to avoid a PR scandal due to some bad user generated content
5
+
6
+ import { computeSecretFingerprint } from "@/lib/computeSecretFingerprint"
7
+
8
+ // those keywords have been generated by looking at the logs of the panorama and the AI Comic Factory
9
+ // those are real requests some users tried to attempt.. :|
10
+
11
+ const chickens = [
12
+ "fcb4dacbd99b21368c50f29c1d47071c87cf2225ab9192282c785460391cd365",
13
+ "68840b60ac27eacaa7afe17e898d3c4a2dc71acff8c74d6782c1bcaafd14963d",
14
+ "67f745224fd6e1a7a3a244514d5807fcc994cbb62ca4ec8fa44cd14244a515ae",
15
+ "681fea565117808c6dbe002520d2cfeeb3e5c67e68630afb4a453449a9da587b",
16
+ "2f3d913b3db9e15a930aac43eb2d6fe8817db8e4bcf37794bf0227b06b718d1b",
17
+ "922a700b807e4994df82eba2b48a6ac131fe8d8d1035d06b3592d622fb232161",
18
+ "cb69ee6774eafcc720adb1f689d28acbb9f47998cbea0299ec66a58dedf91c37"
19
+ ]
20
+
21
+ const ducks = [
22
+ "1c52cb20c0cbc76349fa63232b982bd394cf0850ebc17240dcf33c19fb15a26d",
23
+ "e1d4de9b8d464d7da07c276b63a42c1c9922224f0a6cab6b0826427ce4a7461a",
24
+ "0be3174bfb1a48a65875c2f035b1ae14fbc8f232f55785018de0cfe2132fa952",
25
+ "0f174769641b2e5d2c79b5a83e8ef91e004f6f3e62531cd70cfdff02159268cb",
26
+ "e9fb8ae8ff720acd91025229478a21e43e8e976e30119a76c293201adf572736",
27
+ "f65a0dc0e07b5d084ff24c69dcdb953f7b57101d2ebb716d4dfb5963076ef807",
28
+ "2bf38af1646489c2c086f811d082054cd29e23fa7bb5c525396bec01b3ab688e"
29
+ ]
30
+
31
+ const cats = [
32
+ "fcffc3e997d952007d1b902a9cf40b750ba4a410ac65bfd95475996bf51359e4",
33
+ "3172a5fa159754d703489dfba5af520b8ace107cdf170f4c4cb38a6797aa163f",
34
+ "500012dbff4498a9c4513369d6b9b373fab9330ffd2cb1e622294043cc21b610",
35
+ "84e3a8d34ee7d0c8e7a2926dd1acad46a0b66b9d27725b3a7e5053550f490301"
36
+ ]
37
+
38
+ const roasted = [
39
+ "a2bfbce0046c9a52a0eabf98f73e0f8e09959970431fc892ebdb4e1c97031b50",
40
+ "6eca1adf06851f99e9cdfbb496c27d46ff81106903d11f3346a146e96082b016",
41
+ "49a124c9ed6fbbad4105b3657dc25de369bcafb9d6787f610c08f584cd607d0f",
42
+ "c3afb59420c812cbc7c8f57ad3e8d79407f10106a99f829aa65316c99d0b29c4",
43
+ "2b808858836a5c205080f5b93201ef92e098cff931d8de6d9f20dc722997d077",
44
+ "07bef89d1a7d63c9c5ed64ba0f73d6cff689811847c2e20c8b3fbfb060e1d64e",
45
+ "baeb994922d5473f534aa54322d83effe74c6c4dac807e6b523a677d7acdc17b",
46
+ "ea4735a879edd5cc94ca7db26edd5a970df69a41f0009d3444486647e44175af",
47
+ "f2412249030454cd13ac6f7965871d924c16daacda0123de81892adb19ce49ac",
48
+ "9958c56e12bab8549cf752bcd8bec4ac36cf79c404b1faf5611f057bb71bc0e1",
49
+ "76cdade0b3d4caf0888f60318a5cbca00f830a3b0bf37735fc64fdaeb67c34d3",
50
+ "1bf53c97869e1ea89bda19da64a9173d48fe4ec823e949e2c898f8abb3fbf457",
51
+ "1bf53c97869e1ea89bda19da64a9173d48fe4ec823e949e2c898f8abb3fbf457",
52
+ "3d7f973fab8f4a19c0a3e59efe970ed7bd55a1cb795752d9cbe3c19e8a7d81ec"
53
+ ]
54
+
55
+ const banned = [
56
+ "8a05d4869d9d6ce388c6cd2db13ca12b88097b90f9be027d5ffaaa467c7a6e5e",
57
+ "0c475212a608138244c5fc150b1563e5ef79c516234fd78dcd5993f726c359a0",
58
+ "df17388805f99f2ff3e5ae97a0f55e5c927eb47f17ca65822bf8c88f02bac3dd",
59
+ "86c3355d1bd581cdf7306729d8dd0ee9b7a317b9cfd6d7a6f5fad9c0dafe2167",
60
+ "23a2484cd420c9ffbfcc2c0075a9b330664450ced1fc64ab6a65e278086b8c6e",
61
+ "fb4cabe709b62eea1b4cc0030c76f5e4a43ee677ce19124e8e7bafa86c78ab66",
62
+ "d99c26daee85f7dc81c46c061a5874cff7179ed72d884d2316d664d36ffe7ab5",
63
+ "b93c38af5aa221d76c60ee3eb762efee0cdb0daf29ceb235b7dda6d46c06490d",
64
+ "8cf6c8765dc757319461dd9a785e77c201b8e5a604d36b817cd987c6a5e62500",
65
+ "f4a1cb290745717f86c3cee30fc324c0d80a9945fcbc7bbeb010579f58792f1e",
66
+ "7c87c47c42fc983119551342be9ddd5b32e530c0504ccdbbaa1e12b1d9f1bbcb",
67
+ "d04fad4f21d030da7a1301afbf480ef6246eb7bbf0f26e31865b2e015a25f747",
68
+ "d685ff22fb9da01ee949db212770729603989850864ef7a7085e1f086cfa7deb",
69
+ "533b90588d9ccf7967da54691f575e9fd4926c6e0b5fd94a47b932bcea270bee",
70
+ "9c2d61f28f5bb7f3f1dc9122be64cda8a428b46ce68b70120da4c41dba96ba4c",
71
+ "5d4b1a3eebe64dfa631d0e3b084bd96ee9364c3669269f838ca17a4900276264",
72
+ "d56f56413b9679fc0820a2c0237224ded8554c61fab8959c174123c8b68ba029",
73
+ "323a9ab60739726070d615ff3a05d7ff6bb6e3c4dd9ff16ce24f253ecd7b8851",
74
+ "975c6739de7d4999db15972f707f5f4e95649275f1c0c48e895b8c537e8638ec",
75
+ "67ee26eb9e1c1c7124797321b02bca90a19c18171782917cd4a487b722484dce",
76
+ "6df5aa7b72a4e6e3fb726489ff1437daa5752047507f4da912680b1d6647c7d6",
77
+ "b0864805364359e8c5810c233b1bf2c74dedce9055ae5f7680ba05b4e39db8e2",
78
+ "a8f841472ecffdd6266151148320c8e36847a24ead9d3338e0313b075c16649d",
79
+ "f9b127cd90e85b0ff68dd220361671663f0154b2b827f1f7ea797b020ca0018c",
80
+ "d5c20e9a1ecf01c82da24c514d867498b3e5f522adc1523ce29404a6563641d5",
81
+ "241022b49d7c0aba24a61eea1137a804f36e4bcb47af42950275baac9b4e7aac",
82
+ "fc99a70e17b6c86ef1b537654b0f50353567a7b59912c3ba955f3fca4d1ea696",
83
+ "255306e968009003d295cb2a7256f27bfcdb5d1743bf4d9f2aa4b8adf1a7734d",
84
+ "048c7b709763dd9c43794d241c369f0abcb079d546ddcbbba9968a1ed1da7ed7",
85
+ "520cbfeef3e4c405d79478eedccb97a4d476be585626dd2b1c53292797491bc7",
86
+ "f9f28a7ae7e8b1719b350a04dc087a4b8e33478d109ceeef6ba892b32d1105c9",
87
+ "d177f1bfe603647ef4c1c0e6f1a7172081fb9bbc2ea859705949f2c5aa5d4f22",
88
+ "302feef2c09247fbd23789581f7f5e2219f88ae0a937880954938573c2a52a84",
89
+ "99edd6f57b864873835f16f19c805dd94bed9da8967b84e3a62782f106d9ebcc",
90
+ "e75e5f01dcd8351c9553e89558085bd68e6feb295dee5d8da0c9b43ee303ce36",
91
+ "135e52a026aea9d2e12de358a85e05cf21121a18269269b7c62678c3bc846f5b",
92
+ "28e5b2d3eb5f1ef4cc7b570878b03acf303a6ca4ca95893591e0fb943b0beab0",
93
+ "a26b26340f8d0363633490556d20bcc250726d10e1431eb8c22d6b1ff3f2b14a",
94
+ "27e4ddde96ec6a1dbe1cf12d79448b3e72f144944c15b299629542d1b65fbabf",
95
+ "efd9c0a391ee93251046a58326d1b21b33fe21d71a3fb1855b9048ade53df77c",
96
+ "6d505fcce416c26a606878aab4d249a034ba2a9846cb1f883e0f9e3fb76ba6da",
97
+ "3a37b8a1b72f9bca51233536d50f9c8d33a787434684787871e0049c82347cda",
98
+ "16f9b451184a7c3148344c7d0315f5312ca20553d2271912ecaad91810d977e6",
99
+ "7406537eb74d1885bd05e191228de313b13702a64d90ae1736c6377b25ab579a",
100
+ "7e4d1395ae18980015cab16c85ffa20b4cb90a2db594126e893d0f7ac6eecaa8",
101
+ "ba813ee6c25698f0f68a07121d38bb47c9aa404c1ab0a6e767595cb75e1747b8",
102
+ "6586c93f3ece83e01ecc1eb84a7711e7975826a388d478a009468ea0ed9dc03e",
103
+ "8960174c74d86e03ae88fb6774580170e49952f2286d960be08c556bbd0dda95",
104
+ "4d611454369aa1a4e2b7eed1734fac5d480f08fb86b87a162967e416370f2a8e",
105
+ "59d48440f85eabf565fe8d3bc6b973ba64c70df3b36b0511e0e67ceca91762b3",
106
+ "cd926926e2af74e43d1a6a420a7e1933b78662320477a3c018b2711d8765e339",
107
+ "80e90057df6a59823f51aafac36ed5bc4e5ac26d675d9c1467501590c82f12d4",
108
+ "a9cf28b869b70e258adde5639a048f866ec86f8f3f3d53bfc960b86aa6da9239",
109
+ "cc2adbf8ac0cddeefa304d7b20f14a7e047a4b2299cc5e8f898f5c59660bd964",
110
+ "92a150a46146e9d3f84899cf15e12514af684e7ee18d7add782ddd4f4a15ef18",
111
+ "d9b2e84ef6dc0ce449357d52c9095f69b173a1b848ea2921199d33b0ec10024a",
112
+ "a9329a7e4d367a0135c1ca86c6ce5ecabcc26529235229d71b6bf991f7689e21",
113
+ "8f160c6fd8ccc3fb2a371a4b52748f0bd030766627c4322e2911fe82f6b10497",
114
+ "620e96eae4f3e88cbe0770292b33724c5df3866d83f39df6380441f7271c80e2",
115
+ "cafa3481fa3c45ed1e55cd0129c12b477eeab5aa3d6da20cae6d6292f19b0e6d",
116
+ "be07994e9a83aa3689e79b6e96123676ccc4fa29f523c28c750c6d60505531ee",
117
+ "f6498069768cd3aa79b2b0c91879694f05a259c8ee4a6bb343f0435f74eb1b53",
118
+ "c9b6b26cb3a694eb78fcac0a14ad18d46d50907186a9add41022d31d191b2b65"
119
+ ]
120
+
121
+ const young = [
122
+ "ffdf66787b4a33b78b18c18822e334cfe2c8406caf442851deef451bd43140a1",
123
+ "858f22219afc4b32a7ba9a27a213d7f495e77c3cceed8147eae5282bf3e23d39",
124
+ "8c3c46df84ace3d58d4ce0fbc513017986b33c6002ae369d9f7dd1f892a898cb",
125
+ "66caa22b9483fdf026ce67de61067d81535a7c9b3169cbc5c2a455ac8dcc7bec",
126
+ "76893047b1eff9fadc7be07b13adb5aaed9c73bcdeea46ee07098605e2c7ff76",
127
+ "526cb848754e2baaa17376a5693d90ba3f69f71fd2a866f22876ac8a075849a7",
128
+ "f59c38e31d0f64dc1bfcdf34451723bc1a65570e209e5496c8d1d7f6d3d649db",
129
+ "e013a67e275c62c1402ccbbb11ad14afb8b8a82318a44c07d67599ed5ac874de",
130
+ "3bef34219fb07f867ecbff4d6748f598d6cc0761e17dd0d431ee1f4ec3281374",
131
+ "8211bf5f613fac06cd5d074d34c16dfacc9367c8afaa6ad3aff99d145e5221be"
132
+ ]
133
+
134
+ const getFingerprint = (word: string) => {
135
+ return computeSecretFingerprint(
136
+ word.toLocaleLowerCase().replaceAll(/[^a-zA-Z0-9]/gi, "")
137
+ )
138
+ }
139
+
140
+ const encode = (list: string[]) => {
141
+ console.log(JSON.stringify(
142
+ list.sort((a, b) => (b.length - a.length))
143
+ .map(item => getFingerprint(item)), null, 2))
144
+ }
145
+
146
+ // encode([ "badword" ])
147
+
148
+ export const filterOutBadWords = (sentence: string) => {
149
+ if (process.env.ENABLE_CENSORSHIP !== "true") { return sentence }
150
+
151
+ let requireCensorship = false
152
+
153
+ const words = sentence.replaceAll(/[^a-zA-Z0-9]/gi, " ").replaceAll(/\s+/gi, " ").trim().split(" ")
154
+
155
+ const sanitized = words.map(word => {
156
+ const fingerprint = getFingerprint(word)
157
+
158
+ let result: string = word
159
+ // some users want to play it smart and bypass our system so let's play too
160
+ if (chickens.includes(fingerprint)) {
161
+ result = "large chicken"
162
+ } else if (ducks.includes(fingerprint)) {
163
+ result = "big duck"
164
+ } else if (cats.includes(fingerprint)) {
165
+ result = "cat"
166
+ } else if (roasted.includes(fingerprint)) {
167
+ result = "roasted chicken"
168
+ } else if (young.includes(fingerprint)) {
169
+ result = "adult"
170
+ } else if (banned.includes(fingerprint)) {
171
+ result = "_BANNED_"
172
+ }
173
+
174
+ if (result !== word) {
175
+ requireCensorship = true
176
+ }
177
+ return result
178
+ }).filter(item => item !== "_BANNED_").join(" ")
179
+
180
+ // if the user didn't try to use a bad word, we leave it untouched
181
+ // he words array has been degraded by the replace operation, but it removes commas etc which isn't great
182
+ // so if the request was genuine and SFW, it's best to return the original prompt
183
+ return requireCensorship ? sanitized : sentence
184
+ }
src/app/engine/community.ts ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use server"
2
+
3
+ import { v4 as uuidv4 } from "uuid"
4
+
5
+ import { CreatePostResponse, GetAppPostsResponse, Post, PostVisibility } from "@/types"
6
+ import { filterOutBadWords } from "./censorship"
7
+
8
+ const apiUrl = `${process.env.COMMUNITY_API_URL || ""}`
9
+ const apiToken = `${process.env.COMMUNITY_API_TOKEN || ""}`
10
+ const appId = `${process.env.COMMUNITY_API_ID || ""}`
11
+
12
+ export async function postToCommunity({
13
+ prompt,
14
+ assetUrl,
15
+ }: {
16
+ prompt: string
17
+ assetUrl: string
18
+ }): Promise<Post> {
19
+
20
+ prompt = filterOutBadWords(prompt)
21
+
22
+ // if the community API is disabled,
23
+ // we don't fail, we just mock
24
+ if (!apiUrl) {
25
+ const mockPost: Post = {
26
+ postId: uuidv4(),
27
+ appId: "mock",
28
+ prompt,
29
+ previewUrl: assetUrl,
30
+ assetUrl,
31
+ createdAt: new Date().toISOString(),
32
+ visibility: "normal",
33
+ upvotes: 0,
34
+ downvotes: 0
35
+ }
36
+ return mockPost
37
+ }
38
+
39
+ if (!prompt) {
40
+ console.error(`cannot call the community API without a prompt, aborting..`)
41
+ throw new Error(`cannot call the community API without a prompt, aborting..`)
42
+ }
43
+ if (!assetUrl) {
44
+ console.error(`cannot call the community API without an assetUrl, aborting..`)
45
+ throw new Error(`cannot call the community API without an assetUrl, aborting..`)
46
+ }
47
+
48
+ try {
49
+ console.log(`calling POST ${apiUrl}/posts/${appId} with prompt: ${prompt}`)
50
+
51
+ const postId = uuidv4()
52
+
53
+ const post: Partial<Post> = { postId, appId, prompt, assetUrl }
54
+
55
+ console.table(post)
56
+
57
+ const res = await fetch(`${apiUrl}/posts/${appId}`, {
58
+ method: "POST",
59
+ headers: {
60
+ Accept: "application/json",
61
+ "Content-Type": "application/json",
62
+ Authorization: `Bearer ${apiToken}`,
63
+ },
64
+ body: JSON.stringify(post),
65
+ cache: 'no-store',
66
+ // we can also use this (see https://vercel.com/blog/vercel-cache-api-nextjs-cache)
67
+ // next: { revalidate: 1 }
68
+ })
69
+
70
+ // console.log("res:", res)
71
+ // The return value is *not* serialized
72
+ // You can return Date, Map, Set, etc.
73
+
74
+ // Recommendation: handle errors
75
+ if (res.status !== 200) {
76
+ // This will activate the closest `error.js` Error Boundary
77
+ throw new Error('Failed to fetch data')
78
+ }
79
+
80
+ const response = (await res.json()) as CreatePostResponse
81
+ // console.log("response:", response)
82
+ return response.post
83
+ } catch (err) {
84
+ const error = `failed to post to community: ${err}`
85
+ console.error(error)
86
+ throw new Error(error)
87
+ }
88
+ }
89
+
90
+ export async function getLatestPosts(visibility?: PostVisibility): Promise<Post[]> {
91
+
92
+ let posts: Post[] = []
93
+
94
+ // if the community API is disabled we don't fail,
95
+ // we just mock
96
+ if (!apiUrl) {
97
+ return posts
98
+ }
99
+
100
+ try {
101
+ // console.log(`calling GET ${apiUrl}/posts with renderId: ${renderId}`)
102
+ const res = await fetch(`${apiUrl}/posts/${appId}/${
103
+ visibility || "all"
104
+ }`, {
105
+ method: "GET",
106
+ headers: {
107
+ Accept: "application/json",
108
+ "Content-Type": "application/json",
109
+ Authorization: `Bearer ${apiToken}`,
110
+ },
111
+ cache: 'no-store',
112
+ // we can also use this (see https://vercel.com/blog/vercel-cache-api-nextjs-cache)
113
+ // next: { revalidate: 1 }
114
+ })
115
+
116
+ // console.log("res:", res)
117
+ // The return value is *not* serialized
118
+ // You can return Date, Map, Set, etc.
119
+
120
+ // Recommendation: handle errors
121
+ if (res.status !== 200) {
122
+ // This will activate the closest `error.js` Error Boundary
123
+ throw new Error('Failed to fetch data')
124
+ }
125
+
126
+ const response = (await res.json()) as GetAppPostsResponse
127
+ // console.log("response:", response)
128
+ return Array.isArray(response?.posts) ? response?.posts : []
129
+ } catch (err) {
130
+ // const error = `failed to get posts: ${err}`
131
+ // console.error(error)
132
+ // throw new Error(error)
133
+ return []
134
+ }
135
+ }
src/app/engine/forbidden.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ // the NSFW has to contain bad words, but doing so might get the code flagged
3
+ // or attract unwanted attention, so we hash them
4
+ export const forbidden = [
5
+ // TODO implement this
6
+ ]
src/app/engine/presets.ts ADDED
@@ -0,0 +1,588 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { FontName, actionman, komika, vtc } from "@/lib/fonts"
2
+ import { pick } from "@/lib/pick"
3
+ import { NextFontWithVariable } from "next/dist/compiled/@next/font"
4
+
5
+ export type ComicFamily =
6
+ | "american"
7
+ | "asian"
8
+ | "european"
9
+
10
+ export type ComicColor =
11
+ | "color"
12
+ | "grayscale"
13
+ | "monochrome"
14
+
15
+ export interface Preset {
16
+ id: string
17
+ label: string
18
+ family: ComicFamily
19
+ color: ComicColor
20
+ font: FontName
21
+ llmPrompt: string
22
+ imagePrompt: (prompt: string) => string[]
23
+ negativePrompt: (prompt: string) => string[]
24
+ }
25
+
26
+ // ATTENTION!! negative prompts are not supported by the VideoChain API yet
27
+
28
+ export const presets: Record<string, Preset> = {
29
+ random: {
30
+ id: "random",
31
+ label: "Random style",
32
+ family: "european",
33
+ color: "color",
34
+ font: "actionman",
35
+ llmPrompt: "",
36
+ imagePrompt: (prompt: string) => [],
37
+ negativePrompt: () => [],
38
+ },
39
+ japanese_manga: {
40
+ id: "japanese_manga",
41
+ label: "Japanese",
42
+ family: "asian",
43
+ color: "grayscale",
44
+ font: "actionman",
45
+ llmPrompt: "japanese manga",
46
+ imagePrompt: (prompt: string) => [
47
+ `grayscale`,
48
+ `intricate details`,
49
+ `japanese manga about ${prompt}`,
50
+ "single panel",
51
+ "manga",
52
+ "japanese",
53
+ "intricate",
54
+ "detailed",
55
+ // "drawing"
56
+ ],
57
+ negativePrompt: () => [
58
+ "franco-belgian comic",
59
+ "color album",
60
+ "color",
61
+ "american comic",
62
+ "photo",
63
+ "painting",
64
+ "3D render"
65
+ ],
66
+ },
67
+ nihonga: {
68
+ id: "nihonga",
69
+ label: "Nihonga",
70
+ family: "asian",
71
+ color: "color",
72
+ font: "actionman",
73
+ llmPrompt: "japanese manga",
74
+ imagePrompt: (prompt: string) => [
75
+ `japanese nihonga painting about ${prompt}`,
76
+ "Nihonga",
77
+ "ancient japanese painting",
78
+ "intricate",
79
+ "detailed",
80
+ // "drawing"
81
+ ],
82
+ negativePrompt: () => [
83
+ "franco-belgian comic",
84
+ "color album",
85
+ "color",
86
+ "manga",
87
+ "comic",
88
+ "american comic",
89
+ "photo",
90
+ "painting",
91
+ "3D render"
92
+ ],
93
+ },
94
+ franco_belgian: {
95
+ id: "franco_belgian",
96
+ label: "Franco-Belgian",
97
+ family: "european",
98
+ color: "color",
99
+ font: "actionman",
100
+ llmPrompt: "Franco-Belgian comic (a \"bande dessinée\"), in the style of Franquin, Moebius etc",
101
+ imagePrompt: (prompt: string) => [
102
+ "bande dessinée",
103
+ "franco-belgian comic",
104
+ `franco-belgian color comic about ${prompt}`,
105
+ "comic album",
106
+ // "color drawing"
107
+ ],
108
+ negativePrompt: () => [
109
+ "manga",
110
+ "anime",
111
+ "american comic",
112
+ "grayscale",
113
+ "monochrome",
114
+ "photo",
115
+ "painting",
116
+ "3D render"
117
+ ],
118
+ },
119
+ american_comic_90: {
120
+ id: "american_comic_90",
121
+ label: "American (modern)",
122
+ family: "american",
123
+ color: "color",
124
+ font: "actionman",
125
+ llmPrompt: "american comic",
126
+ imagePrompt: (prompt: string) => [
127
+ "digital color comicbook style",
128
+ `modern american comic about ${prompt}`,
129
+ //"single panel",
130
+ // "2010s",
131
+ // "digital print",
132
+ // "color comicbook",
133
+ // "color drawing"
134
+ ],
135
+ negativePrompt: () => [
136
+ "manga",
137
+ "anime",
138
+ "american comic",
139
+ "action",
140
+ "grayscale",
141
+ "monochrome",
142
+ "photo",
143
+ "painting",
144
+ "3D render"
145
+ ],
146
+ },
147
+
148
+ /*
149
+ american_comic_40: {
150
+ label: "American (1940)",
151
+ family: "american",
152
+ color: "color",
153
+ font: "actionman",
154
+ llmPrompt: "american comic",
155
+ imagePrompt: (prompt: string) => [
156
+ `american comic about ${prompt}`,
157
+ "single panel",
158
+ "american comic",
159
+ "comicbook style",
160
+ "1940",
161
+ "40s",
162
+ "color comicbook",
163
+ "color drawing"
164
+ ],
165
+ negativePrompt: () => [
166
+ "manga",
167
+ "anime",
168
+ "american comic",
169
+ "action",
170
+ "grayscale",
171
+ "monochrome",
172
+ "photo",
173
+ "painting",
174
+ "3D render"
175
+ ],
176
+ },
177
+ */
178
+ american_comic_50: {
179
+ id: "american_comic_50",
180
+ label: "American (1950)",
181
+ family: "american",
182
+ color: "color",
183
+ font: "actionman",
184
+ llmPrompt: "american comic",
185
+ imagePrompt: (prompt: string) => [
186
+ "1950",
187
+ "50s",
188
+ `vintage american color comic about ${prompt}`,
189
+ // "single panel",
190
+ // "comicbook style",
191
+ // "color comicbook",
192
+ // "color drawing"
193
+ ],
194
+ negativePrompt: () => [
195
+ "manga",
196
+ "anime",
197
+ "american comic",
198
+ "action",
199
+ "grayscale",
200
+ "monochrome",
201
+ "photo",
202
+ "painting",
203
+ "3D render"
204
+ ],
205
+ },
206
+ /*
207
+ american_comic_60: {
208
+ label: "American (1960)",
209
+ family: "american",
210
+ color: "color",
211
+ font: "actionman",
212
+ llmPrompt: "american comic",
213
+ imagePrompt: (prompt: string) => [
214
+ `american comic about ${prompt}`,
215
+ "single panel",
216
+ "american comic",
217
+ "comicbook style",
218
+ "1960",
219
+ "60s",
220
+ "color comicbook",
221
+ "color drawing"
222
+ ],
223
+ negativePrompt: () => [
224
+ "manga",
225
+ "anime",
226
+ "american comic",
227
+ "action",
228
+ "grayscale",
229
+ "monochrome",
230
+ "photo",
231
+ "painting",
232
+ "3D render"
233
+ ],
234
+ },
235
+ */
236
+
237
+
238
+ flying_saucer: {
239
+ id: "flying_saucer",
240
+ label: "Flying saucer",
241
+ family: "european",
242
+ color: "color",
243
+ font: "actionman",
244
+ llmPrompt: "new pulp science fiction",
245
+ imagePrompt: (prompt: string) => [
246
+ `vintage color pulp comic panel`,
247
+ "40s",
248
+ "1940",
249
+ "vintage science fiction",
250
+ `${prompt}`,
251
+ // "single panel",
252
+ // "comic album"
253
+ ],
254
+ negativePrompt: () => [
255
+ "manga",
256
+ "anime",
257
+ "american comic",
258
+ "grayscale",
259
+ "monochrome",
260
+ "photo",
261
+ "painting",
262
+ "3D render"
263
+ ],
264
+ },
265
+
266
+ humanoid: {
267
+ id: "humanoid",
268
+ label: "Humanoid",
269
+ family: "european",
270
+ color: "color",
271
+ font: "actionman",
272
+ llmPrompt: "comic books by Moebius",
273
+ imagePrompt: (prompt: string) => [
274
+ `color comic panel`,
275
+ "style of Moebius",
276
+ `${prompt}`,
277
+ "by Moebius",
278
+ "french comic panel",
279
+ "franco-belgian style",
280
+ "bande dessinée",
281
+ "single panel",
282
+ "intricate"
283
+ // "comic album"
284
+ ],
285
+ negativePrompt: () => [
286
+ "manga",
287
+ "anime",
288
+ "american comic",
289
+ "grayscale",
290
+ "monochrome",
291
+ "photo",
292
+ "painting",
293
+ "3D render"
294
+ ],
295
+ },
296
+ haddock: {
297
+ id: "haddock",
298
+ label: "Haddock",
299
+ family: "european",
300
+ color: "color",
301
+ font: "actionman",
302
+ llmPrompt: "writing Tintin comic books",
303
+ imagePrompt: (prompt: string) => [
304
+ `color comic panel`,
305
+ "style of Hergé",
306
+ "tintin style",
307
+ `${prompt}`,
308
+ "by Hergé",
309
+ "french comic panel",
310
+ "franco-belgian style",
311
+ // "color panel",
312
+ // "bande dessinée",
313
+ // "single panel",
314
+ // "comic album"
315
+ ],
316
+ negativePrompt: () => [
317
+ "manga",
318
+ "anime",
319
+ "american comic",
320
+ "grayscale",
321
+ "monochrome",
322
+ "photo",
323
+ "painting",
324
+ "3D render"
325
+ ],
326
+ },
327
+ /*
328
+ lurid: {
329
+ id: "lurid",
330
+ label: "Lurid",
331
+ family: "american",
332
+ color: "color",
333
+ font: "actionman",
334
+ llmPrompt: "1970s satirical and alternative underground comics",
335
+ imagePrompt: (prompt: string) => [
336
+ `satirical color comic`,
337
+ `underground comix`,
338
+ `1970`,
339
+ `${prompt}`,
340
+ ],
341
+ negativePrompt: () => [
342
+ "manga",
343
+ "anime",
344
+ "american comic",
345
+ "grayscale",
346
+ "monochrome",
347
+ "painting"
348
+ ],
349
+ },
350
+ */
351
+ armorican: {
352
+ id: "armorican",
353
+ label: "Armorican",
354
+ family: "european",
355
+ color: "monochrome",
356
+ font: "actionman",
357
+ llmPrompt: "french style comic books set in ancient Rome and Gaul",
358
+ imagePrompt: (prompt: string) => [
359
+ `color comic panel`,
360
+ "romans",
361
+ "gauls",
362
+ "french comic panel",
363
+ "franco-belgian style",
364
+ `about ${prompt}`,
365
+ "bande dessinée",
366
+ "single panel",
367
+ // "comical",
368
+ // "comic album",
369
+ // "color drawing"
370
+ ],
371
+ negativePrompt: () => [
372
+ "manga",
373
+ "anime",
374
+ "american comic",
375
+ "grayscale",
376
+ "monochrome",
377
+ "photo",
378
+ "painting",
379
+ "3D render"
380
+ ],
381
+ },
382
+ render: {
383
+ id: "render",
384
+ label: "3D Render",
385
+ family: "european",
386
+ color: "color",
387
+ font: "actionman",
388
+ llmPrompt: "new movie",
389
+ imagePrompt: (prompt: string) => [
390
+ `3D render`,
391
+ `Blender`,
392
+ `3D animation`,
393
+ `Unreal engine`,
394
+ `${prompt}`,
395
+ ],
396
+ negativePrompt: () => [
397
+ "manga",
398
+ "anime",
399
+ "american comic",
400
+ "grayscale",
401
+ "monochrome",
402
+ "painting"
403
+ ],
404
+ },
405
+ klimt: {
406
+ id: "klimt",
407
+ label: "Klimt",
408
+ family: "european",
409
+ color: "color",
410
+ font: "actionman",
411
+ llmPrompt: "Gustav Klimt art pieces.",
412
+ imagePrompt: (prompt: string) => [
413
+ `golden`,
414
+ `patchwork`,
415
+ `style of Gustav Klimt`,
416
+ `Gustav Klimt painting`,
417
+ `intricate details`,
418
+ `${prompt}`,
419
+ ],
420
+ negativePrompt: () => [
421
+ "manga",
422
+ "anime",
423
+ "american comic",
424
+ "grayscale",
425
+ "monochrome",
426
+ "painting"
427
+ ],
428
+ },
429
+ medieval: {
430
+ id: "medieval",
431
+ label: "Medieval",
432
+ family: "european",
433
+ color: "color",
434
+ font: "actionman",
435
+ llmPrompt: "medieval story (write in this style)",
436
+ imagePrompt: (prompt: string) => [
437
+ `medieval illuminated manuscript`,
438
+ `illuminated manuscript of`,
439
+ `medieval`,
440
+ `intricate details`,
441
+ // `medieval color engraving`,
442
+ `${prompt}`,
443
+ // `medieval`
444
+ ],
445
+ negativePrompt: () => [
446
+ "manga",
447
+ "anime",
448
+ "american comic",
449
+ "grayscale",
450
+ "monochrome",
451
+ "painting"
452
+ ],
453
+ },
454
+ /*
455
+ glass: {
456
+ id: "glass",
457
+ label: "Glass",
458
+ family: "european",
459
+ color: "color",
460
+ font: "actionman",
461
+ llmPrompt: "new movie",
462
+ imagePrompt: (prompt: string) => [
463
+ `stained glass`,
464
+ `vitrail`,
465
+ `stained glass`,
466
+ // `medieval color engraving`,
467
+ `${prompt}`,
468
+ `medieval`,
469
+ ],
470
+ negativePrompt: () => [
471
+ "manga",
472
+ "anime",
473
+ "american comic",
474
+ "grayscale",
475
+ "monochrome",
476
+ "painting"
477
+ ],
478
+ },
479
+ */
480
+ /*
481
+ voynich: {
482
+ id: "voynich",
483
+ label: "Voynich",
484
+ family: "european",
485
+ color: "color",
486
+ font: "actionman",
487
+ llmPrompt: "new movie",
488
+ imagePrompt: (prompt: string) => [
489
+ `voynich`,
490
+ `voynich page`,
491
+ // `medieval color engraving`,
492
+ `${prompt}`,
493
+ `medieval`,
494
+ ],
495
+ negativePrompt: () => [
496
+ "manga",
497
+ "anime",
498
+ "american comic",
499
+ "grayscale",
500
+ "monochrome",
501
+ "painting"
502
+ ],
503
+ },
504
+ */
505
+ egyptian: {
506
+ id: "egyptian",
507
+ label: "Egyptian",
508
+ family: "european",
509
+ color: "color",
510
+ font: "actionman",
511
+ llmPrompt: "ancient egyptian stories.",
512
+ imagePrompt: (prompt: string) => [
513
+ `ancient egyptian wall painting`,
514
+ `ancient egypt`,
515
+ // `medieval color engraving`,
516
+ `${prompt}`,
517
+ ],
518
+ negativePrompt: () => [
519
+ "manga",
520
+ "anime",
521
+ "american comic",
522
+ "grayscale",
523
+ "monochrome",
524
+ "painting"
525
+ ],
526
+ },
527
+ /*
528
+ psx: {
529
+ label: "PSX",
530
+ family: "european",
531
+ color: "color",
532
+ font: "actionman",
533
+ llmPrompt: "new movie",
534
+ imagePrompt: (prompt: string) => [
535
+ `videogame screenshot`,
536
+ `3dfx`,
537
+ `3D dos game`,
538
+ `software rendering`,
539
+ `${prompt}`,
540
+ ],
541
+ negativePrompt: () => [
542
+ "manga",
543
+ "anime",
544
+ "american comic",
545
+ "grayscale",
546
+ "monochrome",
547
+ "painting"
548
+ ],
549
+ },
550
+ */
551
+ /*
552
+ pixel: {
553
+ label: "Pixel",
554
+ family: "european",
555
+ color: "color",
556
+ font: "actionman",
557
+ llmPrompt: "new movie",
558
+ imagePrompt: (prompt: string) => [
559
+ `pixelart`,
560
+ `isometric`,
561
+ `pixelated`,
562
+ `low res`,
563
+ `${prompt}`,
564
+ ],
565
+ negativePrompt: () => [
566
+ "manga",
567
+ "anime",
568
+ "american comic",
569
+ "grayscale",
570
+ "monochrome",
571
+ "painting"
572
+ ],
573
+ },
574
+ */
575
+ }
576
+
577
+ export type PresetName = keyof typeof presets
578
+
579
+ export const defaultPreset: PresetName = "american_comic_90"
580
+
581
+ export const nonRandomPresets = Object.keys(presets).filter(p => p !== "random")
582
+
583
+ export const getPreset = (preset?: PresetName): Preset => presets[preset || defaultPreset] || presets[defaultPreset]
584
+
585
+ export const getRandomPreset = (): Preset => {
586
+ const presetName = pick(Object.keys(presets).filter(preset => preset !== "random")) as PresetName
587
+ return getPreset(presetName)
588
+ }