chriswu25 commited on
Commit
292c742
·
verified ·
1 Parent(s): 072bdec

Upload 5 files

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. Dockerfile +78 -0
  3. README.md +22 -4
  4. help.md +149 -0
  5. launch.sh +104 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ git-batch filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:19.1.0-alpine3.16
2
+
3
+ # Arguments
4
+ ARG APP_HOME=/home/node/app
5
+
6
+ # Install system dependencies
7
+ RUN apk add gcompat tini git jq curl
8
+
9
+ # Ensure proper handling of kernel signals
10
+ ENTRYPOINT [ "tini", "--" ]
11
+
12
+ # Create app directory
13
+ WORKDIR ${APP_HOME}
14
+
15
+ # Set NODE_ENV to production
16
+ ENV NODE_ENV=production
17
+
18
+ # Env
19
+ # 是否远程获取下面的参数 是个链接,返回一个json;执行完后关闭这个链接即可保密
20
+ # 返回内容:
21
+ # {
22
+ # "reverse_proxy": "https://onekey.xxx.top/v1",
23
+ # "proxy_password": "sk-ssvJn4VQAk596Lvv3548xxx",
24
+ # "api_key_makersuite": "AIzaSyAm5S9kl22DDNSXmnd4vgxxx",
25
+ # "github_secret": "github_pat_11AIWDQ2A0cLSEdwiwiZNC_10II4TsFExxx",
26
+ # "github_project": "bincooo/history"
27
+ # }
28
+ ENV fetch ""
29
+ # 代理转发地址
30
+ ENV reverse_proxy ""
31
+ # 代理转发token
32
+ ENV proxy_password ""
33
+ # gemini token
34
+ ENV api_key_makersuite ""
35
+ # github 项目访问凭证token
36
+ ENV github_secret ""
37
+ # github 项目名称
38
+ ENV github_project ""
39
+
40
+ # Install app dependencies
41
+ # COPY package*.json post-install.js ./
42
+ RUN git clone https://github.com/SillyTavern/SillyTavern.git --branch 1.12.11 .
43
+ RUN \
44
+ echo "*** Install npm packages ***" && \
45
+ npm install && npm cache clean --force
46
+
47
+ # Bundle app source
48
+ # COPY . ./
49
+
50
+ ADD launch.sh launch.sh
51
+ RUN curl -JLO https://github.com/bincooo/SillyTavern-Docker/releases/download/v1.0.0/git-batch
52
+ RUN chmod +x launch.sh && chmod +x git-batch && ./git-batch -h
53
+
54
+ RUN \
55
+ echo "*** Install npm packages ***" && \
56
+ npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev && npm cache clean --force
57
+
58
+ # Copy default chats, characters and user avatars to <folder>.default folder
59
+ RUN \
60
+ rm -f "config.yaml" || true && \
61
+ ln -s "./config/config.yaml" "config.yaml" || true && \
62
+ mkdir "config" || true
63
+
64
+ # Cleanup unnecessary files
65
+ RUN \
66
+ echo "*** Cleanup ***" && \
67
+ mv "./docker/docker-entrypoint.sh" "./" && \
68
+ rm -rf "./docker" && \
69
+ echo "*** Make docker-entrypoint.sh executable ***" && \
70
+ chmod +x "./docker-entrypoint.sh" && \
71
+ echo "*** Convert line endings to Unix format ***" && \
72
+ dos2unix "./docker-entrypoint.sh"
73
+ RUN sed -i 's/# Start the server/.\/launch.sh env \&\& .\/launch.sh init/g' docker-entrypoint.sh
74
+ RUN chmod -R 777 ${APP_HOME}
75
+
76
+ EXPOSE 8000
77
+
78
+ CMD [ "./docker-entrypoint.sh" ]
README.md CHANGED
@@ -1,10 +1,28 @@
1
  ---
2
- title: Sese
3
- emoji: 📊
4
- colorFrom: indigo
5
- colorTo: green
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Tavern
3
+ emoji: 🐨
4
+ colorFrom: green
5
+ colorTo: red
6
  sdk: docker
7
  pinned: false
