Skip to content

Commit 44cadcf

Browse files
committed
feat: v2 conversation based interaction
1 parent 8f2f063 commit 44cadcf

File tree

95 files changed

+25362
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+25362
-17
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [dev, master]
6+
pull_request:
7+
branches: [dev]
8+
9+
jobs:
10+
build:
11+
name: Build & Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: ["lts/gallium", "lts/hydrogen", "current"]
16+
steps:
17+
- name: Checkout 🛎️
18+
uses: actions/checkout@v3
19+
with:
20+
persist-credentials: false
21+
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 16
25+
26+
- run: npm ci
27+
28+
- run: npm run test
29+
30+
- run: npm run build --if-present
31+
lint:
32+
name: format and lint
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout 🛎️
36+
uses: actions/checkout@v3
37+
with:
38+
persist-credentials: false
39+
40+
- uses: actions/setup-node@v3
41+
with:
42+
node-version: 16
43+
- run: npm ci
44+
45+
- run: npm run format
46+
47+
- run: npm run lint

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
pnpm-lock.yaml
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/.swc/
15+
/out/
16+
17+
# production
18+
/build
19+
20+
# misc
21+
.DS_Store
22+
*.pem
23+
24+
# debug
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
28+
.pnpm-debug.log*
29+
30+
# local env files
31+
.env*.local
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
38+
next-env.d.ts
39+
.idea
40+
41+
/dist
42+
public/sitemap-0.xml
43+
src/assets/resources/**/*.json
44+
45+
.vercel
46+
.env

LICENSE

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@ MIT License
22

