Skip to content

Commit 5062a42

Browse files
committed
Initial Commit
1 parent 154b4e2 commit 5062a42

Some content is hidden

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

62 files changed

+10382
-0
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.md
2+
Dockerfile
3+
docker-compose.yml
4+
LICENSE
5+
netlify.toml
6+
vercel.json
7+
node_modules
8+
.vscode

.env.example

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Your API Key for OpenAI
2+
OPENAI_API_KEY=
3+
# Provide proxy for OpenAI API. e.g. http://127.0.0.1:7890
4+
HTTPS_PROXY=
5+
# Custom base url for OpenAI API. default: https://api.openai.com
6+
OPENAI_API_BASE_URL=
7+
# Inject analytics or other scripts before </head> of the page
8+
HEAD_SCRIPTS=
9+
# Secret string for the project. Use for generating signatures for API calls
10+
PUBLIC_SECRET_KEY=
11+
# Set password for site, support multiple password separated by comma. If not set, site will be public
12+
SITE_PASSWORD=
13+
# ID of the model to use. https://platform.openai.com/docs/api-reference/models/list
14+
OPENAI_API_MODEL=
15+
# Set the maximum number of historical messages used for contextual contact
16+
PUBLIC_MAX_HISTORY_MESSAGES=

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
public
3+
node_modules
4+
.netlify
5+
.vercel
6+
.github
7+
.changeset

.eslintrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
extends: ['@evan-yang', 'plugin:astro/recommended'],
3+
rules: {
4+
'no-console': ['error', { allow: ['error'] }],
5+
'react/display-name': 'off',
6+
'react-hooks/rules-of-hooks': 'off',
7+
'@typescript-eslint/no-use-before-define': 'off',
8+
},
9+
overrides: [
10+
{
11+
files: ['*.astro'],
12+
parser: 'astro-eslint-parser',
13+
parserOptions: {
14+
parser: '@typescript-eslint/parser',
15+
extraFileExtensions: ['.astro'],
16+
},
17+
rules: {
18+
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
19+
},
20+
},
21+
{
22+
// Define the configuration for `<script>` tag.
23+
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
24+
files: ['**/*.astro/*.js', '*.astro/*.js'],
25+
parser: '@typescript-eslint/parser',
26+
rules: {
27+
'prettier/prettier': 'off',
28+
},
29+
},
30+
],
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 🐞 Bug report (When using)
2+
description: Report an issue or possible bug when using `chatgpt-demo`
3+
labels: ['pending triage', 'use']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
### Before submitting...
9+
Thanks for taking the time to fill out this bug report! Please confirm the following points before submitting:
10+
11+
✅ I have checked the bug was not already reported by searching on GitHub under issues.
12+
✅ Use English to ask questions. This allows more people to search and participate in the issue.
13+
- type: input
14+
id: os
15+
attributes:
16+
label: What operating system are you using?
17+
placeholder: Mac, Windows, Linux
18+
validations:
19+
required: true
20+
- type: input
21+
id: browser
22+
attributes:
23+
label: What browser are you using?
24+
placeholder: Chrome, Firefox, Safari
25+
validations:
26+
required: true
27+
- type: textarea
28+
id: bug-description
29+
attributes:
30+
label: Describe the bug
31+
description: A clear and concise description of what the bug is.
32+
placeholder: Bug description
33+
validations:
34+
required: true
35+
- type: textarea
36+
id: prompt
37+
attributes:
38+
label: What prompt did you enter?
39+
description: If the issue is related to the prompt you entered, please fill in this field.
40+
- type: textarea
41+
id: console-logs
42+
attributes:
43+
label: Console Logs
44+
description: Please check your browser and fill in the error message if it exists.
45+
- type: checkboxes
46+
id: will-pr
47+
attributes:
48+
label: Participation
49+
options:
50+
- label: I am willing to submit a pull request for this issue.
51+
required: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 🐞 Bug report (When self-deploying)
2+
description: Report an issue or possible bug when deploy to your own server or cloud.
3+
labels: ['pending triage', 'deploy']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
### Before submitting...
9+
Thanks for taking the time to fill out this bug report! Please confirm the following points before submitting:
10+
11+
✅ I am using **latest version of chatgpt-demo**.
12+
✅ I have checked the bug was not already reported by searching on GitHub under issues.
13+
✅ Use English to ask questions. This allows more people to search and participate in the issue.
14+
- type: dropdown
15+
id: server
16+
attributes:
17+
label: How is Anse deployed?
18+
description: Select the used deployment method.
19+
options:
20+
- Node
21+
- Docker
22+
- Vercel
23+
- Netlify
24+
- Railway
25+
- Others (Specify in description)
26+
validations:
27+
required: true
28+
- type: textarea
29+
id: bug-description
30+
attributes:
31+
label: Describe the bug
32+
description: A clear and concise description of what the bug is.
33+
placeholder: Bug description
34+
validations:
35+
required: true
36+
- type: textarea
37+
id: console-logs
38+
attributes:
39+
label: Console Logs
40+
description: Please check your browser and node console, fill in the error message if it exists.
41+
- type: checkboxes
42+
id: will-pr
43+
attributes:
44+
label: Participation
45+
options:
46+
- label: I am willing to submit a pull request for this issue.
47+
required: false