8
+ app_port: 8000
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
+
13
+ 使用前请仔细阅读说明:[help](help.md)
14
+ <img width="1162" alt="Screenshot 2024-11-26 at 19 33 19" src="https://github.com/user-attachments/assets/db412195-2c6c-414b-bd9b-fcfa57ea4374">
15
+
16
+
17
+ 如果你没有替换README.md,则需要自己修改端口:
18
+ ```
19
+ ---
20
+ title: xxx
21
+ emoji: 🐨
22
+ colorFrom: green
23
+ colorTo: red
24
+ sdk: docker
25
+ pinned: false
26
+ app_port: 8000 <-- 这里配置,自行对比差异
27
+ ---
28
+ ```
help.md ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### huggingface 部署酒馆教程 (带对话记录同步功能)
2
+
3
+ #### 准备工作
4
+ 1. 用于同步数据的github仓库
5
+ 2. 用户同步数据的github凭证
6
+ 3. 下载初始酒馆项目
7
+ 4. huggingface账号(略)
8
+
9
+ #### step 1
10
+
11
+ 新建一个空项目,用于存储用户数据 [点我](https://github.com/new)
12
+
13
+ 注意是空的,不要勾选 [Add a README file] 选项, 可以选私有化
14
+
15
+ ![](https://i0.hdslb.com/bfs/article/4c775c1a262d9d4c5fadef31d505d75730947427.png)
16
+
17
+ 如图所示,我创建了一个项目: `bincooo/history`
18
+
19
+
20
+
21
+ #### step 2
22
+
23
+ 创建一个github访问凭证token,用于同步历史数据 [点我](https://github.com/settings/personal-access-tokens/new)
24
+
25
+ ![](https://i0.hdslb.com/bfs/article/72bd09d99b0e349dc3232b62b19f288630947427.png)
26
+
27
+ 填写 Token name: history (随意)
28
+
29
+ 填写 Expiration: 过期日期 (随意,没有永久选项)
30
+
31
+ 选择 Only select repositories
32
+
33
+ 选择 Select repositories: bincooo/history (你创建的项目)
34
+
35
+
36
+
37
+
38
+
39
+ 点开 Repository permissions (授权)
40
+
41
+ ![](https://i0.hdslb.com/bfs/article/031739bd64c2cbbdf18cecd1854a133630947427.png)
42
+
43
+ 选择 Pull requests: Access: Read and write (授权读写)
44
+
45
+
46
+
47
+
48
+
49
+ 最后点击最下面的生成按钮 Generate token
50
+
51
+ ![](https://i0.hdslb.com/bfs/article/20670b1d88793503f72f9e4608dbc46230947427.png)
52
+
53
+
54
+
55
+ 保存好你生成的token,离开这个页面后就再也看不到了
56
+
57
+ ![](https://i0.hdslb.com/bfs/article/21e2861b9f6c216f3f674defa8ec867430947427.png)
58
+
59
+ github_pat_11AIWDQ2A07DOQLEn5Lite_nhwHv2pxxxxx
60
+
61
+
62
+
63
+
64
+
65
+ #### step 3
66
+
67
+ https://github.com/bincooo/SillyTavern-Docker.git
68
+
69
+ 到这个项目去下载下来
70
+
71
+ ![](https://i0.hdslb.com/bfs/article/e00f8094754b9af7a281cba3800ccbf230947427.png)
72
+
73
+ 点击 Download ZIP 下载, 并解压
74
+
75
+
76
+
77
+
78
+
79
+ #### step 4
80
+
81
+ 进入 huggingface 新建 space: 点击头像里的 New Space
82
+
83
+ ![](https://i0.hdslb.com/bfs/article/c250bc0a9e4e32100299fc0c848fa24830947427.png)
84
+
85
+
86
+
87
+ 创建完后,上传解压文件内容:Upload files
88
+
89
+ ![](https://i0.hdslb.com/bfs/article/7bf62a42d0d1ac0834ae618845e9d78730947427.png)
90
+
91
+ 进入解压目录全选所有文件,拖入到上传控件
92
+
93
+ ![](https://i0.hdslb.com/bfs/article/a311db7f1865b04aa6fea4b708cfbcce30947427.png)
94
+
95
+ 点击 Dockerfile 文件 编辑它
96
+
97
+ ![](https://i0.hdslb.com/bfs/article/759e147a53d985f2c52b7f646847721830947427.png)
98
+
99
+ 修改这部分内容:(不要照抄,这里的是假数据)
100
+
101
+ ```md
102
+ # Env
103
+ # 代理转发地址
104
+ ENV reverse_proxy "https://onekey.1xxx.top/v1"
105
+ # 代理转发token
106
+ ENV proxy_password "sk-ssvJn4VQAk596Lvv35488xxxx"
107
+ # gemini token
108
+ ENV api_key_makersuite "AIzaSyAm5S9kl22xxxx"
109
+ # github 项目访问凭证token
110
+ ENV github_secret "github_pat_11AIWDQ2A0cLSEdwiwiZNC_10II4TsFxxx"
111
+ # github 项目名称
112
+ ENV github_project "bincooo/history"
113
+ ```
114
+
115
+ 最后点击下面的 `Commit changes main` 保存即可
116
+
117
+
118
+
119
+ 等待部署进度,变绿后获取访问链接:`Embed this space`
120
+
121
+ ![](https://i0.hdslb.com/bfs/article/d20b531fc0b3d703f17502e17da4e1db30947427.png)
122
+
123
+
124
+
125
+ 正常运行后会同步数据到你创建的github 项目下:
126
+
127
+ ![](https://i0.hdslb.com/bfs/article/8c949caa0ea8a32b8d3b03c7bddbae3a30947427.png)
128
+
129
+
130
+
131
+
132
+
133
+ =====
134
+
135
+
136
+
137
+
138
+
139
+ 已默认导入了几个破限选项,也预置好了超级记忆
140
+
141
+ ![](https://i0.hdslb.com/bfs/article/c8e5cbf1e8835272f3b73f17dd64ecbd30947427.png)
142
+
143
+ ![](https://i0.hdslb.com/bfs/article/23a56bf653d22187c58c96cf4ab20c1530947427.png)
144
+
145
+
146
+
147
+
148
+
149
+ 最后,同步代码书写不易,且用且珍惜 祝各位都能成功白嫖!
launch.sh ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ BASE=/home/node/app
4
+ USERNAME=$(printenv username)
5
+ PASSWORD=$(printenv password)
6
+
7
+ function env() {
8
+ if [[ ! -z "${fetch}" ]]; then
9
+ echo '远程获取参数...'
10
+ curl -s "$fetch" -o data.json
11
+ export github_secret=$(jq -r .github_secret data.json)
12
+ export github_project=$(jq -r .github_project data.json)
13
+ fi
14
+
15
+ if [[ -z "${USERNAME}" ]]; then
16
+ USERNAME="root"
17
+ fi
18
+
19
+ if [[ -z "${PASSWORD}" ]]; then
20
+ PASSWORD="123456"
21
+ fi
22
+
23
+ echo
24
+ echo "fetch = ${fetch}"
25
+ echo "github_secret = $github_secret"
26
+ echo "github_project = $github_project"
27
+ echo "USERNAME = ${USERNAME}"
28
+ echo "PASSWORD = ${PASSWORD}"
29
+ echo
30
+ echo
31
+
32
+ sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh
33
+ sed -i "s#\[github_project\]#${github_project}#g" launch.sh
34
+ }
35
+
36
+ function init() {
37
+ mkdir ${BASE}/history
38
+ cd ${BASE}/history
39
+
40
+ git config --global user.email "[email protected]"
41
+ git config --global user.name "complete-Mmx"
42
+ git config --global init.defaultBranch main
43
+ git init
44
+ git remote add origin https://[github_secret]@github.com/[github_project].git
45
+ git add .
46
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
47
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
48
+ git pull origin main
49
+
50
+ cd ${BASE}
51
+
52
+ DIR="${BASE}/history"
53
+ if [ "$(ls -A $DIR | grep -v .git)" ]; then
54
+ echo "Has history..."
55
+ else
56
+ echo "Empty history..."
57
+ cp -r data/* history/
58
+ cp -r secrets.json history/secrets.json
59
+ fi
60
+
61
+ rm -rf data
62
+ ln -s history data
63
+
64
+ rm -r config.yaml
65
+ cp config/config.yaml history/config.yaml
66
+ ln -s history/config.yaml config.yaml
67
+ sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml
68
+ sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml
69
+ sed -i "s/whitelistMode: true/whitelistMode: false/" ${BASE}/config.yaml
70
+ sed -i "s/basicAuthMode: false/basicAuthMode: true/" ${BASE}/config.yaml
71
+ cat config.yaml
72
+ echo "Init history."
73
+ chmod -R 777 history
74
+
75
+ nohup ./git-batch --commit 10s --name git-batch --email [email protected] --push 1m -p history > access.log 2>1 &
76
+ }
77
+
78
+ function release() {
79
+ rm -rf history
80
+ }
81
+
82
+ function update() {
83
+ cd ${BASE}/history
84
+ git pull origin main
85
+ git add .
86
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
87
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
88
+ git push origin main
89
+ }
90
+
91
+ case $1 in
92
+ env)
93
+ env
94
+ ;;
95
+ init)
96
+ init
97
+ ;;
98
+ release)
99
+ release
100
+ ;;
101
+ update)
102
+ update
103
+ ;;
104
+ esac