33
Copyright (c) 2023 Prompt Engineering
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
1-
# chat-visual-novel
2-
ClickVisualNovel, an endless visual novel powered by ChatGPT. ClickVisualNovel —— 这部视觉小说,由ChatGPT来写,永不结束。
1+
# ChatVisualNovel - An endless visual novel powered by ChatGPT.
2+
3+
[![ci](https://github.com/prompt-engineering/chat-visual-novel/actions/workflows/ci.yml/badge.svg)](https://github.com/prompt-engineering/chat-visual-novel/actions/workflows/ci.yml)
4+
![GitHub](https://img.shields.io/github/license/prompt-engineering/chat-visual-novel)
5+
[![Discord](https://img.shields.io/discord/1082563233593966612)](https://discord.gg/FSWXq4DmEj)
6+
7+
English | [简体中文](./README.zh-CN.md)
8+
9+
Online Demo: https://chatvisualnovel.com/
10+
11+
Join us:
12+
13+
[![Chat Server](https://img.shields.io/badge/chat-discord-7289da.svg)](https://discord.gg/FSWXq4DmEj)
14+
15+
# Deploy ChatVisualNovel on Vercel with Planetscale
16+
17+
Follow these steps to deploy ChatVisualNovel on Vercel with a serverless MySQL database provided by Planetscale:
18+
19+
1. Clone the [ChatVisualNovel repo](https://github.com/prompt-engineering/chat-visual-novel) from GitHub.
20+
2. Create a Vercel account and connect it to your GitHub account.
21+
3. Create a [Planetscale](https://app.planetscale.com) account.
22+
4. Set up your Planetscale database:
23+
1. Log in to your Planetscale account with `pscale auth login`.
24+
2. Create a password with `pscale password create <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_NAME>`.
25+
3. Push your database to Planetscale with `npx prisma db push`.
26+
5. Configure your Vercel environment:
27+
- Set `DATABASE_URL` to your Planetscale database URL.
28+
- Generate an encryption key with `node scripts/gen-enc.js` and set it as `ENC_KEY`.
29+
30+
With these steps completed, your ChatVisualNovel will be deployed on Vercel with a Planetscale serverless MySQL database.
31+
32+
# Development
33+
34+
## LICENSE
35+
36+
This code is distributed under the MIT license. See [LICENSE](./LICENSE) in this directory.

README.zh-CN.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ChatVisualNovel - 这部视觉小说,由 ChatGPT 来写,永不结束。
2+
3+
[![ci](https://github.com/prompt-engineering/chat-visual-novel/actions/workflows/ci.yml/badge.svg)](https://github.com/prompt-engineering/chat-visual-novel/actions/workflows/ci.yml)
4+
![GitHub](https://img.shields.io/github/license/prompt-engineering/chat-visual-novel)
5+
6+
演示: https://chatvisualnovel.com/
7+
8+
[English](./README.md) | 简体中文
9+
10+
# 在 Vercel 上部署 ChatVisualNovel,使用 Planetscale
11+
12+
按照以下步骤,在 Vercel 上部署 ChatVisualNovel,使用由 Planetscale 提供的无服务器 MySQL 数据库:
13+
14+
1. 从 GitHub 克隆 [ChatVisualNovel](https://github.com/prompt-engineering/chat-visual-novel)
15+
2. 创建 Vercel 帐户,并将其连接到 GitHub 帐户。
16+
3. 创建 [Planetscale](https://app.planetscale.com) 帐户。
17+
4. 设置 Planetscale 数据库:
18+
1. 使用 `pscale auth login` 登录 Planetscale 帐户。
19+
2. 使用 `pscale password create <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_NAME>` 创建密码。
20+
3. 使用 `npx prisma db push` 将数据库推送到 Planetscale。
21+
5. 配置 Vercel 环境:
22+
-`DATABASE_URL` 设置为 Planetscale 数据库的 URL。
23+
- 使用 `node scripts/gen-enc.js` 生成加密密钥,并将其设置为 `ENC_KEY`
24+
25+
完成这些步骤后,您的 ChatVisualNovel 将在 Vercel 上部署,并使用 Planetscale 的无服务器 MySQL 数据库。
26+
27+
# Development
28+
29+
## LICENSE
30+
31+
This code is distributed under the MIT license. See [LICENSE](./LICENSE) in this directory.

docs/CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Contributor Manual
2+
3+
We welcome contributions of any size and skill level. As an open source project, we believe in giving back to our contributors and are happy to help with guidance on PRs, technical writing, and turning any feature idea into a reality.
4+
5+
> **Tip for new contributors:**
6+
> Take a look at [https://github.com/firstcontributions/first-contributions](https://github.com/firstcontributions/first-contributions) for helpful information on contributing
7+
8+
## Quick Guide
9+
10+
### Prerequisite
11+
12+
```shell
13+
node: ">=16.0.0"
14+
npm: "^8.11.0"
15+
# otherwise, your build will fail
16+
```
17+
18+
### Setting up your local repo
19+
20+
```shell
21+
git clone && cd ...
22+
npm install
23+
npm run build
24+
```
25+
26+
### Development
27+
28+
```shell
29+
# starts a file-watching, live-reloading dev script for active development
30+
npm run dev
31+
# build the entire project, one time.
32+
npm run build
33+
```
34+
35+
### Running tests
36+
37+
```shell
38+
# run this in the top-level project root to run all tests
39+
npm run test
40+
```
41+
42+
### Making a Pull Request
43+
44+
You can run the following commands before making a Pull Request
45+
46+
```shell
47+
# format with fix
48+
npm run format:fix
49+
# lint with fix
50+
npm run lint:fix
51+
```
52+
53+
## Code Structure
54+
55+
TODO
56+
57+
## Translation
58+
59+
See [i18n guide](TRANSLATING.md)

docs/TRANSLATING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 🌐 <abbr title="internationalization">i18n</abbr> Guide
2+
3+
Thanks for your interest in helping us translate ClickPrompt!
4+
5+
TODO

i18n/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# i18n files
2+
3+
Inside this folder, the first folder level is locale code such as `en-US`, and in it has A LOT of json files the naming convention is:
4+
5+
- Global data is in the `$.json` file.
6+
- For specific page data:
7+
- index page is corresponding to `_.json` file
8+
- other pages just use pathname without trailing slash and locale segment, and replace all `/` with `_`(cause in some filesystem `/` is illegal charactor in pathname). such as `_foo.json` for `/foo/`, `_foo_bar.json` for `/foo/bar/` . I think you get the idea.
9+
10+
# HOW TO USE IN RSC(React server component)
11+
12+
```typescript jsx
13+
// page.server.tsx
14+
import { getAppData } from "@/i18n";
15+
import CSC from "./component.client.tsx";
16+
17+
async function RscFoo() {
18+
// ...
19+
const { locale, pathname, i18n } = await getAppData();
20+
const t = i18n.tFactory("/");
21+
// t is a function takes key and give you value in the json file
22+
t("title"); // will be "Streamline your prompt design"
23+
24+
// you can also access global data by
25+
const g = i18n.g;
26+
27+
const i18nProps: GeneralI18nProps = {
28+
locale,
29+
pathname,
30+
i18n: {
31+
dict: i18n.dict,
32+
},
33+
};
34+
35+
// use i18n in CSC (client side component)
36+
return <CSC {...i18nProps} />;
37+
// ...
38+
}
39+
```
40+
41+
```typescript jsx
42+
// component.client.tsx
43+
"use client";
44+
45+
export default function CSC({ i18n }: GeneralI18nProps) {
46+
const { dict } = i18n;
47+
48+
// use dict like plain object here
49+
}
50+
```

i18n/en-US/$.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

i18n/en-US/_.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"title": "Before we begin,",
3+
"prompt_start": "You are a script writer who is writing a ",
4+
"prompt_after_story_genre": " story. Please come up with 1 main character who is a male and ",
5+
"prompt_after_number_of_girls": "girls. Please fill their information using JSON format:",
6+
"prompt_follow_cast_rules": "- Don't start the story yet.\n- Respond only with JSON.",
7+
"prompt_story_start": "Now write one line of the dialogue in the following format:",
8+
"prompt_after_story_format": "Please follow the following rules:\n- There must be a speaker and should not be \"narrator\".\n- The mood can only be either one of ",
9+
"prompt_places": "- The location can be either one of ",
10+
"prompt_end": "- If the speaker is not the main character, the dialogue may be a question to the main character.\n- If the dialogue is a question, please provide up to 3 answers using \"answers\":[\"\"].\n- If the speaker is the main character, don't provide possible answers.\n- Respond only with JSON.",
11+
"select_genre": "Please select a genre: ",
12+
"crime": "crime",
13+
"sci-fi": "sci-fi",
14+
"fantasy": "fantasy",
15+
"horror": "horror",
16+
"romance": "romance",
17+
"sd_note_prefix": "Images pre-generated using ",
18+
"sd_note_model": " with ",
19+
"reset": "Reset",
20+
"loading": "Building story",
21+
"start": "Start",
22+
"continue": "Continue",
23+
"prompt": "Prompt"
24+
}

0 commit comments

Comments
 (0)