.github/ISSUE_TEMPLATE/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 💬 Discussions
4+
url: https://github.com/anse-app/chatgpt-demo/discussions
5+
about: Use discussions if you have an idea for improvement or for asking questions.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 🚀 Feature request
2+
description: Suggest a feature or an improvement
3+
labels: ['enhancement']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
### Before submitting...
9+
Thank you for taking the time to fill out this feature request! Please confirm the following points before submitting:
10+
11+
✅ I have checked the feature was not already submitted by searching on GitHub under issues or discussions.
12+
✅ Use English. This allows more people to search and participate in the issue.
13+
- type: textarea
14+
id: feature-description
15+
attributes:
16+
label: Describe the feature
17+
description: A clear and concise description of what you think would be a helpful addition.
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: additional-context
22+
attributes:
23+
label: Additional context
24+
description: Any other context or screenshots about the feature request here.
25+
- type: checkboxes
26+
id: will-pr
27+
attributes:
28+
label: Participation
29+
options:
30+
- label: I am willing to submit a pull request for this feature.
31+
required: false

.github/ISSUE_TEMPLATE/typo.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 👀 Typo / Grammar fix
2+
description: You can just go ahead and send a PR! Thank you!
3+
labels: []
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## PR Welcome!
9+
10+
If the typo / grammar issue is trivial and straightforward, you can help by **directly sending a quick pull request**!
11+
If you spot multiple of them, we suggest combining them into a single PR. Thanks!
12+
- type: textarea
13+
id: context
14+
attributes:
15+
label: Additional context

.github/PULL_REQUEST_TEMPLATE.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- DO NOT IGNORE THE TEMPLATE!
2+
Thank you for contributing!
3+
Before submitting the PR, please make sure you do the following:
4+
- Discuss first. It's always better to open a feature request issue first to discuss with the maintainers whether the feature is desired and the design of those features.
5+
- Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages.
6+
- Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
7+
-->
8+
9+
### Description
10+
11+
<!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
12+
13+
### Linked Issues
14+
15+
16+
### Additional context
17+
18+
<!-- e.g. is there anything you'd like reviewers to focus on? -->

.github/workflows/build-docker.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: build_docker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build_docker:
9+
name: Build docker
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Set up QEMU
16+
uses: docker/setup-qemu-action@v2
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v2
21+
with:
22+
# https://hub.docker.com/settings/security?generateToken=true
23+
username: ${{ secrets.DOCKERHUB_USERNAME }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
- name: Build and push
26+
id: docker_build
27+
uses: docker/build-push-action@v4
28+
with:
29+
context: .
30+
push: true
31+
labels: ${{ steps.meta.outputs.labels }}
32+
platforms: linux/amd64,linux/arm64
33+
tags: |
34+
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-demo:${{ github.ref_name }}
35+
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-demo:latest

.github/workflows/lint.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: latest
22+
23+
- name: Set node
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 18.x
27+
cache: pnpm
28+
29+
- name: Install
30+
run: pnpm install --no-frozen-lockfile
31+
32+
- name: Lint
33+
run: pnpm run lint

.github/workflows/main.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Log in to the Container registry
23+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
37+
with:
38+
context: .
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/sync.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Upstream Sync
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
schedule:
8+
- cron: "0 0 * * *" # every day
9+
workflow_dispatch:
10+
11+
jobs:
12+
sync_latest_from_upstream:
13+
name: Sync latest commits from upstream repo
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.repository.fork }}
16+
17+
steps:
18+
# Step 1: run a standard checkout action
19+
- name: Checkout target repo
20+
uses: actions/checkout@v3
21+
22+
# Step 2: run the sync action
23+
- name: Sync upstream changes
24+
id: sync
25+
uses: aormsby/[email protected]
26+
with:
27+
upstream_sync_repo: anse-app/chatgpt-demo
28+
upstream_sync_branch: main
29+
target_sync_branch: main
30+
target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
31+
32+
# Set test_mode true to run tests instead of the true action!!
33+
test_mode: false
34+
35+
- name: Sync check
36+
if: failure()
37+
run: |
38+
echo "::error::由于权限不足,导致同步失败(这是预期的行为),请前往仓库首页手动执行[Sync fork]。"
39+
echo "::error::Due to insufficient permissions, synchronization failed (as expected). Please go to the repository homepage and manually perform [Sync fork]."
40+
exit 1

0 commit comments

Comments
 (0)