Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25a41e51b3 | ||
|
|
f998ff239a | ||
|
|
bae9ae6551 | ||
|
|
285e8b1577 | ||
|
|
ce915cdf6a | ||
|
|
84317a03e8 | ||
|
|
ac1fa09604 | ||
|
|
43bc08648d | ||
|
|
e93c77394d | ||
|
|
4b2509e643 | ||
|
|
14fbb437ff | ||
|
|
8963543159 | ||
|
|
377f71b16b | ||
|
|
d32351c130 | ||
|
|
967be6f88f | ||
|
|
fcdda71b46 | ||
|
|
138251932c | ||
|
|
4d1a2396e3 | ||
|
|
b06e292989 | ||
|
|
b1d5b84dd6 | ||
|
|
2beddab114 | ||
|
|
7f85a08508 | ||
|
|
721653a812 | ||
|
|
d99488f22f | ||
|
|
21c3009945 | ||
|
|
3f77762fda | ||
|
|
9590d93c34 | ||
|
|
e0e846a191 | ||
|
|
e9cc9b0798 | ||
|
|
51c5696bb9 | ||
|
|
64f0610ed7 | ||
|
|
1591430742 | ||
|
|
17c690dfb1 | ||
|
|
4b640f884b | ||
|
|
8976764ee5 | ||
|
|
47db663fcd | ||
|
|
366e67bb6e | ||
|
|
b52bae6e17 | ||
|
|
714b8834c7 | ||
|
|
631704d04d | ||
|
|
5896593951 | ||
|
|
8431b5d24f | ||
|
|
bbd1ac1484 | ||
|
|
5990567a79 | ||
|
|
fa0fcc2c89 | ||
|
|
face4c97e8 | ||
|
|
c0ad99673b | ||
|
|
510683c57e | ||
|
|
cea1d8b4d1 | ||
|
|
b7c34b0d42 | ||
|
|
a95fbbbd78 | ||
|
|
d1560674b3 | ||
|
|
4fdfbd2f82 | ||
|
|
635767408f | ||
|
|
39a7eee8ea | ||
|
|
6ec6044901 | ||
|
|
4760a552d4 | ||
|
|
6294327273 | ||
|
|
260f51955a | ||
|
|
29ea886576 | ||
|
|
dae3f72d04 | ||
|
|
796338a32f | ||
|
|
66621e4ceb | ||
|
|
a6f5b520c3 | ||
|
|
c23c644fbc | ||
|
|
cb85c0938d | ||
|
|
88a5d11e15 | ||
|
|
1ecb0b444b | ||
|
|
72d601370d | ||
|
|
4814b88172 | ||
|
|
cfad67a922 | ||
|
|
c28f5604ab | ||
|
|
5853b8ca8d | ||
|
|
ebfc0ce672 | ||
|
|
e62fcd152a | ||
|
|
9bd9b9ecbd | ||
|
|
17faa9c5b8 | ||
|
|
4cd445bf77 | ||
|
|
4fb35845b0 | ||
|
|
f373f1caa8 | ||
|
|
4e75531651 | ||
|
|
539c538d65 | ||
|
|
d90186db33 | ||
|
|
a2d8729ae3 | ||
|
|
edc6ac7297 | ||
|
|
e89e23621c | ||
|
|
6b9ec4c6fa | ||
|
|
ced0966ffc | ||
|
|
966b912013 | ||
|
|
dc71054e61 |
113
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
create-draft:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- uses: jossef/action-set-json-field@v2.1
|
||||
with:
|
||||
file: manifest.json
|
||||
field: version
|
||||
value: ${{ env.VERSION }}
|
||||
|
||||
- continue-on-error: true
|
||||
run: |
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git commit -am "release ${{github.ref_name}}"
|
||||
git push
|
||||
|
||||
- run: |
|
||||
gh release create ${{github.ref_name}} -d -F CURRENT_CHANGE.md -t ${{github.ref_name}}
|
||||
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- uses: actions/setup-python@v4
|
||||
id: cp310
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- uses: crazy-max/ghaction-chocolatey@v2
|
||||
with:
|
||||
args: install upx
|
||||
- run: |
|
||||
Start-BitsTransfer https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip ./python-3.10.11-embed-amd64.zip
|
||||
Expand-Archive ./python-3.10.11-embed-amd64.zip -DestinationPath ./py310
|
||||
$content=Get-Content "./py310/python310._pth"; $content | ForEach-Object {if ($_.ReadCount -eq 3) {"Lib\\site-packages"} else {$_}} | Set-Content ./py310/python310._pth
|
||||
./py310/python ./backend-python/get-pip.py
|
||||
./py310/python -m pip install Cython
|
||||
Copy-Item -Path "${{ steps.cp310.outputs.python-path }}/../include" -Destination "py310/include" -Recurse
|
||||
Copy-Item -Path "${{ steps.cp310.outputs.python-path }}/../libs" -Destination "py310/libs" -Recurse
|
||||
./py310/python -m pip install cyac
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
make
|
||||
Rename-Item -Path "build/bin/RWKV-Runner.exe" -NewName "RWKV-Runner_windows_x64.exe"
|
||||
|
||||
- run: gh release upload ${{github.ref_name}} build/bin/RWKV-Runner_windows_x64.exe
|
||||
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install upx
|
||||
sudo apt-get install build-essential libgtk-3-dev libwebkit2gtk-4.0-dev
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
make
|
||||
mv build/bin/RWKV-Runner build/bin/RWKV-Runner_linux_x64
|
||||
|
||||
- run: gh release upload ${{github.ref_name}} build/bin/RWKV-Runner_linux_x64
|
||||
|
||||
macos:
|
||||
runs-on: macos-13
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
make
|
||||
cp build/darwin/Readme_Install.txt build/bin/Readme_Install.txt
|
||||
cp build/bin/RWKV-Runner.app/Contents/MacOS/RWKV-Runner build/bin/RWKV-Runner_darwin_universal
|
||||
cd build/bin && zip -r RWKV-Runner_macos_universal.zip RWKV-Runner.app Readme_Install.txt
|
||||
|
||||
- run: gh release upload ${{github.ref_name}} build/bin/RWKV-Runner_macos_universal.zip build/bin/RWKV-Runner_darwin_universal
|
||||
|
||||
publish-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ windows, linux, macos ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: gh release edit ${{github.ref_name}} --draft=false
|
||||
1
.gitignore
vendored
@@ -13,6 +13,7 @@ __pycache__
|
||||
/py310
|
||||
*.zip
|
||||
/cmd-helper.bat
|
||||
/install-py-dep.bat
|
||||
/backend-python/wkv_cuda
|
||||
*.exe
|
||||
*.old
|
||||
|
||||
19
.vscode/launch.json
vendored
@@ -10,9 +10,24 @@
|
||||
"name": "Python",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "./backend-python/main.py",
|
||||
"program": "${workspaceFolder}/backend-python/main.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"justMyCode": false
|
||||
},
|
||||
{
|
||||
"name": "Golang",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "exec",
|
||||
"program": "${workspaceFolder}/build/bin/testwails.exe",
|
||||
"console": "integratedTerminal",
|
||||
"preLaunchTask": "build dev"
|
||||
},
|
||||
{
|
||||
"name": "Frontend",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "wails dev -browser"
|
||||
}
|
||||
]
|
||||
}
|
||||
40
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build dev",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CGO_ENABLED": "1"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"options": {
|
||||
"env": {
|
||||
"CGO_CFLAGS": "-mmacosx-version-min=10.13",
|
||||
"CGO_LDFLAGS": "-framework UniformTypeIdentifiers -mmacosx-version-min=10.13"
|
||||
}
|
||||
}
|
||||
},
|
||||
"windows": {
|
||||
"options": {
|
||||
"env": {
|
||||
"CGO_ENABLED": "0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"command": "go",
|
||||
"args": [
|
||||
"build",
|
||||
"-tags",
|
||||
"dev",
|
||||
"-gcflags",
|
||||
"all=-N -l",
|
||||
"-o",
|
||||
"build/bin/testwails.exe"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
12
CURRENT_CHANGE.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## Changes
|
||||
|
||||
- add DPI Scaling setting
|
||||
- allow custom api url, key, model
|
||||
- add chat and completion error messages
|
||||
|
||||
## Install
|
||||
|
||||
- Windows: https://github.com/josStorer/RWKV-Runner/blob/master/build/windows/Readme_Install.txt
|
||||
- MacOS: https://github.com/josStorer/RWKV-Runner/blob/master/build/darwin/Readme_Install.txt
|
||||
- Linux: https://github.com/josStorer/RWKV-Runner/blob/master/build/linux/Readme_Install.txt
|
||||
- Server-Deploy-Examples: https://github.com/josStorer/RWKV-Runner/tree/master/deploy-examples
|
||||
12
Makefile
@@ -1,16 +1,22 @@
|
||||
ifeq ($(OS), Windows_NT)
|
||||
build: build-windows
|
||||
else
|
||||
else ifeq ($(shell uname -s), Darwin)
|
||||
build: build-macos
|
||||
else
|
||||
build: build-linux
|
||||
endif
|
||||
|
||||
build-windows:
|
||||
@echo ---- build for windows
|
||||
wails build -upx -ldflags "-s -w"
|
||||
wails build -upx -ldflags "-s -w" -platform windows/amd64
|
||||
|
||||
build-macos:
|
||||
@echo ---- build for macos
|
||||
wails build -ldflags "-s -w"
|
||||
wails build -ldflags "-s -w" -platform darwin/universal
|
||||
|
||||
build-linux:
|
||||
@echo ---- build for linux
|
||||
wails build -upx -ldflags "-s -w" -platform linux/amd64
|
||||
|
||||
dev:
|
||||
wails dev
|
||||
|
||||
67
README.md
@@ -15,7 +15,13 @@ compatible with the OpenAI API, which means that every ChatGPT client is an RWKV
|
||||
|
||||
English | [简体中文](README_ZH.md)
|
||||
|
||||
[FAQs](https://github.com/josStorer/RWKV-Runner/wiki/FAQs) | [Preview](#Preview) | [Download][download-url]
|
||||
### Install
|
||||
|
||||
[![Windows][Windows-image]][Windows-url]
|
||||
[![MacOS][MacOS-image]][MacOS-url]
|
||||
[![Linux][Linux-image]][Linux-url]
|
||||
|
||||
[FAQs](https://github.com/josStorer/RWKV-Runner/wiki/FAQs) | [Preview](#Preview) | [Download][download-url] | [Server-Deploy-Examples](https://github.com/josStorer/RWKV-Runner/tree/master/deploy-examples)
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg
|
||||
|
||||
@@ -27,9 +33,23 @@ English | [简体中文](README_ZH.md)
|
||||
|
||||
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
|
||||
|
||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||
|
||||
[Windows-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/windows/Readme_Install.txt
|
||||
|
||||
[MacOS-image]: https://img.shields.io/badge/-MacOS-black?logo=apple
|
||||
|
||||
[MacOS-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/darwin/Readme_Install.txt
|
||||
|
||||
[Linux-image]: https://img.shields.io/badge/-Linux-black?logo=linux
|
||||
|
||||
[Linux-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/linux/Readme_Install.txt
|
||||
|
||||
</div>
|
||||
|
||||
#### Default configs do not enable custom CUDA kernel acceleration, but I strongly recommend that you enable it and run with int8 precision, which is much faster and consumes much less VRAM. Go to the Configs page and turn on `Use Custom CUDA kernel to Accelerate`.
|
||||
#### Default configs has enabled custom CUDA kernel acceleration, which is much faster and consumes much less VRAM. If you encounter possible compatibility issues, go to the Configs page and turn off `Use Custom CUDA kernel to Accelerate`.
|
||||
|
||||
#### If Windows Defender claims this is a virus, you can try downloading [v1.0.8](https://github.com/josStorer/RWKV-Runner/releases/tag/v1.0.8)/[v1.0.9](https://github.com/josStorer/RWKV-Runner/releases/tag/v1.0.9) and letting it update automatically to the latest version, or add it to the trusted list.
|
||||
|
||||
#### For different tasks, adjusting API parameters can achieve better results. For example, for translation tasks, you can try setting Temperature to 1 and Top_P to 0.3.
|
||||
|
||||
@@ -67,12 +87,51 @@ body.json:
|
||||
}
|
||||
```
|
||||
|
||||
## Embeddings API Example
|
||||
|
||||
If you are using langchain, just use `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
|
||||
def cosine_similarity(a, b):
|
||||
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|
||||
|
||||
|
||||
values = [
|
||||
"I am a girl",
|
||||
"我是个女孩",
|
||||
"私は女の子です",
|
||||
"广东人爱吃福建人",
|
||||
"我是个人类",
|
||||
"I am a human",
|
||||
"that dog is so cute",
|
||||
"私はねこむすめです、にゃん♪",
|
||||
"宇宙级特大事件!号外号外!"
|
||||
]
|
||||
|
||||
embeddings = []
|
||||
for v in values:
|
||||
r = requests.post("http://127.0.0.1:8000/embeddings", json={"input": v})
|
||||
embedding = r.json()["data"][0]["embedding"]
|
||||
embeddings.append(embedding)
|
||||
|
||||
compared_embedding = embeddings[0]
|
||||
|
||||
embeddings_cos_sim = [cosine_similarity(compared_embedding, e) for e in embeddings]
|
||||
|
||||
for i in np.argsort(embeddings_cos_sim)[::-1]:
|
||||
print(f"{embeddings_cos_sim[i]:.10f} - {values[i]}")
|
||||
```
|
||||
|
||||
## Todo
|
||||
|
||||
- [ ] Model training functionality
|
||||
- [x] CUDA operator int8 acceleration
|
||||
- [ ] macOS support
|
||||
- [ ] Linux support
|
||||
- [x] macOS support
|
||||
- [x] Linux support
|
||||
- [ ] Local State Cache DB
|
||||
|
||||
## Related Repositories:
|
||||
|
||||
69
README_ZH.md
@@ -14,7 +14,13 @@ API兼容的接口,这意味着一切ChatGPT客户端都是RWKV客户端。
|
||||
|
||||
[English](README.md) | 简体中文
|
||||
|
||||
[视频演示](https://www.bilibili.com/video/BV1hM4y1v76R) | [疑难解答](https://www.bilibili.com/read/cv23921171) | [预览](#Preview) | [下载][download-url]
|
||||
### 安装
|
||||
|
||||
[![Windows][Windows-image]][Windows-url]
|
||||
[![MacOS][MacOS-image]][MacOS-url]
|
||||
[![Linux][Linux-image]][Linux-url]
|
||||
|
||||
[视频演示](https://www.bilibili.com/video/BV1hM4y1v76R) | [疑难解答](https://www.bilibili.com/read/cv23921171) | [预览](#Preview) | [下载][download-url] | [懒人包](https://pan.baidu.com/s/1wchIUHgne3gncIiLIeKBEQ?pwd=1111) | [服务器部署示例](https://github.com/josStorer/RWKV-Runner/tree/master/deploy-examples)
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg
|
||||
|
||||
@@ -26,11 +32,25 @@ API兼容的接口,这意味着一切ChatGPT客户端都是RWKV客户端。
|
||||
|
||||
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
|
||||
|
||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||
|
||||
[Windows-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/windows/Readme_Install.txt
|
||||
|
||||
[MacOS-image]: https://img.shields.io/badge/-MacOS-black?logo=apple
|
||||
|
||||
[MacOS-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/darwin/Readme_Install.txt
|
||||
|
||||
[Linux-image]: https://img.shields.io/badge/-Linux-black?logo=linux
|
||||
|
||||
[Linux-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/linux/Readme_Install.txt
|
||||
|
||||
</div>
|
||||
|
||||
#### 注意 目前RWKV中文模型质量一般,推荐使用英文模型体验实际RWKV能力
|
||||
#### 注意 目前RWKV中文模型质量一般,推荐使用英文模型或World(100+ 语言)体验实际RWKV能力
|
||||
|
||||
#### 预设配置没有开启自定义CUDA算子加速,但我强烈建议你开启它并使用int8量化运行,速度非常快,且显存消耗少得多。前往配置页面,打开`使用自定义CUDA算子加速`
|
||||
#### 预设配置已经开启自定义CUDA算子加速,速度更快,且显存消耗更少。如果你遇到可能的兼容性问题,前往配置页面,关闭`使用自定义CUDA算子加速`
|
||||
|
||||
#### 如果Windows Defender说这是一个病毒,你可以尝试下载[v1.0.8](https://github.com/josStorer/RWKV-Runner/releases/tag/v1.0.8)/[v1.0.9](https://github.com/josStorer/RWKV-Runner/releases/tag/v1.0.9)然后让其自动更新到最新版,或添加信任
|
||||
|
||||
#### 对于不同的任务,调整API参数会获得更好的效果,例如对于翻译任务,你可以尝试设置Temperature为1,Top_P为0.3
|
||||
|
||||
@@ -67,12 +87,51 @@ body.json:
|
||||
}
|
||||
```
|
||||
|
||||
## Embeddings API 示例
|
||||
|
||||
如果你在用langchain, 直接使用 `OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")`
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
|
||||
def cosine_similarity(a, b):
|
||||
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|
||||
|
||||
|
||||
values = [
|
||||
"I am a girl",
|
||||
"我是个女孩",
|
||||
"私は女の子です",
|
||||
"广东人爱吃福建人",
|
||||
"我是个人类",
|
||||
"I am a human",
|
||||
"that dog is so cute",
|
||||
"私はねこむすめです、にゃん♪",
|
||||
"宇宙级特大事件!号外号外!"
|
||||
]
|
||||
|
||||
embeddings = []
|
||||
for v in values:
|
||||
r = requests.post("http://127.0.0.1:8000/embeddings", json={"input": v})
|
||||
embedding = r.json()["data"][0]["embedding"]
|
||||
embeddings.append(embedding)
|
||||
|
||||
compared_embedding = embeddings[0]
|
||||
|
||||
embeddings_cos_sim = [cosine_similarity(compared_embedding, e) for e in embeddings]
|
||||
|
||||
for i in np.argsort(embeddings_cos_sim)[::-1]:
|
||||
print(f"{embeddings_cos_sim[i]:.10f} - {values[i]}")
|
||||
```
|
||||
|
||||
## Todo
|
||||
|
||||
- [ ] 模型训练功能
|
||||
- [x] CUDA算子int8提速
|
||||
- [ ] macOS支持
|
||||
- [ ] linux支持
|
||||
- [x] macOS支持
|
||||
- [x] linux支持
|
||||
- [ ] 本地状态缓存数据库
|
||||
|
||||
## 相关仓库:
|
||||
|
||||
@@ -2,6 +2,7 @@ package backend_golang
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -14,9 +15,11 @@ import (
|
||||
|
||||
// App struct
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
exDir string
|
||||
cmdPrefix string
|
||||
ctx context.Context
|
||||
HasConfigData bool
|
||||
ConfigData map[string]any
|
||||
exDir string
|
||||
cmdPrefix string
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct
|
||||
@@ -53,15 +56,30 @@ func (a *App) UpdateApp(url string) (broken bool, err error) {
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
name, err := os.Executable()
|
||||
if err != nil {
|
||||
return false, err
|
||||
if runtime.GOOS == "windows" {
|
||||
name, err := os.Executable()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
exec.Command(name, os.Args[1:]...).Start()
|
||||
wruntime.Quit(a.ctx)
|
||||
}
|
||||
exec.Command(name, os.Args[1:]...).Start()
|
||||
wruntime.Quit(a.ctx)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (a *App) RestartApp() error {
|
||||
if runtime.GOOS == "windows" {
|
||||
name, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
exec.Command(name, os.Args[1:]...).Start()
|
||||
wruntime.Quit(a.ctx)
|
||||
return nil
|
||||
}
|
||||
return errors.New("unsupported OS")
|
||||
}
|
||||
|
||||
func (a *App) GetPlatform() string {
|
||||
return runtime.GOOS
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package backend_golang
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -18,6 +19,7 @@ func (a *App) DownloadFile(path string, url string) error {
|
||||
|
||||
type DownloadStatus struct {
|
||||
resp *grab.Response
|
||||
cancel context.CancelFunc
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Url string `json:"url"`
|
||||
@@ -29,7 +31,7 @@ type DownloadStatus struct {
|
||||
Done bool `json:"done"`
|
||||
}
|
||||
|
||||
var downloadList []DownloadStatus
|
||||
var downloadList []*DownloadStatus
|
||||
|
||||
func existsInDownloadList(url string) bool {
|
||||
for _, ds := range downloadList {
|
||||
@@ -41,49 +43,58 @@ func existsInDownloadList(url string) bool {
|
||||
}
|
||||
|
||||
func (a *App) PauseDownload(url string) {
|
||||
for i, ds := range downloadList {
|
||||
for _, ds := range downloadList {
|
||||
if ds.Url == url {
|
||||
if ds.resp != nil {
|
||||
ds.resp.Cancel()
|
||||
}
|
||||
|
||||
downloadList[i] = DownloadStatus{
|
||||
resp: ds.resp,
|
||||
Name: ds.Name,
|
||||
Path: ds.Path,
|
||||
Url: ds.Url,
|
||||
Downloading: false,
|
||||
if ds.cancel != nil {
|
||||
ds.cancel()
|
||||
}
|
||||
ds.resp = nil
|
||||
ds.Downloading = false
|
||||
ds.Speed = 0
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) ContinueDownload(url string) {
|
||||
for i, ds := range downloadList {
|
||||
for _, ds := range downloadList {
|
||||
if ds.Url == url {
|
||||
client := grab.NewClient()
|
||||
req, _ := grab.NewRequest(ds.Path, ds.Url)
|
||||
resp := client.Do(req)
|
||||
if !ds.Downloading && ds.resp == nil && !ds.Done {
|
||||
ds.Downloading = true
|
||||
|
||||
downloadList[i] = DownloadStatus{
|
||||
resp: resp,
|
||||
Name: ds.Name,
|
||||
Path: ds.Path,
|
||||
Url: ds.Url,
|
||||
Downloading: true,
|
||||
req, err := grab.NewRequest(ds.Path, ds.Url)
|
||||
if err != nil {
|
||||
ds.Downloading = false
|
||||
break
|
||||
}
|
||||
// if PauseDownload() is called before the request finished, ds.Downloading will be false
|
||||
// if the user keeps clicking pause and resume, it may result in multiple requests being successfully downloaded at the same time
|
||||
// so we have to create a context and cancel it when PauseDownload() is called
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ds.cancel = cancel
|
||||
req = req.WithContext(ctx)
|
||||
resp := grab.DefaultClient.Do(req)
|
||||
|
||||
if resp != nil && resp.HTTPResponse != nil &&
|
||||
resp.HTTPResponse.StatusCode >= 200 && resp.HTTPResponse.StatusCode < 300 {
|
||||
ds.resp = resp
|
||||
} else {
|
||||
ds.Downloading = false
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) AddToDownloadList(path string, url string) {
|
||||
if !existsInDownloadList(url) {
|
||||
downloadList = append(downloadList, DownloadStatus{
|
||||
downloadList = append(downloadList, &DownloadStatus{
|
||||
resp: nil,
|
||||
Name: filepath.Base(path),
|
||||
Path: a.exDir + path,
|
||||
Url: url,
|
||||
Downloading: true,
|
||||
Downloading: false,
|
||||
})
|
||||
a.ContinueDownload(url)
|
||||
} else {
|
||||
@@ -96,32 +107,17 @@ func (a *App) downloadLoop() {
|
||||
go func() {
|
||||
for {
|
||||
<-ticker.C
|
||||
for i, ds := range downloadList {
|
||||
transferred := int64(0)
|
||||
size := int64(0)
|
||||
speed := float64(0)
|
||||
progress := float64(0)
|
||||
downloading := ds.Downloading
|
||||
done := false
|
||||
for _, ds := range downloadList {
|
||||
if ds.resp != nil {
|
||||
transferred = ds.resp.BytesComplete()
|
||||
size = ds.resp.Size()
|
||||
speed = ds.resp.BytesPerSecond()
|
||||
progress = 100 * ds.resp.Progress()
|
||||
downloading = !ds.resp.IsComplete()
|
||||
done = ds.resp.Progress() == 1
|
||||
}
|
||||
downloadList[i] = DownloadStatus{
|
||||
resp: ds.resp,
|
||||
Name: ds.Name,
|
||||
Path: ds.Path,
|
||||
Url: ds.Url,
|
||||
Transferred: transferred,
|
||||
Size: size,
|
||||
Speed: speed,
|
||||
Progress: progress,
|
||||
Downloading: downloading,
|
||||
Done: done,
|
||||
ds.Transferred = ds.resp.BytesComplete()
|
||||
ds.Size = ds.resp.Size()
|
||||
ds.Speed = ds.resp.BytesPerSecond()
|
||||
ds.Progress = 100 * ds.resp.Progress()
|
||||
ds.Downloading = !ds.resp.IsComplete()
|
||||
ds.Done = ds.resp.Progress() == 1
|
||||
if !ds.Downloading {
|
||||
ds.resp = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
runtime.EventsEmit(a.ctx, "downloadList", downloadList)
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
func (a *App) SaveJson(fileName string, jsonData any) error {
|
||||
@@ -119,8 +121,34 @@ func (a *App) CopyFile(src string, dst string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) OpenFileFolder(path string) error {
|
||||
absPath, err := filepath.Abs(a.exDir + path)
|
||||
func (a *App) OpenSaveFileDialog(filterPattern string, defaultFileName string, savedContent string) (string, error) {
|
||||
path, err := wruntime.SaveFileDialog(a.ctx, wruntime.SaveDialogOptions{
|
||||
DefaultFilename: defaultFileName,
|
||||
Filters: []wruntime.FileFilter{{
|
||||
Pattern: filterPattern,
|
||||
}},
|
||||
CanCreateDirectories: true,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if path == "" {
|
||||
return "", nil
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(savedContent), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (a *App) OpenFileFolder(path string, relative bool) error {
|
||||
var absPath string
|
||||
var err error
|
||||
if relative {
|
||||
absPath, err = filepath.Abs(a.exDir + path)
|
||||
} else {
|
||||
absPath, err = filepath.Abs(path)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -140,7 +168,12 @@ func (a *App) OpenFileFolder(path string) error {
|
||||
}
|
||||
return nil
|
||||
case "linux":
|
||||
println("unsupported OS")
|
||||
cmd := exec.Command("xdg-open", absPath)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("unsupported OS")
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package backend_golang
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (a *App) StartServer(python string, port int, host string) (string, error) {
|
||||
@@ -48,32 +51,38 @@ func (a *App) InstallPyDep(python string, cnMirror bool) (string, error) {
|
||||
var err error
|
||||
if python == "" {
|
||||
python, err = GetPython()
|
||||
if runtime.GOOS == "windows" {
|
||||
python, err = filepath.Abs(python)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
python = `"` + python + `"`
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
ChangeFileLine("./py310/python310._pth", 3, "Lib\\site-packages")
|
||||
installScript := python + " ./backend-python/get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple\n" +
|
||||
python + " -m pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cu117\n" +
|
||||
python + " -m pip install -r ./backend-python/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple\n" +
|
||||
"exit"
|
||||
if !cnMirror {
|
||||
installScript = strings.Replace(installScript, " -i https://pypi.tuna.tsinghua.edu.cn/simple", "", -1)
|
||||
installScript = strings.Replace(installScript, "requirements.txt", "requirements_versions.txt", -1)
|
||||
}
|
||||
err = os.WriteFile("./install-py-dep.bat", []byte(installScript), 0644)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return Cmd("install-py-dep.bat")
|
||||
}
|
||||
|
||||
if cnMirror {
|
||||
_, err = Cmd(python, "./backend-python/get-pip.py", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_without_cyac.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||
} else {
|
||||
_, err = Cmd(python, "./backend-python/get-pip.py")
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
_, err = Cmd(python, "-m", "pip", "install", "torch==1.13.1", "torchvision==0.14.1", "torchaudio==0.13.1", "--index-url", "https://download.pytorch.org/whl/cu117")
|
||||
} else {
|
||||
_, err = Cmd(python, "-m", "pip", "install", "torch", "torchvision", "torchaudio")
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if cnMirror {
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||
} else {
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt")
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_without_cyac.txt")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,19 @@ import (
|
||||
func Cmd(args ...string) (string, error) {
|
||||
switch platform := runtime.GOOS; platform {
|
||||
case "windows":
|
||||
_, err := os.Stat("cmd-helper.bat")
|
||||
if err != nil {
|
||||
if err := os.WriteFile("./cmd-helper.bat", []byte("start %*"), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := os.WriteFile("./cmd-helper.bat", []byte("start %*"), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
cmdHelper, err := filepath.Abs("./cmd-helper")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, arg := range args {
|
||||
if strings.Contains(arg, " ") && strings.Contains(cmdHelper, " ") {
|
||||
return "", errors.New("path contains space") // golang bug https://github.com/golang/go/issues/17149#issuecomment-473976818
|
||||
if strings.Contains(cmdHelper, " ") {
|
||||
for _, arg := range args {
|
||||
if strings.Contains(arg, " ") {
|
||||
return "", errors.New("path contains space") // golang bug https://github.com/golang/go/issues/17149#issuecomment-473976818
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ func Cmd(args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
exDir := filepath.Dir(ex) + "/../../../"
|
||||
cmd := exec.Command("osascript", "-e", `tell application 'Terminal' to do script '`+"cd "+exDir+" && "+strings.Join(args, " ")+`'`)
|
||||
cmd := exec.Command("osascript", "-e", `tell application "Terminal" to do script "`+"cd "+exDir+" && "+strings.Join(args, " ")+`"`)
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import tiktoken
|
||||
import GPUtil
|
||||
|
||||
import torch
|
||||
import rwkv
|
||||
import langchain
|
||||
import fastapi
|
||||
import uvicorn
|
||||
import sse_starlette
|
||||
|
||||
BIN
backend-python/requirements_without_cyac.txt
Normal file
@@ -2,10 +2,13 @@ import asyncio
|
||||
import json
|
||||
from threading import Lock
|
||||
from typing import List
|
||||
import base64
|
||||
|
||||
from fastapi import APIRouter, Request, status, HTTPException
|
||||
from sse_starlette.sse import EventSourceResponse
|
||||
from pydantic import BaseModel
|
||||
import numpy as np
|
||||
import tiktoken
|
||||
from utils.rwkv import *
|
||||
from utils.log import quick_log
|
||||
import global_var
|
||||
@@ -24,12 +27,187 @@ class ChatCompletionBody(ModelConfigBody):
|
||||
stream: bool = False
|
||||
stop: str = None
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"messages": [{"role": "user", "content": "hello"}],
|
||||
"model": "rwkv",
|
||||
"stream": False,
|
||||
"stop": None,
|
||||
"max_tokens": 1000,
|
||||
"temperature": 1.2,
|
||||
"top_p": 0.5,
|
||||
"presence_penalty": 0.4,
|
||||
"frequency_penalty": 0.4,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CompletionBody(ModelConfigBody):
|
||||
prompt: str
|
||||
model: str = "rwkv"
|
||||
stream: bool = False
|
||||
stop: str = None
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"prompt": "The following is an epic science fiction masterpiece that is immortalized, "
|
||||
+ "with delicate descriptions and grand depictions of interstellar civilization wars.\nChapter 1.\n",
|
||||
"model": "rwkv",
|
||||
"stream": False,
|
||||
"stop": None,
|
||||
"max_tokens": 100,
|
||||
"temperature": 1.2,
|
||||
"top_p": 0.5,
|
||||
"presence_penalty": 0.4,
|
||||
"frequency_penalty": 0.4,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
completion_lock = Lock()
|
||||
|
||||
requests_num = 0
|
||||
|
||||
|
||||
async def eval_rwkv(
|
||||
model: RWKV,
|
||||
request: Request,
|
||||
body: ModelConfigBody,
|
||||
prompt: str,
|
||||
stream: bool,
|
||||
stop: str,
|
||||
chat_mode: bool,
|
||||
):
|
||||
global requests_num
|
||||
requests_num = requests_num + 1
|
||||
quick_log(request, None, "Start Waiting. RequestsNum: " + str(requests_num))
|
||||
while completion_lock.locked():
|
||||
if await request.is_disconnected():
|
||||
requests_num = requests_num - 1
|
||||
print(f"{request.client} Stop Waiting (Lock)")
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Stop Waiting (Lock). RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
await asyncio.sleep(0.1)
|
||||
else:
|
||||
completion_lock.acquire()
|
||||
if await request.is_disconnected():
|
||||
completion_lock.release()
|
||||
requests_num = requests_num - 1
|
||||
print(f"{request.client} Stop Waiting (Lock)")
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Stop Waiting (Lock). RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
set_rwkv_config(model, global_var.get(global_var.Model_Config))
|
||||
set_rwkv_config(model, body)
|
||||
|
||||
response, prompt_tokens, completion_tokens = "", 0, 0
|
||||
for response, delta, prompt_tokens, completion_tokens in model.generate(
|
||||
prompt,
|
||||
stop=stop,
|
||||
):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
if stream:
|
||||
yield json.dumps(
|
||||
{
|
||||
"object": "chat.completion.chunk"
|
||||
if chat_mode
|
||||
else "text_completion",
|
||||
"response": response,
|
||||
"model": model.name,
|
||||
"choices": [
|
||||
{
|
||||
"delta": {"content": delta},
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": delta,
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
# torch_gc()
|
||||
requests_num = requests_num - 1
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
print(f"{request.client} Stop Waiting")
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nStop Waiting. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nFinished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
if stream:
|
||||
yield json.dumps(
|
||||
{
|
||||
"object": "chat.completion.chunk"
|
||||
if chat_mode
|
||||
else "text_completion",
|
||||
"response": response,
|
||||
"model": model.name,
|
||||
"choices": [
|
||||
{
|
||||
"delta": {},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": "",
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
yield "[DONE]"
|
||||
else:
|
||||
yield {
|
||||
"object": "chat.completion" if chat_mode else "text_completion",
|
||||
"response": response,
|
||||
"model": model.name,
|
||||
"usage": {
|
||||
"prompt_tokens": prompt_tokens,
|
||||
"completion_tokens": completion_tokens,
|
||||
"total_tokens": prompt_tokens + completion_tokens,
|
||||
},
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": response,
|
||||
},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": response,
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@router.post("/v1/chat/completions")
|
||||
@router.post("/chat/completions")
|
||||
async def chat_completions(body: ChatCompletionBody, request: Request):
|
||||
@@ -62,7 +240,8 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
{bot} usually gives {user} kind, helpful and informative advices.\n
|
||||
"""
|
||||
if user == "Bob"
|
||||
else f"{user}{interface} hi\n\n{bot}{interface} Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.\n\n"
|
||||
else f"{user}{interface} hi\n\n{bot}{interface} Hi. "
|
||||
+ "I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.\n\n"
|
||||
)
|
||||
for message in body.messages:
|
||||
if message.role == "system":
|
||||
@@ -108,122 +287,20 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
)
|
||||
completion_text += f"{bot}{interface}"
|
||||
|
||||
async def eval_rwkv():
|
||||
global requests_num
|
||||
requests_num = requests_num + 1
|
||||
quick_log(request, None, "Start Waiting. RequestsNum: " + str(requests_num))
|
||||
while completion_lock.locked():
|
||||
if await request.is_disconnected():
|
||||
requests_num = requests_num - 1
|
||||
quick_log(
|
||||
request, None, "Stop Waiting. RequestsNum: " + str(requests_num)
|
||||
)
|
||||
return
|
||||
await asyncio.sleep(0.1)
|
||||
else:
|
||||
completion_lock.acquire()
|
||||
set_rwkv_config(model, global_var.get(global_var.Model_Config))
|
||||
set_rwkv_config(model, body)
|
||||
if body.stream:
|
||||
for response, delta in model.generate(
|
||||
completion_text,
|
||||
stop=f"\n\n{user}" if body.stop is None else body.stop,
|
||||
):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
yield json.dumps(
|
||||
{
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"delta": {"content": delta},
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
# torch_gc()
|
||||
requests_num = requests_num - 1
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
print(f"{request.client} Stop Waiting")
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nStop Waiting. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nFinished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
yield json.dumps(
|
||||
{
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"delta": {},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
yield "[DONE]"
|
||||
else:
|
||||
response = None
|
||||
for response, delta in model.generate(
|
||||
completion_text,
|
||||
stop=f"\n\n{user}" if body.stop is None else body.stop,
|
||||
):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
# torch_gc()
|
||||
requests_num = requests_num - 1
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nFinished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
return
|
||||
yield {
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": response,
|
||||
},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
stop = f"\n\n{user}" if body.stop is None else body.stop
|
||||
if body.stream:
|
||||
return EventSourceResponse(eval_rwkv())
|
||||
return EventSourceResponse(
|
||||
eval_rwkv(model, request, body, completion_text, body.stream, stop, True)
|
||||
)
|
||||
else:
|
||||
try:
|
||||
return await eval_rwkv().__anext__()
|
||||
return await eval_rwkv(
|
||||
model, request, body, completion_text, body.stream, stop, True
|
||||
).__anext__()
|
||||
except StopAsyncIteration:
|
||||
print(f"{request.client} Stop Waiting")
|
||||
return None
|
||||
|
||||
|
||||
class CompletionBody(ModelConfigBody):
|
||||
prompt: str
|
||||
model: str = "rwkv"
|
||||
stream: bool = False
|
||||
stop: str = None
|
||||
|
||||
|
||||
@router.post("/v1/completions")
|
||||
@router.post("/completions")
|
||||
async def completions(body: CompletionBody, request: Request):
|
||||
@@ -234,101 +311,142 @@ async def completions(body: CompletionBody, request: Request):
|
||||
if body.prompt is None or body.prompt == "":
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "prompt not found")
|
||||
|
||||
async def eval_rwkv():
|
||||
global requests_num
|
||||
requests_num = requests_num + 1
|
||||
quick_log(request, None, "Start Waiting. RequestsNum: " + str(requests_num))
|
||||
while completion_lock.locked():
|
||||
if await request.is_disconnected():
|
||||
requests_num = requests_num - 1
|
||||
quick_log(
|
||||
request, None, "Stop Waiting. RequestsNum: " + str(requests_num)
|
||||
)
|
||||
return
|
||||
await asyncio.sleep(0.1)
|
||||
else:
|
||||
completion_lock.acquire()
|
||||
set_rwkv_config(model, global_var.get(global_var.Model_Config))
|
||||
set_rwkv_config(model, body)
|
||||
if body.stream:
|
||||
for response, delta in model.generate(body.prompt, stop=body.stop):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
yield json.dumps(
|
||||
{
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"text": delta,
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
# torch_gc()
|
||||
requests_num = requests_num - 1
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
print(f"{request.client} Stop Waiting")
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nStop Waiting. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nFinished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
yield json.dumps(
|
||||
{
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"text": "",
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
yield "[DONE]"
|
||||
else:
|
||||
response = None
|
||||
for response, delta in model.generate(body.prompt, stop=body.stop):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
# torch_gc()
|
||||
requests_num = requests_num - 1
|
||||
quick_log(
|
||||
request,
|
||||
body,
|
||||
response + "\nFinished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
return
|
||||
yield {
|
||||
"response": response,
|
||||
"model": "rwkv",
|
||||
"choices": [
|
||||
{
|
||||
"text": response,
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
if body.stream:
|
||||
return EventSourceResponse(eval_rwkv())
|
||||
return EventSourceResponse(
|
||||
eval_rwkv(model, request, body, body.prompt, body.stream, body.stop, False)
|
||||
)
|
||||
else:
|
||||
try:
|
||||
return await eval_rwkv().__anext__()
|
||||
return await eval_rwkv(
|
||||
model, request, body, body.prompt, body.stream, body.stop, False
|
||||
).__anext__()
|
||||
except StopAsyncIteration:
|
||||
print(f"{request.client} Stop Waiting")
|
||||
return None
|
||||
|
||||
|
||||
class EmbeddingsBody(BaseModel):
|
||||
input: str | List[str] | List[List[int]]
|
||||
model: str = "rwkv"
|
||||
encoding_format: str = None
|
||||
fast_mode: bool = False
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"input": "a big apple",
|
||||
"model": "rwkv",
|
||||
"encoding_format": None,
|
||||
"fast_mode": False,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def embedding_base64(embedding: List[float]) -> str:
|
||||
return base64.b64encode(np.array(embedding).astype(np.float32)).decode("utf-8")
|
||||
|
||||
|
||||
@router.post("/v1/embeddings")
|
||||
@router.post("/embeddings")
|
||||
@router.post("/v1/engines/text-embedding-ada-002/embeddings")
|
||||
@router.post("/engines/text-embedding-ada-002/embeddings")
|
||||
async def embeddings(body: EmbeddingsBody, request: Request):
|
||||
model: RWKV = global_var.get(global_var.Model)
|
||||
if model is None:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "model not loaded")
|
||||
|
||||
if body.input is None or body.input == "" or body.input == [] or body.input == [[]]:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "input not found")
|
||||
|
||||
global requests_num
|
||||
requests_num = requests_num + 1
|
||||
quick_log(request, None, "Start Waiting. RequestsNum: " + str(requests_num))
|
||||
while completion_lock.locked():
|
||||
if await request.is_disconnected():
|
||||
requests_num = requests_num - 1
|
||||
print(f"{request.client} Stop Waiting (Lock)")
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Stop Waiting (Lock). RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
await asyncio.sleep(0.1)
|
||||
else:
|
||||
completion_lock.acquire()
|
||||
if await request.is_disconnected():
|
||||
completion_lock.release()
|
||||
requests_num = requests_num - 1
|
||||
print(f"{request.client} Stop Waiting (Lock)")
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Stop Waiting (Lock). RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
|
||||
base64_format = False
|
||||
if body.encoding_format == "base64":
|
||||
base64_format = True
|
||||
|
||||
embeddings = []
|
||||
prompt_tokens = 0
|
||||
if type(body.input) == list:
|
||||
if type(body.input[0]) == list:
|
||||
encoding = tiktoken.model.encoding_for_model("text-embedding-ada-002")
|
||||
for i in range(len(body.input)):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
input = encoding.decode(body.input[i])
|
||||
embedding, token_len = model.get_embedding(input, body.fast_mode)
|
||||
prompt_tokens = prompt_tokens + token_len
|
||||
if base64_format:
|
||||
embedding = embedding_base64(embedding)
|
||||
embeddings.append(embedding)
|
||||
else:
|
||||
for i in range(len(body.input)):
|
||||
if await request.is_disconnected():
|
||||
break
|
||||
embedding, token_len = model.get_embedding(
|
||||
body.input[i], body.fast_mode
|
||||
)
|
||||
prompt_tokens = prompt_tokens + token_len
|
||||
if base64_format:
|
||||
embedding = embedding_base64(embedding)
|
||||
embeddings.append(embedding)
|
||||
else:
|
||||
embedding, prompt_tokens = model.get_embedding(body.input, body.fast_mode)
|
||||
if base64_format:
|
||||
embedding = embedding_base64(embedding)
|
||||
embeddings.append(embedding)
|
||||
|
||||
requests_num = requests_num - 1
|
||||
completion_lock.release()
|
||||
if await request.is_disconnected():
|
||||
print(f"{request.client} Stop Waiting")
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Stop Waiting. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
return
|
||||
quick_log(
|
||||
request,
|
||||
None,
|
||||
"Finished. RequestsNum: " + str(requests_num),
|
||||
)
|
||||
|
||||
ret_data = [
|
||||
{
|
||||
"object": "embedding",
|
||||
"index": i,
|
||||
"embedding": embedding,
|
||||
}
|
||||
for i, embedding in enumerate(embeddings)
|
||||
]
|
||||
|
||||
return {
|
||||
"object": "list",
|
||||
"data": ret_data,
|
||||
"model": model.name,
|
||||
"usage": {"prompt_tokens": prompt_tokens, "total_tokens": prompt_tokens},
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pathlib
|
||||
from utils.log import quick_log
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Response, status as Status
|
||||
from fastapi import APIRouter, HTTPException, Request, Response, status as Status
|
||||
from pydantic import BaseModel
|
||||
from utils.rwkv import *
|
||||
from utils.torch import *
|
||||
@@ -28,9 +29,18 @@ class SwitchModelBody(BaseModel):
|
||||
strategy: str
|
||||
customCuda: bool = False
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"model": "models/RWKV-4-World-3B-v1-20230619-ctx4096.pth",
|
||||
"strategy": "cuda fp16",
|
||||
"customCuda": False,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@router.post("/switch-model")
|
||||
def switch_model(body: SwitchModelBody, response: Response):
|
||||
def switch_model(body: SwitchModelBody, response: Response, request: Request):
|
||||
if global_var.get(global_var.Model_Status) is global_var.ModelStatus.Loading:
|
||||
response.status_code = Status.HTTP_304_NOT_MODIFIED
|
||||
return
|
||||
@@ -39,6 +49,9 @@ def switch_model(body: SwitchModelBody, response: Response):
|
||||
global_var.set(global_var.Model, None)
|
||||
torch_gc()
|
||||
|
||||
if body.model == "":
|
||||
return "success"
|
||||
|
||||
os.environ["RWKV_CUDA_ON"] = "1" if body.customCuda else "0"
|
||||
|
||||
global_var.set(global_var.Model_Status, global_var.ModelStatus.Loading)
|
||||
@@ -53,8 +66,11 @@ def switch_model(body: SwitchModelBody, response: Response):
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
quick_log(request, body, f"Exception: {e}")
|
||||
global_var.set(global_var.Model_Status, global_var.ModelStatus.Offline)
|
||||
raise HTTPException(Status.HTTP_500_INTERNAL_SERVER_ERROR, "failed to load")
|
||||
raise HTTPException(
|
||||
Status.HTTP_500_INTERNAL_SERVER_ERROR, f"failed to load: {e}"
|
||||
)
|
||||
|
||||
if global_var.get(global_var.Model_Config) is None:
|
||||
global_var.set(
|
||||
|
||||
@@ -1,67 +1,92 @@
|
||||
from typing import Any, Dict
|
||||
from fastapi import APIRouter, HTTPException, Response, status
|
||||
from typing import Any, Dict, List
|
||||
from utils.log import quick_log
|
||||
from fastapi import APIRouter, HTTPException, Request, Response, status
|
||||
from pydantic import BaseModel
|
||||
import gc
|
||||
import copy
|
||||
import sys
|
||||
import torch
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
trie = None
|
||||
dtrie: Dict = {}
|
||||
max_trie_len = 3000
|
||||
loop_start_id = 1 # to prevent preloaded prompts from being deleted
|
||||
loop_del_trie_id = loop_start_id
|
||||
|
||||
|
||||
def init():
|
||||
global trie
|
||||
try:
|
||||
import cyac
|
||||
import mmap
|
||||
import os
|
||||
|
||||
if os.path.exists("state_cache.trie"):
|
||||
with open("state_cache.trie", "r") as bf:
|
||||
buff_object = mmap.mmap(bf.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
trie = cyac.Trie.from_buff(buff_object, copy=False)
|
||||
else:
|
||||
trie = cyac.Trie()
|
||||
# import mmap
|
||||
# import os
|
||||
#
|
||||
# if os.path.exists("state_cache.trie"):
|
||||
# with open("state_cache.trie", "r") as bf:
|
||||
# buff_object = mmap.mmap(bf.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
# trie = cyac.Trie.from_buff(buff_object, copy=False)
|
||||
# else:
|
||||
trie = cyac.Trie()
|
||||
except ModuleNotFoundError:
|
||||
print("cyac not found")
|
||||
|
||||
|
||||
class AddStateBody(BaseModel):
|
||||
prompt: str
|
||||
tokens: list[str]
|
||||
tokens: List[str]
|
||||
state: Any
|
||||
logits: Any
|
||||
|
||||
|
||||
@router.post("/add-state")
|
||||
def add_state(body: AddStateBody):
|
||||
global trie, dtrie
|
||||
global trie, dtrie, loop_del_trie_id
|
||||
if trie is None:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||
|
||||
id = trie.insert(body.prompt)
|
||||
device = body.state[0].device
|
||||
dtrie[id] = {
|
||||
"tokens": copy.deepcopy(body.tokens),
|
||||
"state": [tensor.cpu() for tensor in body.state]
|
||||
if device != torch.device("cpu")
|
||||
else copy.deepcopy(body.state),
|
||||
"logits": copy.deepcopy(body.logits),
|
||||
"device": device,
|
||||
}
|
||||
try:
|
||||
id: int = trie.insert(body.prompt)
|
||||
device: torch.device = body.state[0].device
|
||||
dtrie[id] = {
|
||||
"tokens": copy.deepcopy(body.tokens),
|
||||
"state": [tensor.cpu() for tensor in body.state]
|
||||
if device != torch.device("cpu")
|
||||
else copy.deepcopy(body.state),
|
||||
"logits": copy.deepcopy(body.logits),
|
||||
"device": device,
|
||||
}
|
||||
|
||||
return "success"
|
||||
if len(trie) >= max_trie_len:
|
||||
del_prompt = trie[loop_del_trie_id]
|
||||
trie.remove(del_prompt)
|
||||
dtrie[loop_del_trie_id] = None
|
||||
loop_del_trie_id = loop_del_trie_id + 1
|
||||
if loop_del_trie_id >= max_trie_len:
|
||||
loop_del_trie_id = loop_start_id
|
||||
|
||||
quick_log(
|
||||
None,
|
||||
None,
|
||||
f"New Trie Id: {id}\nTrie Len: {len(trie)}\nTrie Buff Size: {trie.buff_size()}\nDtrie Buff Size Of Id: {_get_a_dtrie_buff_size(dtrie[id])}",
|
||||
)
|
||||
return "success"
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status.HTTP_400_BAD_REQUEST, f"insert failed, bad prompt.\n{e}"
|
||||
)
|
||||
|
||||
|
||||
@router.post("/reset-state")
|
||||
def reset_state():
|
||||
global trie
|
||||
global trie, dtrie
|
||||
if trie is None:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||
|
||||
trie = cyac.Trie()
|
||||
dtrie = {}
|
||||
gc.collect()
|
||||
|
||||
return "success"
|
||||
@@ -71,29 +96,58 @@ class LongestPrefixStateBody(BaseModel):
|
||||
prompt: str
|
||||
|
||||
|
||||
def _get_a_dtrie_buff_size(dtrie_v):
|
||||
# print(sys.getsizeof(dtrie_v["tokens"][0])) # str
|
||||
# print(sys.getsizeof(dtrie_v["tokens"][0]) * len(dtrie_v["tokens"]))
|
||||
# print(dtrie_v["state"][0][0].element_size())
|
||||
# print(dtrie_v["state"][0].nelement())
|
||||
# print(len(dtrie_v["state"]))
|
||||
# print(
|
||||
# len(dtrie_v["state"])
|
||||
# * dtrie_v["state"][0].nelement()
|
||||
# * dtrie_v["state"][0][0].element_size()
|
||||
# )
|
||||
# print(dtrie_v["logits"][0].element_size())
|
||||
# print(dtrie_v["logits"].nelement())
|
||||
# print(dtrie_v["logits"][0].element_size() * dtrie_v["logits"].nelement())
|
||||
return 54 * len(dtrie_v["tokens"]) + 491520 + 262144 + 28 # TODO
|
||||
|
||||
|
||||
@router.post("/longest-prefix-state")
|
||||
def longest_prefix_state(body: LongestPrefixStateBody):
|
||||
def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
|
||||
global trie
|
||||
if trie is None:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||
|
||||
id = -1
|
||||
for id, len in trie.prefix(body.prompt):
|
||||
try:
|
||||
for id, len in trie.prefix(body.prompt):
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
if id != -1:
|
||||
v = dtrie[id]
|
||||
device = v["device"]
|
||||
device: torch.device = v["device"]
|
||||
prompt: str = trie[id]
|
||||
|
||||
quick_log(request, body, "Hit:\n" + prompt)
|
||||
return {
|
||||
"prompt": trie[id],
|
||||
"prompt": prompt,
|
||||
"tokens": v["tokens"],
|
||||
"state": [tensor.to(device) for tensor in v["state"]]
|
||||
if device != torch.device("cpu")
|
||||
else v["state"],
|
||||
"logits": v["logits"],
|
||||
"device": device,
|
||||
"device": device.type,
|
||||
}
|
||||
else:
|
||||
return {"prompt": "", "tokens": [], "state": None, "logits": None}
|
||||
return {
|
||||
"prompt": "",
|
||||
"tokens": [],
|
||||
"state": None,
|
||||
"logits": None,
|
||||
"device": None,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/save-state")
|
||||
@@ -102,6 +156,6 @@ def save_state():
|
||||
if trie is None:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||
|
||||
trie.save("state_cache.trie")
|
||||
# trie.save("state_cache.trie")
|
||||
|
||||
return "success"
|
||||
return "not implemented"
|
||||
|
||||
4
backend-python/rwkv_pip/rwkv_tokenizer.py
vendored
@@ -72,9 +72,9 @@ class TRIE_TOKENIZER:
|
||||
for t, i in self.token2idx.items():
|
||||
_ = self.root.add(t, val=(t, i))
|
||||
|
||||
def encodeBytes(self, src: bytes) -> list[int]:
|
||||
def encodeBytes(self, src: bytes):
|
||||
idx: int = 0
|
||||
tokens: list[int] = []
|
||||
tokens = []
|
||||
while idx < len(src):
|
||||
_idx: int = idx
|
||||
idx, _, values = self.root.find_longest(src, idx)
|
||||
|
||||
@@ -15,18 +15,24 @@ logger.addHandler(fh)
|
||||
|
||||
|
||||
def quick_log(request: Request, body: Any, response: str):
|
||||
logger.info(
|
||||
f"Client: {request.client}\nUrl: {request.url}\n"
|
||||
+ (
|
||||
f"Body: {json.dumps(body.__dict__, default=vars, ensure_ascii=False)}\n"
|
||||
if body
|
||||
else ""
|
||||
try:
|
||||
logger.info(
|
||||
f"Client: {request.client if request else ''}\nUrl: {request.url if request else ''}\n"
|
||||
+ (
|
||||
f"Body: {json.dumps(body.__dict__, default=vars, ensure_ascii=False)}\n"
|
||||
if body
|
||||
else ""
|
||||
)
|
||||
+ (f"Data:\n{response}\n" if response else "")
|
||||
)
|
||||
+ (f"Response:\n{response}\n" if response else "")
|
||||
)
|
||||
except Exception as e:
|
||||
logger.info(f"Error quick_log request:\n{e}")
|
||||
|
||||
|
||||
async def log_middleware(request: Request):
|
||||
logger.info(
|
||||
f"Client: {request.client}\nUrl: {request.url}\nBody: {await request.body()}\n"
|
||||
)
|
||||
try:
|
||||
logger.info(
|
||||
f"Client: {request.client}\nUrl: {request.url}\nBody: {await request.body()}\n"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.info(f"Error log_middleware request:\n{e}")
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import os
|
||||
import pathlib
|
||||
import copy
|
||||
from typing import Dict, List
|
||||
from typing import Dict, List, Tuple
|
||||
from utils.log import quick_log
|
||||
from fastapi import HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
import torch
|
||||
import numpy as np
|
||||
from rwkv_pip.utils import PIPELINE
|
||||
from routes import state_cache
|
||||
|
||||
@@ -20,6 +23,8 @@ class RWKV:
|
||||
def __init__(self, model: str, strategy: str, tokens_path: str) -> None:
|
||||
from rwkv.model import RWKV as Model # dynamic import to make RWKV_CUDA_ON work
|
||||
|
||||
filename, _ = os.path.splitext(os.path.basename(model))
|
||||
self.name = filename
|
||||
self.model = Model(model, strategy)
|
||||
self.pipeline = PIPELINE(self.model, tokens_path)
|
||||
self.model_state = None
|
||||
@@ -63,9 +68,10 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
{bot} usually gives {user} kind, helpful and informative advices.\n
|
||||
"""
|
||||
if self.user == "Bob"
|
||||
else f"{user}{interface} hi\n\n{bot}{interface} Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.\n\n"
|
||||
else f"{user}{interface} hi\n\n{bot}{interface} Hi. "
|
||||
+ "I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.\n\n"
|
||||
)
|
||||
logits = self.run_rnn(self.fix_tokens(self.pipeline.encode(preset_system)))
|
||||
logits, _ = self.run_rnn(self.fix_tokens(self.pipeline.encode(preset_system)))
|
||||
try:
|
||||
state_cache.add_state(
|
||||
state_cache.AddStateBody(
|
||||
@@ -86,6 +92,7 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
|
||||
def run_rnn(self, _tokens: List[str], newline_adj: int = 0):
|
||||
tokens = [int(x) for x in _tokens]
|
||||
token_len = len(tokens)
|
||||
self.model_tokens += tokens
|
||||
|
||||
while len(tokens) > 0:
|
||||
@@ -98,14 +105,165 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
|
||||
if self.model_tokens[-1] in self.AVOID_REPEAT_TOKENS:
|
||||
out[self.model_tokens[-1]] = -999999999
|
||||
return out
|
||||
return out, token_len
|
||||
|
||||
def get_embedding(self, input: str, fast_mode: bool) -> Tuple[List[float], int]:
|
||||
if fast_mode:
|
||||
embedding, token_len = self.fast_embedding(
|
||||
self.fix_tokens(self.pipeline.encode(input)), None
|
||||
)
|
||||
else:
|
||||
self.model_state = None
|
||||
self.model_tokens = []
|
||||
_, token_len = self.run_rnn(self.fix_tokens(self.pipeline.encode(input)))
|
||||
embedding = self.model_state[-5].tolist()
|
||||
embedding = (embedding / np.linalg.norm(embedding)).tolist()
|
||||
return embedding, token_len
|
||||
|
||||
def fast_embedding(self, tokens: List[str], state):
|
||||
tokens = [int(x) for x in tokens]
|
||||
token_len = len(tokens)
|
||||
self = self.model
|
||||
|
||||
with torch.no_grad():
|
||||
w = self.w
|
||||
args = self.args
|
||||
|
||||
if state == None:
|
||||
state = [None] * args.n_layer * 5
|
||||
for i in range(
|
||||
args.n_layer
|
||||
): # state: 0=att_xx 1=att_aa 2=att_bb 3=att_pp 4=ffn_xx
|
||||
dd = self.strategy[i]
|
||||
dev = dd.device
|
||||
atype = dd.atype
|
||||
state[i * 5 + 0] = torch.zeros(
|
||||
args.n_embd, dtype=atype, requires_grad=False, device=dev
|
||||
).contiguous()
|
||||
state[i * 5 + 1] = torch.zeros(
|
||||
args.n_embd, dtype=torch.float, requires_grad=False, device=dev
|
||||
).contiguous()
|
||||
state[i * 5 + 2] = torch.zeros(
|
||||
args.n_embd, dtype=torch.float, requires_grad=False, device=dev
|
||||
).contiguous()
|
||||
state[i * 5 + 3] = (
|
||||
torch.zeros(
|
||||
args.n_embd,
|
||||
dtype=torch.float,
|
||||
requires_grad=False,
|
||||
device=dev,
|
||||
).contiguous()
|
||||
- 1e30
|
||||
)
|
||||
state[i * 5 + 4] = torch.zeros(
|
||||
args.n_embd, dtype=atype, requires_grad=False, device=dev
|
||||
).contiguous()
|
||||
|
||||
break
|
||||
|
||||
seq_mode = len(tokens) > 1
|
||||
|
||||
x = w["emb.weight"][tokens if seq_mode else tokens[0]]
|
||||
|
||||
for i in range(args.n_layer):
|
||||
bbb = f"blocks.{i}."
|
||||
att = f"blocks.{i}.att."
|
||||
ffn = f"blocks.{i}.ffn."
|
||||
dd = self.strategy[i]
|
||||
dev = dd.device
|
||||
atype = dd.atype
|
||||
wtype = dd.wtype
|
||||
if seq_mode:
|
||||
if "cuda" in str(dev) and os.environ["RWKV_CUDA_ON"] == "1":
|
||||
ATT = (
|
||||
self.cuda_att_seq
|
||||
if wtype != torch.uint8
|
||||
else self.cuda_att_seq_i8
|
||||
)
|
||||
else:
|
||||
ATT = self.att_seq if wtype != torch.uint8 else self.att_seq_i8
|
||||
FFN = self.ffn_seq if wtype != torch.uint8 else self.ffn_seq_i8
|
||||
else:
|
||||
ATT = self.att_one if wtype != torch.uint8 else self.att_one_i8
|
||||
FFN = self.ffn_one if wtype != torch.uint8 else self.ffn_one_i8
|
||||
|
||||
x = x.to(dtype=atype, device=dev)
|
||||
|
||||
kw = w[f"{att}key.weight"]
|
||||
vw = w[f"{att}value.weight"]
|
||||
rw = w[f"{att}receptance.weight"]
|
||||
ow = w[f"{att}output.weight"]
|
||||
if dd.stream:
|
||||
kw = kw.to(device=dev, non_blocking=True)
|
||||
vw = vw.to(device=dev, non_blocking=True)
|
||||
rw = rw.to(device=dev, non_blocking=True)
|
||||
ow = ow.to(device=dev, non_blocking=True)
|
||||
kmx = w[f"{att}key.weight_mx"] if wtype == torch.uint8 else x
|
||||
krx = w[f"{att}key.weight_rx"] if wtype == torch.uint8 else x
|
||||
kmy = w[f"{att}key.weight_my"] if wtype == torch.uint8 else x
|
||||
kry = w[f"{att}key.weight_ry"] if wtype == torch.uint8 else x
|
||||
vmx = w[f"{att}value.weight_mx"] if wtype == torch.uint8 else x
|
||||
vrx = w[f"{att}value.weight_rx"] if wtype == torch.uint8 else x
|
||||
vmy = w[f"{att}value.weight_my"] if wtype == torch.uint8 else x
|
||||
vry = w[f"{att}value.weight_ry"] if wtype == torch.uint8 else x
|
||||
rmx = w[f"{att}receptance.weight_mx"] if wtype == torch.uint8 else x
|
||||
rrx = w[f"{att}receptance.weight_rx"] if wtype == torch.uint8 else x
|
||||
rmy = w[f"{att}receptance.weight_my"] if wtype == torch.uint8 else x
|
||||
rry = w[f"{att}receptance.weight_ry"] if wtype == torch.uint8 else x
|
||||
omx = w[f"{att}output.weight_mx"] if wtype == torch.uint8 else x
|
||||
orx = w[f"{att}output.weight_rx"] if wtype == torch.uint8 else x
|
||||
omy = w[f"{att}output.weight_my"] if wtype == torch.uint8 else x
|
||||
ory = w[f"{att}output.weight_ry"] if wtype == torch.uint8 else x
|
||||
(
|
||||
x,
|
||||
state[i * 5 + 0],
|
||||
state[i * 5 + 1],
|
||||
state[i * 5 + 2],
|
||||
state[i * 5 + 3],
|
||||
) = ATT(
|
||||
x,
|
||||
state[i * 5 + 0],
|
||||
state[i * 5 + 1],
|
||||
state[i * 5 + 2],
|
||||
state[i * 5 + 3],
|
||||
w[f"{bbb}ln1.weight"],
|
||||
w[f"{bbb}ln1.bias"],
|
||||
w[f"{att}time_mix_k"],
|
||||
w[f"{att}time_mix_v"],
|
||||
w[f"{att}time_mix_r"],
|
||||
w[f"{att}time_decay"],
|
||||
w[f"{att}time_first"],
|
||||
kw,
|
||||
vw,
|
||||
rw,
|
||||
ow,
|
||||
kmx,
|
||||
krx,
|
||||
kmy,
|
||||
kry,
|
||||
vmx,
|
||||
vrx,
|
||||
vmy,
|
||||
vry,
|
||||
rmx,
|
||||
rrx,
|
||||
rmy,
|
||||
rry,
|
||||
omx,
|
||||
orx,
|
||||
omy,
|
||||
ory,
|
||||
)
|
||||
|
||||
return state[0].tolist(), token_len
|
||||
|
||||
def generate(self, prompt: str, stop: str = None):
|
||||
quick_log(None, None, "Generation Prompt:\n" + prompt)
|
||||
cache = None
|
||||
delta_prompt = prompt
|
||||
try:
|
||||
cache = state_cache.longest_prefix_state(
|
||||
state_cache.LongestPrefixStateBody(prompt=prompt)
|
||||
state_cache.LongestPrefixStateBody(prompt=prompt), None
|
||||
)
|
||||
except HTTPException:
|
||||
pass
|
||||
@@ -118,8 +276,11 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
self.model_tokens = copy.deepcopy(cache["tokens"])
|
||||
logits = copy.deepcopy(cache["logits"])
|
||||
|
||||
prompt_token_len = 0
|
||||
if delta_prompt != "":
|
||||
logits = self.run_rnn(self.fix_tokens(self.pipeline.encode(delta_prompt)))
|
||||
logits, prompt_token_len = self.run_rnn(
|
||||
self.fix_tokens(self.pipeline.encode(delta_prompt))
|
||||
)
|
||||
try:
|
||||
state_cache.add_state(
|
||||
state_cache.AddStateBody(
|
||||
@@ -137,6 +298,7 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
|
||||
occurrence: Dict = {}
|
||||
|
||||
completion_token_len = 0
|
||||
response = ""
|
||||
for i in range(self.max_tokens_per_generation):
|
||||
for n in occurrence:
|
||||
@@ -149,14 +311,15 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
)
|
||||
|
||||
if token == END_OF_TEXT:
|
||||
yield response, ""
|
||||
yield response, "", prompt_token_len, completion_token_len
|
||||
break
|
||||
if token not in occurrence:
|
||||
occurrence[token] = 1
|
||||
else:
|
||||
occurrence[token] += 1
|
||||
|
||||
logits = self.run_rnn([token])
|
||||
logits, _ = self.run_rnn([token])
|
||||
completion_token_len = completion_token_len + 1
|
||||
delta: str = self.pipeline.decode(self.model_tokens[out_last:])
|
||||
if "\ufffd" not in delta: # avoid utf-8 display issues
|
||||
response += delta
|
||||
@@ -174,7 +337,7 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
)
|
||||
except HTTPException:
|
||||
pass
|
||||
yield response, ""
|
||||
yield response, "", prompt_token_len, completion_token_len
|
||||
break
|
||||
out_last = begin + i + 1
|
||||
if i == self.max_tokens_per_generation - 1:
|
||||
@@ -189,7 +352,7 @@ The following is a coherent verbose detailed conversation between a girl named {
|
||||
)
|
||||
except HTTPException:
|
||||
pass
|
||||
yield response, delta
|
||||
yield response, delta, prompt_token_len, completion_token_len
|
||||
|
||||
|
||||
class ModelConfigBody(BaseModel):
|
||||
@@ -199,12 +362,26 @@ class ModelConfigBody(BaseModel):
|
||||
presence_penalty: float = Field(default=None, ge=-2, le=2)
|
||||
frequency_penalty: float = Field(default=None, ge=-2, le=2)
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"max_tokens": 1000,
|
||||
"temperature": 1.2,
|
||||
"top_p": 0.5,
|
||||
"presence_penalty": 0.4,
|
||||
"frequency_penalty": 0.4,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def set_rwkv_config(model: RWKV, body: ModelConfigBody):
|
||||
if body.max_tokens is not None:
|
||||
model.max_tokens_per_generation = body.max_tokens
|
||||
if body.temperature is not None:
|
||||
model.temperature = body.temperature
|
||||
if body.temperature < 0.1:
|
||||
model.temperature = 0.1
|
||||
else:
|
||||
model.temperature = body.temperature
|
||||
if body.top_p is not None:
|
||||
model.top_p = body.top_p
|
||||
if body.presence_penalty is not None:
|
||||
|
||||
BIN
build/appicon.png
vendored
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 120 KiB |
2
build/darwin/Info.dev.plist
vendored
@@ -8,7 +8,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wails.{{.Name}}</string>
|
||||
<string>dev.josStorer.RWKV-Runner</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
|
||||
2
build/darwin/Info.plist
vendored
@@ -8,7 +8,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wails.{{.Name}}</string>
|
||||
<string>dev.josStorer.RWKV-Runner</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
|
||||
13
build/darwin/Readme_Install.txt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings.
|
||||
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器.
|
||||
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。
|
||||
|
||||
Please execute this program in an empty directory. All related dependencies will be placed in this directory.
|
||||
请将本程序放在一个空目录内执行, 所有相关依赖均会放置于此目录.
|
||||
このプログラムを空のディレクトリで実行してください。関連するすべての依存関係は、このディレクトリに配置されます。
|
||||
|
||||
Please execute the following command in the terminal to remove the permission restrictions of this app, and then this program can work properly:
|
||||
请在终端执行以下命令解除本app的权限限制, 然后本程序才可以正常工作:
|
||||
このアプリの権限制限を解除するために、ターミナルで以下のコマンドを実行してください。その後、このプログラムは正常に動作するようになります:
|
||||
|
||||
sudo xattr -r -d com.apple.quarantine ./RWKV-Runner.app
|
||||
16
build/darwin/entitlements.plist
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<false/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.downloads.read-write</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
17
build/darwin/gon-sign.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"source": [
|
||||
"./build/bin/RWKV-Runner_darwin.app"
|
||||
],
|
||||
"bundle_id": "dev.josStorer.RWKV-Runner",
|
||||
"apple_id": {
|
||||
"username": "joshua1466587594@outlook.com",
|
||||
"password": ""
|
||||
},
|
||||
"sign": {
|
||||
"application_identity": "D00A983569B4EAA2A008B963254F385F42A493FD",
|
||||
"entitlements_file": "./build/darwin/entitlements.plist"
|
||||
},
|
||||
"zip": {
|
||||
"output_path": "./build/bin/RWKV-Runner_darwin.archive.zip"
|
||||
}
|
||||
}
|
||||
19
build/linux/Readme_Install.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings.
|
||||
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器.
|
||||
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。
|
||||
|
||||
Please execute this program in an empty directory. All related dependencies will be placed in this directory.
|
||||
请将本程序放在一个空目录内执行, 所有相关依赖均会放置于此目录.
|
||||
このプログラムを空のディレクトリで実行してください。関連するすべての依存関係は、このディレクトリに配置されます。
|
||||
|
||||
On Linux system, this program cannot invoke the terminal for automatic dependency installation. You must manually execute the following commands for installation so that it can be used normally:
|
||||
在Linux系统下, 本程序无法调用终端自动安装依赖, 你必须手动执行以下命令进行安装, 之后方可正常使用:
|
||||
Linuxシステムでは、このプログラムはターミナルを自動的に呼び出して依存関係をインストールすることができません。以下のコマンドを手動で実行する必要があります。それが完了した後に、正常に使用することができます:
|
||||
|
||||
sudo apt install python3-dev
|
||||
chmod +x ./RWKV-Runner
|
||||
./RWKV-Runner
|
||||
cd backend-python
|
||||
pip3 install -r requirements.txt # or pip3 install -r requirements_without_cyac.txt
|
||||
|
||||
# See More: https://github.com/josStorer/RWKV-Runner/tree/master/deploy-examples
|
||||
3
build/windows/Readme_Install.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Please execute this program in an empty directory. All related dependencies will be placed in this directory.
|
||||
请将本程序放在一个空目录内执行, 所有相关依赖均会放置于此目录.
|
||||
このプログラムを空のディレクトリで実行してください。関連するすべての依存関係は、このディレクトリに配置されます。
|
||||
BIN
build/windows/icon.ico
vendored
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 167 KiB |
24
deploy-examples/ChatGPT-Next-Web/setup.bat
Normal file
@@ -0,0 +1,24 @@
|
||||
: install git python3.10 yarn by yourself
|
||||
: change model and strategy according to your hardware
|
||||
|
||||
mkdir RWKV-Next-Web
|
||||
cd RWKV-Next-Web
|
||||
|
||||
git clone https://github.com/josStorer/RWKV-Runner --depth=1
|
||||
python -m pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cu117
|
||||
python -m pip install -r RWKV-Runner/backend-python/requirements.txt
|
||||
start python ./RWKV-Runner/backend-python/main.py
|
||||
|
||||
powershell -Command "(Test-Path ./RWKV-Runner/models) -or (mkdir RWKV-Runner/models)"
|
||||
powershell -Command "Import-Module BitsTransfer"
|
||||
powershell -Command "(Test-Path ./RWKV-Runner/models/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth) -or (Start-BitsTransfer https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth ./RWKV-Runner/models/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth)"
|
||||
powershell -Command "Invoke-WebRequest http://127.0.0.1:8000/switch-model -Method POST -ContentType 'application/json' -Body '{\"model\":\"./RWKV-Runner/models/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth\",\"strategy\":\"cuda fp32 *20+\"}'"
|
||||
|
||||
git clone https://github.com/Yidadaa/ChatGPT-Next-Web --depth=1
|
||||
cd ChatGPT-Next-Web
|
||||
call yarn install
|
||||
call yarn build
|
||||
set PROXY_URL=""
|
||||
set BASE_URL=http://127.0.0.1:8000
|
||||
start "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "http://127.0.0.1:3000"
|
||||
yarn start
|
||||
27
deploy-examples/ChatGPT-Next-Web/setup.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
# install git python3.10 yarn by yourself
|
||||
# change model and strategy according to your hardware
|
||||
|
||||
sudo apt install python3-dev
|
||||
|
||||
mkdir RWKV-Next-Web
|
||||
cd RWKV-Next-Web
|
||||
|
||||
git clone https://github.com/josStorer/RWKV-Runner --depth=1
|
||||
python3 -m pip install torch torchvision torchaudio
|
||||
python3 -m pip install -r RWKV-Runner/backend-python/requirements.txt
|
||||
python3 ./RWKV-Runner/backend-python/main.py > log.txt &
|
||||
|
||||
if [ ! -d RWKV-Runner/models ]; then
|
||||
mkdir RWKV-Runner/models
|
||||
fi
|
||||
wget -N https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth -P RWKV-Runner/models/
|
||||
|
||||
git clone https://github.com/Yidadaa/ChatGPT-Next-Web --depth=1
|
||||
cd ChatGPT-Next-Web
|
||||
yarn install
|
||||
yarn build
|
||||
export PROXY_URL=""
|
||||
export BASE_URL=http://127.0.0.1:8000
|
||||
yarn start &
|
||||
|
||||
curl http://127.0.0.1:8000/switch-model -X POST -H "Content-Type: application/json" -d '{"model":"./RWKV-Runner/models/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth","strategy":"cpu fp32"}'
|
||||
@@ -16,7 +16,7 @@
|
||||
"Stored Layers": "载入显存层数",
|
||||
"Precision": "精度",
|
||||
"Device": "设备",
|
||||
"Convert model with these configs": "用这些设置转换模型",
|
||||
"Convert model with these configs. Using a converted model will greatly improve the loading speed, but model parameters of the converted model cannot be modified.": "用这些设置转换模型. 使用转换过的模型能大大提升载入速度, 但是转换后的模型无法再修改模型参数.",
|
||||
"Manage Models": "管理模型",
|
||||
"Model": "模型",
|
||||
"Model Parameters": "模型参数",
|
||||
@@ -70,7 +70,7 @@
|
||||
"Type your message here": "在此输入消息",
|
||||
"Copy": "复制",
|
||||
"Read Aloud": "朗读",
|
||||
"Hello! I'm RWKV, an open-source and commercially available large language model.": "你好! 我是RWKV, 一个开源可商用的大语言模型.",
|
||||
"Hello! I'm RWKV, an open-source and commercially usable large language model.": "你好! 我是RWKV, 一个开源可商用的大语言模型.",
|
||||
"This tool's API is compatible with OpenAI API. It can be used with any ChatGPT tool you like. Go to the settings of some ChatGPT tool, replace the 'https://api.openai.com' part in the API address with '": "本工具的API与OpenAI API兼容. 因此可以配合任意你喜欢的ChatGPT工具使用. 打开某个ChatGPT工具的设置, 将API地址中的'https://api.openai.com'部分替换为'",
|
||||
"New Version Available": "新版本可用",
|
||||
"Update": "更新",
|
||||
@@ -78,16 +78,17 @@
|
||||
"Update Error": "更新出错",
|
||||
"Open the following URL with your browser to view the API documentation": "使用浏览器打开以下地址查看API文档",
|
||||
"By default, the maximum number of tokens that can be answered in a single response, it can be changed by the user by specifying API parameters.": "默认情况下, 单个回复最多回答的token数目, 用户可以通过自行指定API参数改变这个值",
|
||||
"Sampling temperature, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.": "采样温度, 越大随机性越强, 更具创造力, 越小则越保守稳定",
|
||||
"Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.": "考虑前 n% 概率质量的结果, 0.1 考虑前 10%, 质量更高, 但更保守, 1 考虑所有质量结果, 质量降低, 但更多样",
|
||||
"Sampling temperature, it's like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.": "采样温度, 就像给模型喝酒, 越大随机性越强, 更具创造力, 越小则越保守稳定",
|
||||
"Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.": "就像给模型喂镇静剂. 考虑前 n% 概率质量的结果, 0.1 考虑前 10%, 质量更高, 但更保守, 1 考虑所有质量结果, 质量降低, 但更多样",
|
||||
"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.": "存在惩罚. 正值根据新token在至今的文本中是否出现过, 来对其进行惩罚, 从而增加了模型涉及新话题的可能性",
|
||||
"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.": "频率惩罚. 正值根据新token在至今的文本中出现的频率/次数, 来对其进行惩罚, 从而减少模型原封不动地重复相同句子的可能性",
|
||||
"int8 uses less VRAM, but has slightly lower quality. fp16 has higher quality, and fp32 has the best quality.": "int8占用显存更低, 但质量略微下降. fp16质量更好, fp32质量最好",
|
||||
"Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM.": "载入显存的神经网络层数, 载入越多, 速度越快, 但显存消耗越大",
|
||||
"Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM. (If your VRAM is not enough, it will fail to load)": "载入显存的神经网络层数, 载入越多, 速度越快, 但显存消耗越大 (如果你的显存不够, 会载入失败)",
|
||||
"Whether to use CPU to calculate the last output layer of the neural network with FP32 precision to obtain better quality.": "是否使用cpu以fp32精度计算神经网络的最后一层输出层, 以获得更好的质量",
|
||||
"Downloads": "下载",
|
||||
"Pause": "暂停",
|
||||
"Continue": "继续",
|
||||
"Resume": "继续",
|
||||
"Check": "查看",
|
||||
"Model file not found": "模型文件不存在",
|
||||
"Can not find download url": "找不到下载地址",
|
||||
@@ -99,7 +100,7 @@
|
||||
"Model Config Exception": "模型配置异常",
|
||||
"Use Gitee Updates Source": "使用Gitee更新源",
|
||||
"Use Custom CUDA kernel to Accelerate": "使用自定义CUDA算子加速",
|
||||
"Enabling this option can greatly improve inference speed, but there may be compatibility issues. If it fails to start, please turn off this option.": "开启这个选项能大大提升推理速度,但可能存在兼容性问题,如果启动失败,请关闭此选项",
|
||||
"Enabling this option can greatly improve inference speed and save some VRAM, but there may be compatibility issues. If it fails to start, please turn off this option.": "开启这个选项能大大提升推理速度并节省显存,但可能存在兼容性问题,如果启动失败,请关闭此选项",
|
||||
"Supported custom cuda file not found": "没有找到支持的自定义cuda文件",
|
||||
"Failed to copy custom cuda file": "自定义cuda文件复制失败",
|
||||
"Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.": "正在下载更新,请等待。如果一直未完成,请从Github手动下载并覆盖原程序",
|
||||
@@ -134,8 +135,24 @@
|
||||
"Advanced": "高级",
|
||||
"Custom Python Path": "自定义Python路径",
|
||||
"Custom Models Path": "自定义模型路径",
|
||||
"MacOS is not supported yet, please convert manually.": "暂不支持MacOS, 请手动转换",
|
||||
"Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?",
|
||||
"Path Cannot Contain Space": "路径不能包含空格",
|
||||
"Failed to switch model, please try starting the program with administrator privileges.": "切换模型失败, 请尝试以管理员权限启动程序"
|
||||
"File Path Cannot Contain Space": "文件路径不能包含空格",
|
||||
"Current Strategy": "当前Strategy",
|
||||
"MacOS is not yet supported for performing this operation, please do it manually.": "MacOS尚未支持此操作, 请手动执行",
|
||||
"Linux is not yet supported for performing this operation, please do it manually.": "Linux尚未支持此操作, 请手动执行",
|
||||
"On Linux system, you must manually install python dependencies.": "在Linux系统下, 你必须手动安装python依赖",
|
||||
"Update completed, please restart the program.": "更新完成, 请重启程序",
|
||||
"Are you sure you want to reset this page? It cannot be undone.": "你确定要重置本页吗?这无法撤销",
|
||||
"Model file download is not complete": "模型文件下载未完成",
|
||||
"Error": "错误",
|
||||
"Are you sure you want to clear the conversation? It cannot be undone.": "你确定要清空对话吗?这无法撤销",
|
||||
"Save": "保存",
|
||||
"Conversation Saved": "对话已保存",
|
||||
"Open": "打开",
|
||||
"DPI Scaling": "显示缩放",
|
||||
"Restart the app to apply DPI Scaling.": "重启应用以使显示缩放生效",
|
||||
"Restart": "重启",
|
||||
"API Chat Model Name": "API聊天模型名",
|
||||
"API Completion Model Name": "API补全模型名",
|
||||
"Localhost": "本地"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
frontend/src/assets/images/strategy.jpg
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
frontend/src/assets/images/strategy_zh.jpg
Normal file
|
After Width: | Height: | Size: 115 KiB |
58
frontend/src/components/DialogButton.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import { FC, ReactElement } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogBody,
|
||||
DialogContent,
|
||||
DialogSurface,
|
||||
DialogTitle,
|
||||
DialogTrigger
|
||||
} from '@fluentui/react-components';
|
||||
import { ToolTipButton } from './ToolTipButton';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const DialogButton: FC<{
|
||||
text?: string | null
|
||||
icon?: ReactElement,
|
||||
tooltip?: string | null,
|
||||
className?: string,
|
||||
title: string,
|
||||
contentText: string,
|
||||
onConfirm: () => void,
|
||||
size?: 'small' | 'medium' | 'large',
|
||||
shape?: 'rounded' | 'circular' | 'square',
|
||||
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent',
|
||||
}> = ({
|
||||
text, icon, tooltip, className, title, contentText,
|
||||
onConfirm, size, shape, appearance
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <Dialog>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
{tooltip ?
|
||||
<ToolTipButton className={className} desc={tooltip} text={text} icon={icon} size={size} shape={shape}
|
||||
appearance={appearance} /> :
|
||||
<Button className={className} icon={icon} size={size} shape={shape} appearance={appearance}>{text}</Button>
|
||||
}
|
||||
</DialogTrigger>
|
||||
<DialogSurface>
|
||||
<DialogBody>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogContent>
|
||||
{contentText}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="secondary">{t('Cancel')}</Button>
|
||||
</DialogTrigger>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="primary" onClick={onConfirm}>{t('Confirm')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
</DialogActions>
|
||||
</DialogBody>
|
||||
</DialogSurface>
|
||||
</Dialog>;
|
||||
};
|
||||
@@ -5,17 +5,23 @@ import classnames from 'classnames';
|
||||
export const Labeled: FC<{
|
||||
label: string;
|
||||
desc?: string | null,
|
||||
descComponent?: ReactElement,
|
||||
content: ReactElement,
|
||||
flex?: boolean,
|
||||
spaceBetween?: boolean,
|
||||
breakline?: boolean
|
||||
breakline?: boolean,
|
||||
onMouseEnter?: () => void
|
||||
onMouseLeave?: () => void
|
||||
}> = ({
|
||||
label,
|
||||
desc,
|
||||
descComponent,
|
||||
content,
|
||||
flex,
|
||||
spaceBetween,
|
||||
breakline
|
||||
breakline,
|
||||
onMouseEnter,
|
||||
onMouseLeave
|
||||
}) => {
|
||||
return (
|
||||
<div className={classnames(
|
||||
@@ -24,11 +30,11 @@ export const Labeled: FC<{
|
||||
breakline ? 'flex-col' : '',
|
||||
spaceBetween && 'justify-between')
|
||||
}>
|
||||
{desc ?
|
||||
<Tooltip content={desc} showDelay={0} hideDelay={0} relationship="description">
|
||||
<Label>{label}</Label>
|
||||
{(desc || descComponent) ?
|
||||
<Tooltip content={descComponent ? descComponent : desc!} showDelay={0} hideDelay={0} relationship="description">
|
||||
<Label onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>{label}</Label>
|
||||
</Tooltip> :
|
||||
<Label>{label}</Label>
|
||||
<Label onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>{label}</Label>
|
||||
}
|
||||
{content}
|
||||
</div>
|
||||
|
||||
18
frontend/src/components/ResetConfigsButton.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import React, { FC } from 'react';
|
||||
import { DialogButton } from './DialogButton';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ArrowReset20Regular } from '@fluentui/react-icons';
|
||||
import commonStore from '../stores/commonStore';
|
||||
|
||||
import { defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultModelConfigs';
|
||||
|
||||
export const ResetConfigsButton: FC<{ afterConfirm?: () => void }> = ({ afterConfirm }) => {
|
||||
const { t } = useTranslation();
|
||||
return <DialogButton icon={<ArrowReset20Regular />} tooltip={t('Reset All Configs')} title={t('Reset All Configs')}
|
||||
contentText={t('Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
commonStore.setModelConfigs(commonStore.platform != 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, false);
|
||||
commonStore.setCurrentConfigIndex(0, true);
|
||||
afterConfirm?.();
|
||||
}} />;
|
||||
};
|
||||
@@ -75,10 +75,21 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
BrowserOpenURL('https://aka.ms/vs/16/release/vc_redist.x64.exe');
|
||||
});
|
||||
} else {
|
||||
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
||||
InstallPyDep(commonStore.settings.customPythonPath, commonStore.settings.cnMirror);
|
||||
setTimeout(WindowShow, 1000);
|
||||
});
|
||||
toast(depErrorMsg, { type: 'info', position: 'bottom-left' });
|
||||
if (commonStore.platform != 'linux')
|
||||
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
||||
InstallPyDep(commonStore.settings.customPythonPath, commonStore.settings.cnMirror).catch((e) => {
|
||||
const errMsg = e.message || e;
|
||||
toast(t('Error') + ' - ' + errMsg, { type: 'error' });
|
||||
});
|
||||
setTimeout(WindowShow, 1000);
|
||||
}, {
|
||||
autoClose: 8000
|
||||
});
|
||||
else
|
||||
toastWithButton(t('On Linux system, you must manually install python dependencies.'), t('Check'), () => {
|
||||
BrowserOpenURL('https://github.com/josStorer/RWKV-Runner/blob/master/build/linux/Readme_Install.txt');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
toast(depErrorMsg, { type: 'error' });
|
||||
@@ -94,11 +105,13 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
saveCache();
|
||||
}
|
||||
|
||||
if (!await FileExists(modelPath)) {
|
||||
toastWithButton(t('Model file not found'), t('Download'), () => {
|
||||
const downloadUrl = commonStore.modelSourceList.find(item => item.name === modelName)?.downloadUrl;
|
||||
const currentModelSource = commonStore.modelSourceList.find(item => item.name === modelName);
|
||||
|
||||
const showDownloadPrompt = (promptInfo: string, downloadName: string) => {
|
||||
toastWithButton(promptInfo, t('Download'), () => {
|
||||
const downloadUrl = currentModelSource?.downloadUrl;
|
||||
if (downloadUrl) {
|
||||
toastWithButton(`${t('Downloading')} ${modelName}`, t('Check'), () => {
|
||||
toastWithButton(`${t('Downloading')} ${downloadName}`, t('Check'), () => {
|
||||
navigate({ pathname: '/downloads' });
|
||||
},
|
||||
{ autoClose: 3000 });
|
||||
@@ -107,7 +120,14 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
toast(t('Can not find download url'), { type: 'error' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!await FileExists(modelPath)) {
|
||||
showDownloadPrompt(t('Model file not found'), modelName);
|
||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||
return;
|
||||
} else if (!currentModelSource?.isLocal) {
|
||||
showDownloadPrompt(t('Model file download is not complete'), modelName);
|
||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||
return;
|
||||
}
|
||||
@@ -116,7 +136,13 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
|
||||
await exit(1000).catch(() => {
|
||||
});
|
||||
StartServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1');
|
||||
StartServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1').catch((e) => {
|
||||
const errMsg = e.message || e;
|
||||
if (errMsg.includes('path contains space'))
|
||||
toast(`${t('Error')} - ${t('File Path Cannot Contain Space')}`, { type: 'error' });
|
||||
else
|
||||
toast(t('Error') + ' - ' + errMsg, { type: 'error' });
|
||||
});
|
||||
setTimeout(WindowShow, 1000);
|
||||
|
||||
let timeoutCount = 6;
|
||||
@@ -142,30 +168,35 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
});
|
||||
|
||||
let customCudaFile = '';
|
||||
if (modelConfig.modelParameters.device != 'CPU' && modelConfig.modelParameters.useCustomCuda) {
|
||||
customCudaFile = getSupportedCustomCudaFile();
|
||||
if (customCudaFile && commonStore.platform === 'windows') {
|
||||
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
|
||||
// defensive measure. As Python has already been launched, will only take effect the next time it runs.
|
||||
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
||||
});
|
||||
await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => {
|
||||
FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => {
|
||||
if (!exist) {
|
||||
customCudaFile = '';
|
||||
toast(t('Failed to copy custom cuda file'), { type: 'error' });
|
||||
}
|
||||
if ((modelConfig.modelParameters.device === 'CUDA' || modelConfig.modelParameters.device === 'Custom')
|
||||
&& modelConfig.modelParameters.useCustomCuda) {
|
||||
if (commonStore.platform === 'windows') {
|
||||
customCudaFile = getSupportedCustomCudaFile();
|
||||
if (customCudaFile) {
|
||||
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
|
||||
// defensive measure. As Python has already been launched, will only take effect the next time it runs.
|
||||
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
|
||||
});
|
||||
});
|
||||
} else
|
||||
toast(t('Supported custom cuda file not found'), { type: 'warning' });
|
||||
await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => {
|
||||
FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => {
|
||||
if (!exist) {
|
||||
customCudaFile = '';
|
||||
toast(t('Failed to copy custom cuda file'), { type: 'error' });
|
||||
}
|
||||
});
|
||||
});
|
||||
} else
|
||||
toast(t('Supported custom cuda file not found'), { type: 'warning' });
|
||||
} else {
|
||||
customCudaFile = 'any';
|
||||
}
|
||||
}
|
||||
|
||||
switchModel({
|
||||
model: modelPath,
|
||||
strategy: getStrategy(modelConfig),
|
||||
customCuda: customCudaFile !== ''
|
||||
}).then((r) => {
|
||||
}).then(async (r) => {
|
||||
if (r.ok) {
|
||||
commonStore.setStatus({ status: ModelStatus.Working });
|
||||
toastWithButton(t('Startup Completed'), t('Chat'), () => {
|
||||
@@ -175,14 +206,11 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
toast(t('Loading Model'), { type: 'info' });
|
||||
} else {
|
||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||
toast(t('Failed to switch model'), { type: 'error' });
|
||||
toast(t('Failed to switch model') + ' - ' + await r.text(), { type: 'error' });
|
||||
}
|
||||
}).catch(() => {
|
||||
}).catch((e) => {
|
||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||
if (commonStore.platform === 'windows')
|
||||
toast(t('Failed to switch model, please try starting the program with administrator privileges.'), { type: 'error' });
|
||||
else
|
||||
toast(t('Failed to switch model'), { type: 'error' });
|
||||
toast(t('Failed to switch model') + ' - ' + e.message || e, { type: 'error' });
|
||||
});
|
||||
}
|
||||
}).catch(() => {
|
||||
|
||||
@@ -5,6 +5,7 @@ export const ToolTipButton: FC<{
|
||||
text?: string | null,
|
||||
desc: string,
|
||||
icon?: ReactElement,
|
||||
className?: string,
|
||||
size?: 'small' | 'medium' | 'large',
|
||||
shape?: 'rounded' | 'circular' | 'square';
|
||||
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent';
|
||||
@@ -14,6 +15,7 @@ export const ToolTipButton: FC<{
|
||||
text,
|
||||
desc,
|
||||
icon,
|
||||
className,
|
||||
size,
|
||||
shape,
|
||||
appearance,
|
||||
@@ -22,7 +24,7 @@ export const ToolTipButton: FC<{
|
||||
}) => {
|
||||
return (
|
||||
<Tooltip content={desc} showDelay={0} hideDelay={0} relationship="label">
|
||||
<Button disabled={disabled} icon={icon} onClick={onClick} size={size} shape={shape}
|
||||
<Button className={className} disabled={disabled} icon={icon} onClick={onClick} size={size} shape={shape}
|
||||
appearance={appearance}>{text}</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ import App from './App';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
import { startup } from './startup';
|
||||
import './_locales/i18n-react';
|
||||
import { WindowSetAlwaysOnTop } from '../wailsjs/runtime';
|
||||
import { WindowShow } from '../wailsjs/runtime';
|
||||
|
||||
startup().then(() => {
|
||||
const container = document.getElementById('root');
|
||||
@@ -20,6 +20,5 @@ startup().then(() => {
|
||||
);
|
||||
|
||||
// force display the window
|
||||
WindowSetAlwaysOnTop(true);
|
||||
WindowSetAlwaysOnTop(false);
|
||||
WindowShow();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { FC, useEffect, useRef, useState } from 'react';
|
||||
import React, { FC, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Avatar, PresenceBadge, Textarea } from '@fluentui/react-components';
|
||||
import commonStore, { ModelStatus } from '../stores/commonStore';
|
||||
@@ -7,14 +7,17 @@ import { v4 as uuid } from 'uuid';
|
||||
import classnames from 'classnames';
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||
import { ConversationPair, getConversationPairs, Record } from '../utils/get-conversation-pairs';
|
||||
import logo from '../../../build/appicon.jpg';
|
||||
import logo from '../assets/images/logo.jpg';
|
||||
import MarkdownRender from '../components/MarkdownRender';
|
||||
import { ToolTipButton } from '../components/ToolTipButton';
|
||||
import { ArrowCircleUp28Regular, Delete28Regular, RecordStop28Regular } from '@fluentui/react-icons';
|
||||
import { ArrowCircleUp28Regular, Delete28Regular, RecordStop28Regular, Save28Regular } from '@fluentui/react-icons';
|
||||
import { CopyButton } from '../components/CopyButton';
|
||||
import { ReadButton } from '../components/ReadButton';
|
||||
import { toast } from 'react-toastify';
|
||||
import { WorkHeader } from '../components/WorkHeader';
|
||||
import { DialogButton } from '../components/DialogButton';
|
||||
import { OpenFileFolder, OpenSaveFileDialog } from '../../wailsjs/go/backend_golang/App';
|
||||
import { toastWithButton } from '../utils';
|
||||
|
||||
export const userName = 'M E';
|
||||
export const botName = 'A I';
|
||||
@@ -39,23 +42,23 @@ export type MessageItem = {
|
||||
done: boolean
|
||||
}
|
||||
|
||||
export type Conversations = {
|
||||
export type Conversation = {
|
||||
[uuid: string]: MessageItem
|
||||
}
|
||||
|
||||
let chatSseController: AbortController | null = null;
|
||||
|
||||
const ChatPanel: FC = observer(() => {
|
||||
const { t } = useTranslation();
|
||||
const [message, setMessage] = useState('');
|
||||
const bodyRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
|
||||
const sseControllerRef = useRef<AbortController | null>(null);
|
||||
|
||||
let lastMessageId: string;
|
||||
let generating: boolean = false;
|
||||
if (commonStore.conversationsOrder.length > 0) {
|
||||
lastMessageId = commonStore.conversationsOrder[commonStore.conversationsOrder.length - 1];
|
||||
const lastMessage = commonStore.conversations[lastMessageId];
|
||||
if (commonStore.conversationOrder.length > 0) {
|
||||
lastMessageId = commonStore.conversationOrder[commonStore.conversationOrder.length - 1];
|
||||
const lastMessage = commonStore.conversation[lastMessageId];
|
||||
if (lastMessage.sender === botName)
|
||||
generating = !lastMessage.done;
|
||||
}
|
||||
@@ -67,16 +70,16 @@ const ChatPanel: FC = observer(() => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (commonStore.conversationsOrder.length === 0) {
|
||||
commonStore.setConversationsOrder(['welcome']);
|
||||
commonStore.setConversations({
|
||||
if (commonStore.conversationOrder.length === 0) {
|
||||
commonStore.setConversationOrder(['welcome']);
|
||||
commonStore.setConversation({
|
||||
'welcome': {
|
||||
sender: botName,
|
||||
type: MessageType.Normal,
|
||||
color: 'colorful',
|
||||
avatarImg: logo,
|
||||
time: new Date().toISOString(),
|
||||
content: t('Hello! I\'m RWKV, an open-source and commercially available large language model.'),
|
||||
content: t('Hello! I\'m RWKV, an open-source and commercially usable large language model.'),
|
||||
side: 'left',
|
||||
done: true
|
||||
}
|
||||
@@ -93,19 +96,19 @@ const ChatPanel: FC = observer(() => {
|
||||
e.stopPropagation();
|
||||
if (e.type === 'click' || (e.keyCode === 13 && !e.shiftKey)) {
|
||||
e.preventDefault();
|
||||
if (commonStore.status.status === ModelStatus.Offline) {
|
||||
if (commonStore.status.status === ModelStatus.Offline && !commonStore.settings.apiUrl) {
|
||||
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
||||
return;
|
||||
}
|
||||
if (!message) return;
|
||||
onSubmit(message);
|
||||
setMessage('');
|
||||
if (!commonStore.currentInput) return;
|
||||
onSubmit(commonStore.currentInput);
|
||||
commonStore.setCurrentInput('');
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = (message: string) => {
|
||||
const newId = uuid();
|
||||
commonStore.conversations[newId] = {
|
||||
commonStore.conversation[newId] = {
|
||||
sender: userName,
|
||||
type: MessageType.Normal,
|
||||
color: 'brand',
|
||||
@@ -114,19 +117,19 @@ const ChatPanel: FC = observer(() => {
|
||||
side: 'right',
|
||||
done: true
|
||||
};
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.conversationsOrder.push(newId);
|
||||
commonStore.setConversationsOrder(commonStore.conversationsOrder);
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.conversationOrder.push(newId);
|
||||
commonStore.setConversationOrder(commonStore.conversationOrder);
|
||||
|
||||
const records: Record[] = [];
|
||||
commonStore.conversationsOrder.forEach((uuid, index) => {
|
||||
const conversation = commonStore.conversations[uuid];
|
||||
if (conversation.done && conversation.type === MessageType.Normal && conversation.sender === botName) {
|
||||
commonStore.conversationOrder.forEach((uuid, index) => {
|
||||
const messageItem = commonStore.conversation[uuid];
|
||||
if (messageItem.done && messageItem.type === MessageType.Normal && messageItem.sender === botName) {
|
||||
if (index > 0) {
|
||||
const questionId = commonStore.conversationsOrder[index - 1];
|
||||
const question = commonStore.conversations[questionId];
|
||||
const questionId = commonStore.conversationOrder[index - 1];
|
||||
const question = commonStore.conversation[questionId];
|
||||
if (question.done && question.type === MessageType.Normal && question.sender === userName) {
|
||||
records.push({ question: question.content, answer: conversation.content });
|
||||
records.push({ question: question.content, answer: messageItem.content });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +138,7 @@ const ChatPanel: FC = observer(() => {
|
||||
(messages as ConversationPair[]).push({ role: 'user', content: message });
|
||||
|
||||
const answerId = uuid();
|
||||
commonStore.conversations[answerId] = {
|
||||
commonStore.conversation[answerId] = {
|
||||
sender: botName,
|
||||
type: MessageType.Normal,
|
||||
color: 'colorful',
|
||||
@@ -145,33 +148,36 @@ const ChatPanel: FC = observer(() => {
|
||||
side: 'left',
|
||||
done: false
|
||||
};
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.conversationsOrder.push(answerId);
|
||||
commonStore.setConversationsOrder(commonStore.conversationsOrder);
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.conversationOrder.push(answerId);
|
||||
commonStore.setConversationOrder(commonStore.conversationOrder);
|
||||
setTimeout(scrollToBottom);
|
||||
let answer = '';
|
||||
sseControllerRef.current = new AbortController();
|
||||
fetchEventSource(`http://127.0.0.1:${port}/chat/completions`, // https://api.openai.com/v1/chat/completions || http://127.0.0.1:${port}/chat/completions
|
||||
chatSseController = new AbortController();
|
||||
fetchEventSource( // https://api.openai.com/v1/chat/completions || http://127.0.0.1:${port}/chat/completions
|
||||
commonStore.settings.apiUrl ?
|
||||
commonStore.settings.apiUrl + '/v1/chat/completions' :
|
||||
`http://127.0.0.1:${port}/chat/completions`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer sk-`
|
||||
Authorization: `Bearer ${commonStore.settings.apiKey}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
stream: true,
|
||||
model: 'gpt-3.5-turbo'
|
||||
model: commonStore.settings.apiChatModelName // 'gpt-3.5-turbo'
|
||||
}),
|
||||
signal: sseControllerRef.current?.signal,
|
||||
signal: chatSseController?.signal,
|
||||
onmessage(e) {
|
||||
console.log('sse message', e);
|
||||
scrollToBottom();
|
||||
if (e.data === '[DONE]') {
|
||||
commonStore.conversations[answerId].done = true;
|
||||
commonStore.conversations[answerId].content = commonStore.conversations[answerId].content.trim();
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.setConversationsOrder([...commonStore.conversationsOrder]);
|
||||
commonStore.conversation[answerId].done = true;
|
||||
commonStore.conversation[answerId].content = commonStore.conversation[answerId].content.trim();
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||
return;
|
||||
}
|
||||
let data;
|
||||
@@ -183,19 +189,31 @@ const ChatPanel: FC = observer(() => {
|
||||
}
|
||||
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
|
||||
answer += data.choices[0]?.delta?.content || '';
|
||||
commonStore.conversations[answerId].content = answer;
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.setConversationsOrder([...commonStore.conversationsOrder]);
|
||||
commonStore.conversation[answerId].content = answer;
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||
}
|
||||
},
|
||||
async onopen(response) {
|
||||
if (response.status !== 200) {
|
||||
commonStore.conversation[answerId].content += '\n[ERROR]\n```\n' + response.statusText + '\n' + (await response.text()) + '\n```';
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||
setTimeout(scrollToBottom);
|
||||
}
|
||||
},
|
||||
onclose() {
|
||||
console.log('Connection closed');
|
||||
},
|
||||
onerror(err) {
|
||||
commonStore.conversations[answerId].type = MessageType.Error;
|
||||
commonStore.conversations[answerId].done = true;
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.setConversationsOrder([...commonStore.conversationsOrder]);
|
||||
commonStore.conversation[answerId].type = MessageType.Error;
|
||||
commonStore.conversation[answerId].done = true;
|
||||
err = err.message || err;
|
||||
if (err && !err.includes('ReadableStreamDefaultReader'))
|
||||
commonStore.conversation[answerId].content += '\n[ERROR]\n```\n' + err + '\n```';
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||
setTimeout(scrollToBottom);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
@@ -204,13 +222,13 @@ const ChatPanel: FC = observer(() => {
|
||||
return (
|
||||
<div className="flex flex-col w-full grow gap-4 pt-4 overflow-hidden">
|
||||
<div ref={bodyRef} className="grow overflow-y-scroll overflow-x-hidden pr-2">
|
||||
{commonStore.conversationsOrder.map((uuid, index) => {
|
||||
const conversation = commonStore.conversations[uuid];
|
||||
{commonStore.conversationOrder.map((uuid, index) => {
|
||||
const messageItem = commonStore.conversation[uuid];
|
||||
return <div
|
||||
key={uuid}
|
||||
className={classnames(
|
||||
'flex gap-2 mb-2 overflow-hidden',
|
||||
conversation.side === 'left' ? 'flex-row' : 'flex-row-reverse'
|
||||
messageItem.side === 'left' ? 'flex-row' : 'flex-row-reverse'
|
||||
)}
|
||||
onMouseEnter={() => {
|
||||
const utils = document.getElementById('utils-' + uuid);
|
||||
@@ -222,52 +240,52 @@ const ChatPanel: FC = observer(() => {
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
color={conversation.color}
|
||||
name={conversation.sender}
|
||||
image={conversation.avatarImg ? { src: conversation.avatarImg } : undefined}
|
||||
color={messageItem.color}
|
||||
name={messageItem.sender}
|
||||
image={messageItem.avatarImg ? { src: messageItem.avatarImg } : undefined}
|
||||
/>
|
||||
<div
|
||||
className={classnames(
|
||||
'p-2 rounded-lg overflow-hidden',
|
||||
conversation.side === 'left' ? 'bg-gray-200' : 'bg-blue-500',
|
||||
conversation.side === 'left' ? 'text-gray-600' : 'text-white'
|
||||
messageItem.side === 'left' ? 'bg-gray-200' : 'bg-blue-500',
|
||||
messageItem.side === 'left' ? 'text-gray-600' : 'text-white'
|
||||
)}
|
||||
>
|
||||
<MarkdownRender>{conversation.content}</MarkdownRender>
|
||||
<MarkdownRender>{messageItem.content}</MarkdownRender>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 items-start">
|
||||
<div className="grow" />
|
||||
{(conversation.type === MessageType.Error || !conversation.done) &&
|
||||
{(messageItem.type === MessageType.Error || !messageItem.done) &&
|
||||
<PresenceBadge size="extra-small" status={
|
||||
conversation.type === MessageType.Error ? 'busy' : 'away'
|
||||
messageItem.type === MessageType.Error ? 'busy' : 'away'
|
||||
} />
|
||||
}
|
||||
<div className="flex invisible" id={'utils-' + uuid}>
|
||||
<ReadButton content={conversation.content} />
|
||||
<CopyButton content={conversation.content} />
|
||||
<ReadButton content={messageItem.content} />
|
||||
<CopyButton content={messageItem.content} />
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
})}
|
||||
</div>
|
||||
<div className="flex items-end gap-2">
|
||||
<ToolTipButton desc={t('Clear')}
|
||||
<DialogButton tooltip={t('Clear')}
|
||||
icon={<Delete28Regular />}
|
||||
size="large" shape="circular" appearance="subtle"
|
||||
onClick={(e) => {
|
||||
size="large" shape="circular" appearance="subtle" title={t('Clear')}
|
||||
contentText={t('Are you sure you want to clear the conversation? It cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
if (generating)
|
||||
sseControllerRef.current?.abort();
|
||||
commonStore.setConversations({});
|
||||
commonStore.setConversationsOrder([]);
|
||||
}}
|
||||
/>
|
||||
chatSseController?.abort();
|
||||
commonStore.setConversation({});
|
||||
commonStore.setConversationOrder([]);
|
||||
}} />
|
||||
<Textarea
|
||||
ref={inputRef}
|
||||
className="grow"
|
||||
resize="vertical"
|
||||
placeholder={t('Type your message here')!}
|
||||
value={message}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
value={commonStore.currentInput}
|
||||
onChange={(e) => commonStore.setCurrentInput(e.target.value)}
|
||||
onKeyDown={handleKeyDownOrClick}
|
||||
/>
|
||||
<ToolTipButton desc={generating ? t('Stop') : t('Send')}
|
||||
@@ -275,17 +293,36 @@ const ChatPanel: FC = observer(() => {
|
||||
size="large" shape="circular" appearance="subtle"
|
||||
onClick={(e) => {
|
||||
if (generating) {
|
||||
sseControllerRef.current?.abort();
|
||||
chatSseController?.abort();
|
||||
if (lastMessageId) {
|
||||
commonStore.conversations[lastMessageId].type = MessageType.Error;
|
||||
commonStore.conversations[lastMessageId].done = true;
|
||||
commonStore.setConversations(commonStore.conversations);
|
||||
commonStore.setConversationsOrder([...commonStore.conversationsOrder]);
|
||||
commonStore.conversation[lastMessageId].type = MessageType.Error;
|
||||
commonStore.conversation[lastMessageId].done = true;
|
||||
commonStore.setConversation(commonStore.conversation);
|
||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||
}
|
||||
} else {
|
||||
handleKeyDownOrClick(e);
|
||||
}
|
||||
}} />
|
||||
<ToolTipButton desc={t('Save')}
|
||||
icon={<Save28Regular />}
|
||||
size="large" shape="circular" appearance="subtle"
|
||||
onClick={() => {
|
||||
let savedContent: string = '';
|
||||
commonStore.conversationOrder.forEach((uuid) => {
|
||||
const messageItem = commonStore.conversation[uuid];
|
||||
savedContent += `**${messageItem.sender}**\n - ${new Date(messageItem.time).toLocaleString()}\n\n${messageItem.content}\n\n`;
|
||||
});
|
||||
|
||||
OpenSaveFileDialog('*.md', 'conversation.md', savedContent).then((path) => {
|
||||
if (path)
|
||||
toastWithButton(t('Conversation Saved'), t('Open'), () => {
|
||||
OpenFileFolder(path, false);
|
||||
});
|
||||
}).catch(e => {
|
||||
toast(t('Error') + ' - ' + e.message || e, { type: 'error', autoClose: 2500 });
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ApiParameters } from './Configs';
|
||||
import commonStore, { ModelStatus } from '../stores/commonStore';
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||
import { toast } from 'react-toastify';
|
||||
import { DialogButton } from '../components/DialogButton';
|
||||
|
||||
export type CompletionParams = Omit<ApiParameters, 'apiPort'> & {
|
||||
stop: string,
|
||||
@@ -103,7 +104,7 @@ export const defaultPresets: CompletionPreset[] = [{
|
||||
}
|
||||
}, {
|
||||
name: 'Instruction',
|
||||
prompt: 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n# Instruction:\nExplain the following metaphor: Life is like cats.\n\n# Response:\n',
|
||||
prompt: 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n# Instruction:\nWrite a story using the following information\n\n# Input:\nA man named Alex chops a tree down\n\n# Response:\n',
|
||||
params: {
|
||||
maxResponseToken: 500,
|
||||
temperature: 1.2,
|
||||
@@ -129,11 +130,12 @@ export const defaultPresets: CompletionPreset[] = [{
|
||||
}
|
||||
}];
|
||||
|
||||
let completionSseController: AbortController | null = null;
|
||||
|
||||
const CompletionPanel: FC = observer(() => {
|
||||
const { t } = useTranslation();
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
|
||||
const sseControllerRef = useRef<AbortController | null>(null);
|
||||
|
||||
const scrollToBottom = () => {
|
||||
if (inputRef.current)
|
||||
@@ -178,7 +180,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
};
|
||||
|
||||
const onSubmit = (prompt: string) => {
|
||||
if (commonStore.status.status === ModelStatus.Offline) {
|
||||
if (commonStore.status.status === ModelStatus.Offline && !commonStore.settings.apiUrl) {
|
||||
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
||||
commonStore.setCompletionGenerating(false);
|
||||
return;
|
||||
@@ -187,18 +189,21 @@ const CompletionPanel: FC = observer(() => {
|
||||
prompt += params.injectStart.replaceAll('\\n', '\n');
|
||||
|
||||
let answer = '';
|
||||
sseControllerRef.current = new AbortController();
|
||||
fetchEventSource(`http://127.0.0.1:${port}/completions`, // https://api.openai.com/v1/completions || http://127.0.0.1:${port}/completions
|
||||
completionSseController = new AbortController();
|
||||
fetchEventSource( // https://api.openai.com/v1/completions || http://127.0.0.1:${port}/completions
|
||||
commonStore.settings.apiUrl ?
|
||||
commonStore.settings.apiUrl + '/v1/completions' :
|
||||
`http://127.0.0.1:${port}/completions`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer sk-`
|
||||
Authorization: `Bearer ${commonStore.settings.apiKey}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
prompt,
|
||||
stream: true,
|
||||
model: 'text-davinci-003',
|
||||
model: commonStore.settings.apiCompletionModelName, // 'text-davinci-003'
|
||||
max_tokens: params.maxResponseToken,
|
||||
temperature: params.temperature,
|
||||
top_p: params.topP,
|
||||
@@ -206,7 +211,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
frequency_penalty: params.frequencyPenalty,
|
||||
stop: params.stop.replaceAll('\\n', '\n') || undefined
|
||||
}),
|
||||
signal: sseControllerRef.current?.signal,
|
||||
signal: completionSseController?.signal,
|
||||
onmessage(e) {
|
||||
console.log('sse message', e);
|
||||
scrollToBottom();
|
||||
@@ -226,10 +231,22 @@ const CompletionPanel: FC = observer(() => {
|
||||
setPrompt(prompt + answer.trim() + params.injectEnd.replaceAll('\\n', '\n'));
|
||||
}
|
||||
},
|
||||
async onopen(response) {
|
||||
if (response.status !== 200) {
|
||||
toast(response.statusText + '\n' + (await response.text()), {
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
},
|
||||
onclose() {
|
||||
console.log('Connection closed');
|
||||
},
|
||||
onerror(err) {
|
||||
err = err.message || err;
|
||||
if (err && !err.includes('ReadableStreamDefaultReader'))
|
||||
toast(err, {
|
||||
type: 'error'
|
||||
});
|
||||
commonStore.setCompletionGenerating(false);
|
||||
throw err;
|
||||
}
|
||||
@@ -258,7 +275,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
<Option key={preset.name} value={preset.name}>{t(preset.name)!}</Option>)
|
||||
}
|
||||
</Dropdown>
|
||||
<div className="flex flex-col gap-1 overflow-x-hidden overflow-y-auto">
|
||||
<div className="flex flex-col gap-1 overflow-x-hidden overflow-y-auto p-1">
|
||||
<Labeled flex breakline label={t('Max Response Token')}
|
||||
desc={t('By default, the maximum number of tokens that can be answered in a single response, it can be changed by the user by specifying API parameters.')}
|
||||
content={
|
||||
@@ -272,7 +289,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
<Labeled flex breakline label={t('Temperature')}
|
||||
desc={t('Sampling temperature, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={params.temperature} min={0} max={2} step={0.1}
|
||||
input
|
||||
@@ -283,7 +300,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
<Labeled flex breakline label={t('Top_P')}
|
||||
desc={t('Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
@@ -347,12 +364,14 @@ const CompletionPanel: FC = observer(() => {
|
||||
</div>
|
||||
<div className="grow" />
|
||||
<div className="flex justify-between gap-2">
|
||||
<Button className="grow" onClick={() => {
|
||||
setPreset(defaultPresets.find((preset) => preset.name === name)!);
|
||||
}}>{t('Reset')}</Button>
|
||||
<DialogButton className="grow" text={t('Reset')} title={t('Reset')}
|
||||
contentText={t('Are you sure you want to reset this page? It cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
setPreset(defaultPresets.find((preset) => preset.name === name)!);
|
||||
}} />
|
||||
<Button className="grow" appearance="primary" onClick={() => {
|
||||
if (commonStore.completionGenerating) {
|
||||
sseControllerRef.current?.abort();
|
||||
completionSseController?.abort();
|
||||
commonStore.setCompletionGenerating(false);
|
||||
} else {
|
||||
commonStore.setCompletionGenerating(true);
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogBody,
|
||||
DialogContent,
|
||||
DialogSurface,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
Dropdown,
|
||||
Input,
|
||||
Label,
|
||||
Option,
|
||||
Select,
|
||||
Switch
|
||||
} from '@fluentui/react-components';
|
||||
import {
|
||||
AddCircle20Regular,
|
||||
ArrowReset20Regular,
|
||||
DataUsageSettings20Regular,
|
||||
Delete20Regular,
|
||||
Save20Regular
|
||||
} from '@fluentui/react-icons';
|
||||
import { Dropdown, Input, Label, Option, Select, Switch, Text } from '@fluentui/react-components';
|
||||
import { AddCircle20Regular, DataUsageSettings20Regular, Delete20Regular, Save20Regular } from '@fluentui/react-icons';
|
||||
import React, { FC } from 'react';
|
||||
import { Section } from '../components/Section';
|
||||
import { Labeled } from '../components/Labeled';
|
||||
@@ -38,6 +17,9 @@ import { ConvertModel, FileExists } from '../../wailsjs/go/backend_golang/App';
|
||||
import { getStrategy, refreshLocalModels } from '../utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { WindowShow } from '../../wailsjs/runtime/runtime';
|
||||
import strategyImg from '../assets/images/strategy.jpg';
|
||||
import strategyZhImg from '../assets/images/strategy_zh.jpg';
|
||||
import { ResetConfigsButton } from '../components/ResetConfigsButton';
|
||||
|
||||
export type ApiParameters = {
|
||||
apiPort: number
|
||||
@@ -48,7 +30,7 @@ export type ApiParameters = {
|
||||
frequencyPenalty: number;
|
||||
}
|
||||
|
||||
export type Device = 'CPU' | 'CUDA' | 'Custom';
|
||||
export type Device = 'CPU' | 'CUDA' | 'MPS' | 'Custom';
|
||||
export type Precision = 'fp16' | 'int8' | 'fp32';
|
||||
|
||||
export type ModelParameters = {
|
||||
@@ -58,7 +40,6 @@ export type ModelParameters = {
|
||||
precision: Precision;
|
||||
storedLayers: number;
|
||||
maxStoredLayers: number;
|
||||
enableHighPrecisionForLastLayer: boolean;
|
||||
useCustomCuda?: boolean;
|
||||
customStrategy?: string;
|
||||
}
|
||||
@@ -70,568 +51,11 @@ export type ModelConfig = {
|
||||
modelParameters: ModelParameters
|
||||
}
|
||||
|
||||
export const defaultModelConfigs: ModelConfig[] = [
|
||||
{
|
||||
name: 'GPU-2G-1B5-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 4,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-4G-1B5-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-4G-3B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 24,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-4G-3B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 24,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-4G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 8,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-4G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 8,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-6G-1B5-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-6G-3B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-6G-3B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-6G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 18,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-6G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 18,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: true,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-8G-3B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-8G-3B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-8G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 27,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-8G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 27,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-10G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-10G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-12G-14B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 24,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-16G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-16G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-16G-14B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 37,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-18G-14B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'GPU-32G-14B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false,
|
||||
useCustomCuda: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'CPU-6G-1B5-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CPU',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'CPU-12G-3B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth',
|
||||
device: 'CPU',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'CPU-12G-3B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth',
|
||||
device: 'CPU',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'CPU-28G-7B-EN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth',
|
||||
device: 'CPU',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'CPU-28G-7B-CN',
|
||||
apiParameters: {
|
||||
apiPort: 8000,
|
||||
maxResponseToken: 4100,
|
||||
temperature: 1.2,
|
||||
topP: 0.5,
|
||||
presencePenalty: 0.4,
|
||||
frequencyPenalty: 0.4
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth',
|
||||
device: 'CPU',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
maxStoredLayers: 41,
|
||||
enableHighPrecisionForLastLayer: false
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export const Configs: FC = observer(() => {
|
||||
const { t } = useTranslation();
|
||||
const [selectedIndex, setSelectedIndex] = React.useState(commonStore.currentModelConfigIndex);
|
||||
const [selectedConfig, setSelectedConfig] = React.useState(commonStore.modelConfigs[selectedIndex]);
|
||||
const [displayStrategyImg, setDisplayStrategyImg] = React.useState(false);
|
||||
const navigate = useNavigate();
|
||||
const port = selectedConfig.apiParameters.apiPort;
|
||||
|
||||
@@ -700,31 +124,10 @@ export const Configs: FC = observer(() => {
|
||||
commonStore.deleteModelConfig(selectedIndex);
|
||||
updateSelectedIndex(Math.min(selectedIndex, commonStore.modelConfigs.length - 1));
|
||||
}} />
|
||||
<Dialog>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<ToolTipButton desc={t('Reset All Configs')} icon={<ArrowReset20Regular />} />
|
||||
</DialogTrigger>
|
||||
<DialogSurface>
|
||||
<DialogBody>
|
||||
<DialogTitle>{t('Reset All Configs')}</DialogTitle>
|
||||
<DialogContent>
|
||||
{t('Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.')}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="secondary">{t('Cancel')}</Button>
|
||||
</DialogTrigger>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="primary" onClick={() => {
|
||||
commonStore.setModelConfigs(defaultModelConfigs, false); // updateSelectedIndex() will save configs
|
||||
updateSelectedIndex(0);
|
||||
}}>{t('Confirm')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
</DialogActions>
|
||||
</DialogBody>
|
||||
</DialogSurface>
|
||||
</Dialog>
|
||||
<ResetConfigsButton afterConfirm={() => {
|
||||
setSelectedIndex(0);
|
||||
setSelectedConfig(commonStore.modelConfigs[0]);
|
||||
}} />
|
||||
<ToolTipButton desc={t('Save Config')} icon={<Save20Regular />} onClick={onClickSave} />
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
@@ -763,7 +166,7 @@ export const Configs: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Temperature') + ' *'}
|
||||
desc={t('Sampling temperature, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.temperature} min={0} max={2} step={0.1}
|
||||
input
|
||||
@@ -774,7 +177,7 @@ export const Configs: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Top_P') + ' *'}
|
||||
desc={t('Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.topP} min={0} max={1} step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
@@ -834,33 +237,38 @@ export const Configs: FC = observer(() => {
|
||||
}} />
|
||||
</div>
|
||||
} />
|
||||
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
|
||||
if (commonStore.platform == 'darwin') {
|
||||
toast(t('MacOS is not supported yet, please convert manually.'), { type: 'info' });
|
||||
return;
|
||||
}
|
||||
<ToolTipButton text={t('Convert')}
|
||||
desc={t('Convert model with these configs. Using a converted model will greatly improve the loading speed, but model parameters of the converted model cannot be modified.')}
|
||||
onClick={async () => {
|
||||
if (commonStore.platform == 'darwin') {
|
||||
toast(t('MacOS is not yet supported for performing this operation, please do it manually.'), { type: 'info' });
|
||||
return;
|
||||
} else if (commonStore.platform == 'linux') {
|
||||
toast(t('Linux is not yet supported for performing this operation, please do it manually.'), { type: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
|
||||
if (await FileExists(modelPath)) {
|
||||
const strategy = getStrategy(selectedConfig);
|
||||
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
||||
toast(t('Start Converting'), { autoClose: 1000, type: 'info' });
|
||||
ConvertModel(commonStore.settings.customPythonPath, modelPath, strategy, newModelPath).then(() => {
|
||||
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
|
||||
refreshLocalModels({ models: commonStore.modelSourceList }, false);
|
||||
}).catch(e => {
|
||||
const errMsg = e.message || e;
|
||||
if (errMsg.includes('path contains space'))
|
||||
toast(`${t('Convert Failed')} - ${t('Path Cannot Contain Space')}`, { type: 'error' });
|
||||
else
|
||||
toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' });
|
||||
});
|
||||
setTimeout(WindowShow, 1000);
|
||||
} else {
|
||||
toast(`${t('Model Not Found')} - ${modelPath}`, { type: 'error' });
|
||||
}
|
||||
}} />
|
||||
<Labeled label={t('Device')} content={
|
||||
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
|
||||
if (await FileExists(modelPath)) {
|
||||
const strategy = getStrategy(selectedConfig);
|
||||
const newModelPath = modelPath + '-' + strategy.replace(/[:> *+]/g, '-');
|
||||
toast(t('Start Converting'), { autoClose: 1000, type: 'info' });
|
||||
ConvertModel(commonStore.settings.customPythonPath, modelPath, strategy, newModelPath).then(() => {
|
||||
toast(`${t('Convert Success')} - ${newModelPath}`, { type: 'success' });
|
||||
refreshLocalModels({ models: commonStore.modelSourceList }, false);
|
||||
}).catch(e => {
|
||||
const errMsg = e.message || e;
|
||||
if (errMsg.includes('path contains space'))
|
||||
toast(`${t('Convert Failed')} - ${t('File Path Cannot Contain Space')}`, { type: 'error' });
|
||||
else
|
||||
toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' });
|
||||
});
|
||||
setTimeout(WindowShow, 1000);
|
||||
} else {
|
||||
toast(`${t('Model Not Found')} - ${modelPath}`, { type: 'error' });
|
||||
}
|
||||
}} />
|
||||
<Labeled label={t('Strategy')} content={
|
||||
<Dropdown style={{ minWidth: 0 }} className="grow" value={t(selectedConfig.modelParameters.device)!}
|
||||
selectedOptions={[selectedConfig.modelParameters.device]}
|
||||
onOptionSelect={(_, data) => {
|
||||
@@ -871,6 +279,7 @@ export const Configs: FC = observer(() => {
|
||||
}
|
||||
}}>
|
||||
<Option value="CPU">CPU</Option>
|
||||
{commonStore.platform === 'darwin' && <Option value="MPS">MPS</Option>}
|
||||
<Option value="CUDA">CUDA</Option>
|
||||
<Option value="Custom">{t('Custom')!}</Option>
|
||||
</Dropdown>
|
||||
@@ -895,10 +304,15 @@ export const Configs: FC = observer(() => {
|
||||
</Dropdown>
|
||||
} />
|
||||
}
|
||||
{selectedConfig.modelParameters.device == 'CUDA' && <div />}
|
||||
{
|
||||
selectedConfig.modelParameters.device == 'CUDA' && <Labeled label={t('Stored Layers')}
|
||||
desc={t('Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM.')}
|
||||
selectedConfig.modelParameters.device == 'CUDA' &&
|
||||
<Labeled label={t('Current Strategy')}
|
||||
content={<Text> {getStrategy(selectedConfig)} </Text>} />
|
||||
}
|
||||
{
|
||||
selectedConfig.modelParameters.device == 'CUDA' &&
|
||||
<Labeled label={t('Stored Layers')}
|
||||
desc={t('Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM. (If your VRAM is not enough, it will fail to load)')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.modelParameters.storedLayers} min={0}
|
||||
max={selectedConfig.modelParameters.maxStoredLayers} step={1} input
|
||||
@@ -910,23 +324,21 @@ export const Configs: FC = observer(() => {
|
||||
} />
|
||||
}
|
||||
{
|
||||
selectedConfig.modelParameters.device == 'CUDA' &&
|
||||
<Labeled label={t('Enable High Precision For Last Layer')}
|
||||
desc={t('Whether to use CPU to calculate the last output layer of the neural network with FP32 precision to obtain better quality.')}
|
||||
content={
|
||||
<Switch checked={selectedConfig.modelParameters.enableHighPrecisionForLastLayer}
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigModelParams({
|
||||
enableHighPrecisionForLastLayer: data.checked
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
selectedConfig.modelParameters.device == 'CUDA' && <div />
|
||||
}
|
||||
{
|
||||
displayStrategyImg &&
|
||||
<img style={{ width: '80vh', height: 'auto', zIndex: 100 }} className="fixed left-0 top-0"
|
||||
src={commonStore.settings.language === 'zh' ? strategyZhImg : strategyImg} />
|
||||
}
|
||||
{
|
||||
selectedConfig.modelParameters.device == 'Custom' &&
|
||||
<Labeled label="Strategy" desc="https://github.com/BlinkDL/ChatRWKV/blob/main/ChatRWKV-strategy.png"
|
||||
<Labeled label="Strategy"
|
||||
onMouseEnter={() => setDisplayStrategyImg(true)}
|
||||
onMouseLeave={() => setDisplayStrategyImg(false)}
|
||||
content={
|
||||
<Input className="grow" placeholder="cuda:0 fp16 *20 -> cuda:1 fp16"
|
||||
<Input className="grow"
|
||||
placeholder={commonStore.platform != 'darwin' ? 'cuda:0 fp16 *20 -> cuda:1 fp16' : 'mps fp32'}
|
||||
value={selectedConfig.modelParameters.customStrategy}
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigModelParams({
|
||||
@@ -937,9 +349,9 @@ export const Configs: FC = observer(() => {
|
||||
}
|
||||
{selectedConfig.modelParameters.device == 'Custom' && <div />}
|
||||
{
|
||||
selectedConfig.modelParameters.device != 'CPU' &&
|
||||
selectedConfig.modelParameters.device != 'CPU' && selectedConfig.modelParameters.device != 'MPS' &&
|
||||
<Labeled label={t('Use Custom CUDA kernel to Accelerate')}
|
||||
desc={t('Enabling this option can greatly improve inference speed, but there may be compatibility issues. If it fails to start, please turn off this option.')}
|
||||
desc={t('Enabling this option can greatly improve inference speed and save some VRAM, but there may be compatibility issues. If it fails to start, please turn off this option.')}
|
||||
content={
|
||||
<Switch checked={selectedConfig.modelParameters.useCustomCuda}
|
||||
onChange={(e, data) => {
|
||||
|
||||
@@ -53,7 +53,7 @@ export const Downloads: FC = observer(() => {
|
||||
<div className="flex items-center gap-2">
|
||||
<ProgressBar className="grow" value={status.progress} max={100} />
|
||||
{!status.done &&
|
||||
<ToolTipButton desc={status.downloading ? t('Pause') : t('Continue')}
|
||||
<ToolTipButton desc={status.downloading ? t('Pause') : t('Resume')}
|
||||
icon={status.downloading ? <Pause20Regular /> : <Play20Regular />}
|
||||
onClick={() => {
|
||||
if (status.downloading)
|
||||
@@ -62,7 +62,7 @@ export const Downloads: FC = observer(() => {
|
||||
ContinueDownload(status.url);
|
||||
}} />}
|
||||
<ToolTipButton desc={t('Open Folder')} icon={<Folder20Regular />} onClick={() => {
|
||||
OpenFileFolder(`${commonStore.settings.customModelsPath}/${status.name}`);
|
||||
OpenFileFolder(status.path, false);
|
||||
}} />
|
||||
</div>
|
||||
</Field>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ConfigSelector } from '../components/ConfigSelector';
|
||||
import MarkdownRender from '../components/MarkdownRender';
|
||||
import commonStore from '../stores/commonStore';
|
||||
import { Completion } from './Completion';
|
||||
import { ResetConfigsButton } from '../components/ResetConfigsButton';
|
||||
|
||||
export type IntroductionContent = { [lang: string]: string }
|
||||
|
||||
@@ -65,7 +66,8 @@ export const Home: FC = observer(() => {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col justify-between h-full">
|
||||
<img className="rounded-xl select-none hidden sm:block" src={banner} />
|
||||
<img className="rounded-xl select-none hidden sm:block"
|
||||
style={{ maxHeight: '40%', margin: '0 auto' }} src={banner} />
|
||||
<div className="flex flex-col gap-2">
|
||||
<Text size={600} weight="medium">{t('Introduction')}</Text>
|
||||
<div className="h-40 overflow-y-auto overflow-x-hidden p-1">
|
||||
@@ -85,6 +87,7 @@ export const Home: FC = observer(() => {
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-row-reverse sm:fixed bottom-2 right-2">
|
||||
<div className="flex gap-3">
|
||||
<ResetConfigsButton />
|
||||
<ConfigSelector />
|
||||
<RunButton />
|
||||
</div>
|
||||
|
||||
@@ -142,7 +142,7 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
||||
{
|
||||
item.isLocal &&
|
||||
<ToolTipButton desc={t('Open Folder')} icon={<Folder20Regular />} onClick={() => {
|
||||
OpenFileFolder(`${commonStore.settings.customModelsPath}/${item.name}`);
|
||||
OpenFileFolder(`${commonStore.settings.customModelsPath}/${item.name}`, true);
|
||||
}} />
|
||||
}
|
||||
{item.downloadUrl && !item.isLocal &&
|
||||
|
||||
@@ -14,7 +14,8 @@ import { Labeled } from '../components/Labeled';
|
||||
import commonStore from '../stores/commonStore';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { checkUpdate } from '../utils';
|
||||
import { checkUpdate, toastWithButton } from '../utils';
|
||||
import { RestartApp } from '../../wailsjs/go/backend_golang/App';
|
||||
|
||||
export const Languages = {
|
||||
dev: 'English', // i18n default
|
||||
@@ -30,8 +31,13 @@ export type SettingsType = {
|
||||
giteeUpdatesSource: boolean
|
||||
cnMirror: boolean
|
||||
host: string
|
||||
dpiScaling: number
|
||||
customModelsPath: string
|
||||
customPythonPath: string
|
||||
apiUrl: string
|
||||
apiKey: string
|
||||
apiChatModelName: string
|
||||
apiCompletionModelName: string
|
||||
}
|
||||
|
||||
export const Settings: FC = observer(() => {
|
||||
@@ -45,7 +51,7 @@ export const Settings: FC = observer(() => {
|
||||
|
||||
return (
|
||||
<Page title={t('Settings')} content={
|
||||
<div className="flex flex-col gap-2 overflow-hidden">
|
||||
<div className="flex flex-col gap-2 overflow-y-auto overflow-x-hidden p-1">
|
||||
<Labeled label={t('Language')} flex spaceBetween content={
|
||||
<Dropdown style={{ minWidth: 0 }} listbox={{ style: { minWidth: 0 } }}
|
||||
value={Languages[commonStore.settings.language]}
|
||||
@@ -56,7 +62,6 @@ export const Settings: FC = observer(() => {
|
||||
commonStore.setSettings({
|
||||
language: lang
|
||||
});
|
||||
i18n.changeLanguage(lang);
|
||||
}
|
||||
}}>
|
||||
{
|
||||
@@ -65,6 +70,31 @@ export const Settings: FC = observer(() => {
|
||||
}
|
||||
</Dropdown>
|
||||
} />
|
||||
{
|
||||
commonStore.platform === 'windows' &&
|
||||
<Labeled label={t('DPI Scaling')} flex spaceBetween content={
|
||||
<Dropdown style={{ minWidth: 0 }} listbox={{ style: { minWidth: 0 } }}
|
||||
value={commonStore.settings.dpiScaling + '%'}
|
||||
selectedOptions={[commonStore.settings.dpiScaling.toString()]}
|
||||
onOptionSelect={(_, data) => {
|
||||
if (data.optionValue) {
|
||||
commonStore.setSettings({
|
||||
dpiScaling: Number(data.optionValue)
|
||||
});
|
||||
toastWithButton(t('Restart the app to apply DPI Scaling.'), t('Restart'), () => {
|
||||
RestartApp();
|
||||
}, {
|
||||
autoClose: 5000
|
||||
});
|
||||
}
|
||||
}}>
|
||||
{
|
||||
Array.from({ length: 7 }, (_, i) => (i + 2) * 25).map((v, i) =>
|
||||
<Option key={i} value={v.toString()}>{v + '%'}</Option>)
|
||||
}
|
||||
</Dropdown>
|
||||
} />
|
||||
}
|
||||
<Labeled label={t('Dark Mode')} flex spaceBetween content={
|
||||
<Switch checked={commonStore.settings.darkMode}
|
||||
onChange={(e, data) => {
|
||||
@@ -95,7 +125,7 @@ export const Settings: FC = observer(() => {
|
||||
} />
|
||||
}
|
||||
{
|
||||
commonStore.settings.language === 'zh' &&
|
||||
commonStore.settings.language === 'zh' && commonStore.platform != 'linux' &&
|
||||
<Labeled label={t('Use Tsinghua Pip Mirrors')} flex spaceBetween content={
|
||||
<Switch checked={commonStore.settings.cnMirror}
|
||||
onChange={(e, data) => {
|
||||
@@ -113,8 +143,11 @@ export const Settings: FC = observer(() => {
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Accordion collapsible>
|
||||
<AccordionItem value="1">
|
||||
<Accordion collapsible openItems={!commonStore.advancedCollapsed && 'advanced'} onToggle={(e, data) => {
|
||||
if (data.value === 'advanced')
|
||||
commonStore.setAdvancedCollapsed(!commonStore.advancedCollapsed);
|
||||
}}>
|
||||
<AccordionItem value="advanced">
|
||||
<AccordionHeader ref={advancedHeaderRef} size="large">{t('Advanced')}</AccordionHeader>
|
||||
<AccordionPanel>
|
||||
<div className="flex flex-col gap-2 overflow-hidden">
|
||||
@@ -138,6 +171,102 @@ export const Settings: FC = observer(() => {
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={'API URL'}
|
||||
content={
|
||||
<div className="flex gap-2">
|
||||
<Input style={{ minWidth: 0 }} className="grow" value={commonStore.settings.apiUrl}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
apiUrl: data.value
|
||||
});
|
||||
}} />
|
||||
<Dropdown style={{ minWidth: 0 }} listbox={{ style: { minWidth: 0 } }}
|
||||
value="..." selectedOptions={[]} expandIcon={null}
|
||||
onOptionSelect={(_, data) => {
|
||||
commonStore.setSettings({
|
||||
apiUrl: data.optionValue
|
||||
});
|
||||
if (data.optionText === 'OpenAI') {
|
||||
if (commonStore.settings.apiChatModelName === 'rwkv')
|
||||
commonStore.setSettings({
|
||||
apiChatModelName: 'gpt-3.5-turbo'
|
||||
});
|
||||
if (commonStore.settings.apiCompletionModelName === 'rwkv')
|
||||
commonStore.setSettings({
|
||||
apiCompletionModelName: 'text-davinci-003'
|
||||
});
|
||||
}
|
||||
}}>
|
||||
<Option value="">{t('Localhost')!}</Option>
|
||||
<Option value="https://api.openai.com">OpenAI</Option>
|
||||
</Dropdown>
|
||||
</div>
|
||||
} />
|
||||
<Labeled label={'API Key'}
|
||||
content={
|
||||
<Input className="grow" placeholder="sk-" value={commonStore.settings.apiKey}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
apiKey: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('API Chat Model Name')}
|
||||
content={
|
||||
<div className="flex gap-2">
|
||||
<Input style={{ minWidth: 0 }} className="grow" placeholder="rwkv"
|
||||
value={commonStore.settings.apiChatModelName}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
apiChatModelName: data.value
|
||||
});
|
||||
}} />
|
||||
<Dropdown style={{ minWidth: 0 }} listbox={{ style: { minWidth: 0 } }}
|
||||
value="..." selectedOptions={[]} expandIcon={null}
|
||||
onOptionSelect={(_, data) => {
|
||||
if (data.optionValue) {
|
||||
commonStore.setSettings({
|
||||
apiChatModelName: data.optionValue
|
||||
});
|
||||
}
|
||||
}}>
|
||||
{
|
||||
['rwkv', 'gpt-4', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-32k-0613', 'gpt-3.5-turbo', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613']
|
||||
.map((v, i) =>
|
||||
<Option key={i} value={v}>{v}</Option>
|
||||
)
|
||||
}
|
||||
</Dropdown>
|
||||
</div>
|
||||
} />
|
||||
<Labeled label={t('API Completion Model Name')}
|
||||
content={
|
||||
<div className="flex gap-2">
|
||||
<Input style={{ minWidth: 0 }} className="grow" placeholder="rwkv"
|
||||
value={commonStore.settings.apiCompletionModelName}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
apiCompletionModelName: data.value
|
||||
});
|
||||
}} />
|
||||
<Dropdown style={{ minWidth: 0 }} listbox={{ style: { minWidth: 0 } }}
|
||||
value="..." selectedOptions={[]} expandIcon={null}
|
||||
onOptionSelect={(_, data) => {
|
||||
if (data.optionValue) {
|
||||
commonStore.setSettings({
|
||||
apiCompletionModelName: data.optionValue
|
||||
});
|
||||
}
|
||||
}}>
|
||||
{
|
||||
['rwkv', 'text-davinci-003', 'text-davinci-002', 'text-curie-001', 'text-babbage-001', 'text-ada-001']
|
||||
.map((v, i) =>
|
||||
<Option key={i} value={v}>{v}</Option>
|
||||
)
|
||||
}
|
||||
</Dropdown>
|
||||
</div>
|
||||
} />
|
||||
</div>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
1127
frontend/src/pages/defaultModelConfigs.ts
Normal file
@@ -3,8 +3,8 @@ import { GetPlatform, ReadJson } from '../wailsjs/go/backend_golang/App';
|
||||
import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshModels } from './utils';
|
||||
import { getStatus } from './apis';
|
||||
import { EventsOn } from '../wailsjs/runtime';
|
||||
import { defaultModelConfigs } from './pages/Configs';
|
||||
import manifest from '../../manifest.json';
|
||||
import { defaultModelConfigs, defaultModelConfigsMac } from './pages/defaultModelConfigs';
|
||||
|
||||
export async function startup() {
|
||||
downloadProgramFiles();
|
||||
@@ -54,7 +54,7 @@ async function initConfig() {
|
||||
configData.currentModelConfigIndex >= 0 && configData.currentModelConfigIndex < configData.modelConfigs.length)
|
||||
commonStore.setCurrentConfigIndex(configData.currentModelConfigIndex, false);
|
||||
}).catch(() => {
|
||||
commonStore.setModelConfigs(defaultModelConfigs, true);
|
||||
commonStore.setModelConfigs(commonStore.platform != 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import { makeAutoObservable } from 'mobx';
|
||||
import { getUserLanguage, isSystemLightMode, saveConfigs } from '../utils';
|
||||
import { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime';
|
||||
import manifest from '../../../manifest.json';
|
||||
import { defaultModelConfigs, ModelConfig } from '../pages/Configs';
|
||||
import { Conversations } from '../pages/Chat';
|
||||
import { ModelConfig } from '../pages/Configs';
|
||||
import { Conversation } from '../pages/Chat';
|
||||
import { ModelSourceItem } from '../pages/Models';
|
||||
import { DownloadStatus } from '../pages/Downloads';
|
||||
import { SettingsType } from '../pages/Settings';
|
||||
@@ -11,6 +11,8 @@ import { IntroductionContent } from '../pages/Home';
|
||||
import { AboutContent } from '../pages/About';
|
||||
import i18n from 'i18next';
|
||||
import { CompletionPreset } from '../pages/Completion';
|
||||
import { defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultModelConfigs';
|
||||
import commonStore from './commonStore';
|
||||
|
||||
export enum ModelStatus {
|
||||
Offline,
|
||||
@@ -39,8 +41,9 @@ class CommonStore {
|
||||
// home
|
||||
introduction: IntroductionContent = manifest.introduction;
|
||||
// chat
|
||||
conversations: Conversations = {};
|
||||
conversationsOrder: string[] = [];
|
||||
currentInput: string = '';
|
||||
conversation: Conversation = {};
|
||||
conversationOrder: string[] = [];
|
||||
// completion
|
||||
completionPreset: CompletionPreset | null = null;
|
||||
completionGenerating: boolean = false;
|
||||
@@ -53,6 +56,7 @@ class CommonStore {
|
||||
// downloads
|
||||
downloadList: DownloadStatus[] = [];
|
||||
// settings
|
||||
advancedCollapsed: boolean = true;
|
||||
settings: SettingsType = {
|
||||
language: getUserLanguage(),
|
||||
darkMode: !isSystemLightMode(),
|
||||
@@ -60,8 +64,13 @@ class CommonStore {
|
||||
giteeUpdatesSource: getUserLanguage() === 'zh',
|
||||
cnMirror: getUserLanguage() === 'zh',
|
||||
host: '127.0.0.1',
|
||||
dpiScaling: 100,
|
||||
customModelsPath: './models',
|
||||
customPythonPath: ''
|
||||
customPythonPath: '',
|
||||
apiUrl: '',
|
||||
apiKey: 'sk-',
|
||||
apiChatModelName: 'rwkv',
|
||||
apiCompletionModelName: 'rwkv'
|
||||
};
|
||||
// about
|
||||
about: AboutContent = manifest.about;
|
||||
@@ -98,7 +107,8 @@ class CommonStore {
|
||||
|
||||
createModelConfig = (config: ModelConfig = defaultModelConfigs[0], saveConfig: boolean = true) => {
|
||||
if (config.name === defaultModelConfigs[0].name) {
|
||||
config = JSON.parse(JSON.stringify(config)); // deep copy
|
||||
// deep copy
|
||||
config = JSON.parse(JSON.stringify(commonStore.platform != 'darwin' ? defaultModelConfigs[0] : defaultModelConfigsMac[0]));
|
||||
config.name = new Date().toLocaleString();
|
||||
}
|
||||
this.modelConfigs.push(config);
|
||||
@@ -160,12 +170,12 @@ class CommonStore {
|
||||
this.downloadList = value;
|
||||
};
|
||||
|
||||
setConversations = (value: Conversations) => {
|
||||
this.conversations = value;
|
||||
setConversation = (value: Conversation) => {
|
||||
this.conversation = value;
|
||||
};
|
||||
|
||||
setConversationsOrder = (value: string[]) => {
|
||||
this.conversationsOrder = value;
|
||||
setConversationOrder = (value: string[]) => {
|
||||
this.conversationOrder = value;
|
||||
};
|
||||
|
||||
setCompletionPreset(value: CompletionPreset) {
|
||||
@@ -179,6 +189,14 @@ class CommonStore {
|
||||
setPlatform(value: Platform) {
|
||||
this.platform = value;
|
||||
}
|
||||
|
||||
setCurrentInput(value: string) {
|
||||
this.currentInput = value;
|
||||
}
|
||||
|
||||
setAdvancedCollapsed(value: boolean) {
|
||||
this.advancedCollapsed = value;
|
||||
}
|
||||
}
|
||||
|
||||
export default new CommonStore();
|
||||
@@ -137,8 +137,10 @@ export const getStrategy = (modelConfig: ModelConfig | undefined = undefined) =>
|
||||
strategy += params.precision === 'fp16' ? 'fp16' : params.precision === 'int8' ? 'fp16i8' : 'fp32';
|
||||
if (params.storedLayers < params.maxStoredLayers)
|
||||
strategy += ` *${params.storedLayers}+`;
|
||||
if (params.enableHighPrecisionForLastLayer)
|
||||
strategy += ' -> cpu fp32 *1';
|
||||
break;
|
||||
case 'MPS':
|
||||
strategy += 'mps ';
|
||||
strategy += params.precision === 'fp16' ? 'fp16' : params.precision === 'int8' ? 'fp16i8' : 'fp32';
|
||||
break;
|
||||
case 'Custom':
|
||||
strategy = params.customStrategy || '';
|
||||
@@ -248,10 +250,17 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) {
|
||||
toast(t('Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.'), {
|
||||
type: 'info',
|
||||
position: 'bottom-left',
|
||||
autoClose: 10000
|
||||
autoClose: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
UpdateApp(updateUrl).catch((e) => {
|
||||
UpdateApp(updateUrl).then(() => {
|
||||
toast(t('Update completed, please restart the program.'), {
|
||||
type: 'success',
|
||||
position: 'bottom-left',
|
||||
autoClose: false
|
||||
}
|
||||
);
|
||||
}).catch((e) => {
|
||||
toast(t('Update Error') + ' - ' + e.message || e, {
|
||||
type: 'error',
|
||||
position: 'bottom-left',
|
||||
|
||||
6
frontend/wailsjs/go/backend_golang/App.d.ts
generated
vendored
@@ -24,7 +24,9 @@ export function InstallPyDep(arg1:string,arg2:boolean):Promise<string>;
|
||||
|
||||
export function ListDirFiles(arg1:string):Promise<Array<backend_golang.FileInfo>>;
|
||||
|
||||
export function OpenFileFolder(arg1:string):Promise<void>;
|
||||
export function OpenFileFolder(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function OpenSaveFileDialog(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
|
||||
export function PauseDownload(arg1:string):Promise<void>;
|
||||
|
||||
@@ -32,6 +34,8 @@ export function ReadFileInfo(arg1:string):Promise<backend_golang.FileInfo>;
|
||||
|
||||
export function ReadJson(arg1:string):Promise<any>;
|
||||
|
||||
export function RestartApp():Promise<void>;
|
||||
|
||||
export function SaveJson(arg1:string,arg2:any):Promise<void>;
|
||||
|
||||
export function StartServer(arg1:string,arg2:number,arg3:string):Promise<string>;
|
||||
|
||||
12
frontend/wailsjs/go/backend_golang/App.js
generated
@@ -46,8 +46,12 @@ export function ListDirFiles(arg1) {
|
||||
return window['go']['backend_golang']['App']['ListDirFiles'](arg1);
|
||||
}
|
||||
|
||||
export function OpenFileFolder(arg1) {
|
||||
return window['go']['backend_golang']['App']['OpenFileFolder'](arg1);
|
||||
export function OpenFileFolder(arg1, arg2) {
|
||||
return window['go']['backend_golang']['App']['OpenFileFolder'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenSaveFileDialog(arg1, arg2, arg3) {
|
||||
return window['go']['backend_golang']['App']['OpenSaveFileDialog'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function PauseDownload(arg1) {
|
||||
@@ -62,6 +66,10 @@ export function ReadJson(arg1) {
|
||||
return window['go']['backend_golang']['App']['ReadJson'](arg1);
|
||||
}
|
||||
|
||||
export function RestartApp() {
|
||||
return window['go']['backend_golang']['App']['RestartApp']();
|
||||
}
|
||||
|
||||
export function SaveJson(arg1, arg2) {
|
||||
return window['go']['backend_golang']['App']['SaveJson'](arg1, arg2);
|
||||
}
|
||||
|
||||
21
main.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
@@ -29,18 +31,35 @@ func main() {
|
||||
backend.CopyEmbed(cyac)
|
||||
backend.CopyEmbed(cyacInfo)
|
||||
backend.CopyEmbed(py)
|
||||
os.Mkdir("models", os.ModePerm)
|
||||
}
|
||||
|
||||
// Create an instance of the app structure
|
||||
app := backend.NewApp()
|
||||
|
||||
var zoomFactor float64 = 1.0
|
||||
data, err := app.ReadJson("config.json")
|
||||
if err == nil {
|
||||
app.HasConfigData = true
|
||||
app.ConfigData = data.(map[string]any)
|
||||
if dpiScaling, ok := app.ConfigData["settings"].(map[string]any)["dpiScaling"]; ok {
|
||||
zoomFactor = dpiScaling.(float64) / 100
|
||||
}
|
||||
} else {
|
||||
app.HasConfigData = false
|
||||
}
|
||||
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
err = wails.Run(&options.App{
|
||||
Title: "RWKV-Runner",
|
||||
Width: 1024,
|
||||
Height: 680,
|
||||
MinWidth: 375,
|
||||
MinHeight: 640,
|
||||
Windows: &windows.Options{
|
||||
ZoomFactor: zoomFactor,
|
||||
IsZoomControlEnabled: true,
|
||||
},
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
|
||||
607
manifest.json
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.1.6",
|
||||
"version": "1.2.5",
|
||||
"introduction": {
|
||||
"en": "RWKV is an open-source, commercially usable large language model with high flexibility and great potential for development.\n### About This Tool\nThis tool aims to lower the barrier of entry for using large language models, making it accessible to everyone. It provides fully automated dependency and model management. You simply need to click and run, following the instructions, to deploy a local large language model. The tool itself is very compact and only requires a single executable file for one-click deployment.\nAdditionally, this tool offers an interface that is fully compatible with the OpenAI API. This means you can use any ChatGPT client as a client for RWKV, enabling capability expansion beyond just chat functionality.\n### Preset Configuration Rules at the Bottom\nThis tool comes with a series of preset configurations to reduce complexity. The naming rules for each configuration represent the following in order: device - required VRAM/memory - model size - model language.\nFor example, \"GPU-8G-3B-EN\" indicates that this configuration is for a graphics card with 8GB of VRAM, a model size of 3 billion parameters, and it uses an English language model.\nLarger model sizes have higher performance and VRAM requirements. Among configurations with the same model size, those with higher VRAM usage will have faster runtime.\nFor example, if you have 12GB of VRAM but running the \"GPU-12G-7B-EN\" configuration is slow, you can downgrade to \"GPU-8G-3B-EN\" for a significant speed improvement.\n### About RWKV\nRWKV is an RNN with Transformer-level LLM performance, which can also be directly trained like a GPT transformer (parallelizable). And it's 100% attention-free. You only need the hidden state at position t to compute the state at position t+1. You can use the \"GPT\" mode to quickly compute the hidden state for the \"RNN\" mode.<br/>So it's combining the best of RNN and transformer - great performance, fast inference, saves VRAM, fast training, \"infinite\" ctx_len, and free sentence embedding (using the final hidden state).",
|
||||
"zh": "RWKV是一个开源且允许商用的大语言模型,灵活性很高且极具发展潜力。\n### 关于本工具\n本工具旨在降低大语言模型的使用门槛,做到人人可用,本工具提供了全自动化的依赖和模型管理,你只需要直接点击运行,跟随引导,即可完成本地大语言模型的部署,工具本身体积极小,只需要一个exe即可完成一键部署。\n此外,本工具提供了与OpenAI API完全兼容的接口,这意味着你可以把任意ChatGPT客户端用作RWKV的客户端,实现能力拓展,而不局限于聊天。\n### 底部的预设配置规则\n本工具内置了一系列预设配置,以降低使用难度,每个配置名的规则,依次代表着:设备-所需显存/内存-模型规模-模型语言。\n例如,GPU-8G-3B-CN,表示该配置用于显卡,需要8G显存,模型规模为30亿参数,使用的是中文模型。\n模型规模越大,性能要求越高,显存要求也越高,而同样模型规模的配置中,显存占用越高的,运行速度越快。\n例如当你有12G显存,但运行GPU-12G-7B-CN配置速度比较慢,可降级成GPU-8G-3B-CN,将会大幅提速。\n### 关于RWKV\nRWKV是具有Transformer级别LLM性能的RNN,也可以像GPT Transformer一样直接进行训练(可并行化)。而且它是100% attention-free的。你只需在位置t处获得隐藏状态即可计算位置t + 1处的状态。你可以使用“GPT”模式快速计算用于“RNN”模式的隐藏状态。\n因此,它将RNN和Transformer的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"
|
||||
@@ -16,16 +16,341 @@
|
||||
],
|
||||
"models": [
|
||||
{
|
||||
"name": "RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth",
|
||||
"name": "RWKV-4-World-CHNtuned-0.1B-v1-20230617-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Chinese 3B v12",
|
||||
"zh": "中文 3B v12"
|
||||
"en": "100+ Languages 0.1B v1 Enhanced Chinese",
|
||||
"zh": "100+ 语言 0.1B v1 中文增强"
|
||||
},
|
||||
"size": 5969345330,
|
||||
"SHA256": "c0abb4b745ba3523b9d8b3e1293110867ee55b1ef3dc8c122212f78396755721",
|
||||
"lastUpdated": "2023-05-28T11:51:12",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-3B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230527-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-3B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230527-ctx4096.pth"
|
||||
"size": 385594610,
|
||||
"SHA256": "a3888f9958d378ee6d4976ae1c02edb698f4382e426086febafb4a69417b9080",
|
||||
"lastUpdated": "2023-06-17T18:35:26",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-CHNtuned-0.1B-v1-20230617-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-CHNtuned-0.1B-v1-20230617-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-0.1B-v1-20230520-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 0.1B v1",
|
||||
"zh": "100+ 语言 0.1B v1"
|
||||
},
|
||||
"size": 385594610,
|
||||
"SHA256": "a10ef99df2a8f8a6801edf4fc92a9c49bedd63dcb900d3e5667a2136b3d671e7",
|
||||
"lastUpdated": "2023-05-25T09:21:27",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-CHNtuned-0.4B-v1-20230618-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 0.4B v1 Enhanced Chinese",
|
||||
"zh": "100+ 语言 0.4B v1 中文增强"
|
||||
},
|
||||
"size": 923362866,
|
||||
"SHA256": "dbd5302cbee596bbc900f97eb10b2af3001a7f2c7e4d8643bf8683b2cdbdd324",
|
||||
"lastUpdated": "2023-06-18T10:46:50",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-CHNtuned-0.4B-v1-20230618-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-CHNtuned-0.4B-v1-20230618-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-0.4B-v1-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 0.4B v1",
|
||||
"zh": "100+ 语言 0.4B v1"
|
||||
},
|
||||
"size": 923362866,
|
||||
"SHA256": "4b4a2733cf5e5dc97dd62106f391d99895d16b11c5ccd10c89f28c52067a4919",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-0.4B-v1-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-0.4B-v1-20230529-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-CHNtuned-1.5B-v1-20230620-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1 Enhanced Chinese",
|
||||
"zh": "100+ 语言 1.5B v1 中文增强"
|
||||
},
|
||||
"size": 3155281586,
|
||||
"SHA256": "9f31f2ed5fe52dcf2d50208eb2efd764b9674dba2adb1baeff61997b4390a26b",
|
||||
"lastUpdated": "2023-06-20T06:35:37",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-CHNtuned-1.5B-v1-20230620-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-CHNtuned-1.5B-v1-20230620-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-1.5B-v1-OnlyForTest_57%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1 Test",
|
||||
"zh": "100+ 语言 1.5B v1 测试"
|
||||
},
|
||||
"size": 3155281581,
|
||||
"SHA256": "ac36770931776c5aa179690918c9a3b0b5f4ebe3301ea3574a7e182209778788",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-1.5B-v1-OnlyForTest_57%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-OnlyForTest_57%25_trained-20230529-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-1.5B-v1-OnlyForTest_81%_trained-20230603-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1 Test",
|
||||
"zh": "100+ 语言 1.5B v1 测试"
|
||||
},
|
||||
"size": 3155281581,
|
||||
"SHA256": "044fb10daa71f4c012493ac8ef455c8c3301095b5f009dae58f0f6382a53e23c",
|
||||
"lastUpdated": "2023-06-03T13:57:20",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-1.5B-v1-OnlyForTest_81%25_trained-20230603-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-OnlyForTest_81%25_trained-20230603-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-1.5B-v1-20230607-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1",
|
||||
"zh": "100+ 语言 1.5B v1"
|
||||
},
|
||||
"size": 3155281586,
|
||||
"SHA256": "05bad4ab0ce41250064153d5352587b83215a82eb50134489675129bd4ad1087",
|
||||
"lastUpdated": "2023-06-07T09:33:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-1.5B-v1-20230607-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-20230607-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1 fixed",
|
||||
"zh": "100+ 语言 1.5B v1 修复"
|
||||
},
|
||||
"size": 3155281586,
|
||||
"SHA256": "71f0c3229f9227cbcb8ae5fee6461197129a57e26366c4d23a49058417b046c9",
|
||||
"lastUpdated": "2023-06-12T06:31:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-OnlyForTest_35%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1 Test",
|
||||
"zh": "100+ 语言 3B v1 测试"
|
||||
},
|
||||
"size": 6125597613,
|
||||
"SHA256": "e4ee6e91a80d56de43bc79841f3a8be3b7b215d7d9788f79c467b9b1f7f03cb8",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-OnlyForTest_35%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-OnlyForTest_35%25_trained-20230529-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-OnlyForTest_52%_trained-20230603-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1 Test",
|
||||
"zh": "100+ 语言 3B v1 测试"
|
||||
},
|
||||
"size": 6125597613,
|
||||
"SHA256": "aad3671078a0c686368add4f4b695a76c2ba1ddd505a64c0949bb003beeee9a3",
|
||||
"lastUpdated": "2023-06-03T13:57:20",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-OnlyForTest_52%25_trained-20230603-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-OnlyForTest_52%25_trained-20230603-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-OnlyForTest_64%_trained-20230607-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1 Test",
|
||||
"zh": "100+ 语言 3B v1 测试"
|
||||
},
|
||||
"size": 6125597613,
|
||||
"SHA256": "49e8675e09e0786ca12a554442c37b9e809ed93e9211af937cd149968a6b81e9",
|
||||
"lastUpdated": "2023-06-07T09:33:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-OnlyForTest_64%25_trained-20230607-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-OnlyForTest_64%25_trained-20230607-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1 Test",
|
||||
"zh": "100+ 语言 3B v1 测试"
|
||||
},
|
||||
"size": 6125597613,
|
||||
"SHA256": "3bb10caf3017871435d83f39facc8a729fd774020390153470f004eb3ef645bd",
|
||||
"lastUpdated": "2023-06-12T06:31:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-OnlyForTest_80%25_trained-20230612-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-OnlyForTest_80%25_trained-20230612-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-20230619-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1",
|
||||
"zh": "100+ 语言 3B v1"
|
||||
},
|
||||
"size": 6125597618,
|
||||
"SHA256": "1b227af317fa25b6939ab3c7cd321226ca48b8fe4bbbd2df3db669f1482c54ba",
|
||||
"lastUpdated": "2023-06-20T03:00:51",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-20230619-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-20230619-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_30%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "05f91562b2ae8b025226e40b3fb536d6f8eb3c142ac899c0808ee1c9dc189ec4",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_30%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_30%25_trained-20230529-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_40%_trained-20230601-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "63c060c472e45b6c3af2baaaee448ffd95f9b46e3cc6e1ef70ce7ecb1d01bcfa",
|
||||
"lastUpdated": "2023-06-02T00:09:39",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_40%25_trained-20230601-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_40%25_trained-20230601-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_52%_trained-20230606-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "636405626eadbab230e1a7dc2855bb6244e09b5850547dda7103f650b4849de7",
|
||||
"lastUpdated": "2023-06-06T14:21:31",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_52%25_trained-20230606-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_52%25_trained-20230606-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "8039be276f555318a5b2e9ad82b9d70001c12bd2e3e668048615fc7b09d5d9a4",
|
||||
"lastUpdated": "2023-06-11T01:58:29",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_64%25_trained-20230610-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_64%25_trained-20230610-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_75%_trained-20230615-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "a5f4246a18698a350a49988de7a8a01cbd765f8d11ee6427cabb93bf659f2d0d",
|
||||
"lastUpdated": "2023-06-15T15:09:11",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_75%25_trained-20230615-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_75%25_trained-20230615-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_84%_trained-20230618-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "dfb56e8ba32907cb47df83c8d702e7f350d9ad50a59b71b031da4681637588b3",
|
||||
"lastUpdated": "2023-06-19T01:28:17",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_84%25_trained-20230618-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_84%25_trained-20230618-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Professional Writer 7B v1",
|
||||
"zh": "专业写作 7B v1"
|
||||
},
|
||||
"size": 14785389618,
|
||||
"SHA256": "cd40b661930dea46c0f930c51d99cef6b484fe3d641388981dee5a0c68e2b1c7",
|
||||
"lastUpdated": "2023-04-10T13:55:52",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Balanced Writer 3B v1",
|
||||
"zh": "均衡写作 3B v1"
|
||||
},
|
||||
"size": 5969345064,
|
||||
"SHA256": "283c6e6fa10c52a93e9a01d9630f288473267ea152a49c6579b5c0427bdc9c61",
|
||||
"lastUpdated": "2023-04-12T13:18:29",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "Balanced Writer 7B v1",
|
||||
"zh": "均衡写作 7B v1"
|
||||
},
|
||||
"size": 14785389864,
|
||||
"SHA256": "bd08c75a296bd193dcfadb993fe06d7f9dd91ca3385231f24c592c89d25cd596",
|
||||
"lastUpdated": "2023-04-26T18:57:01",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Popular Writer 3B v1",
|
||||
"zh": "通俗写作 3B v1"
|
||||
},
|
||||
"size": 5969345064,
|
||||
"SHA256": "c41e0af2cbc66e94121377680e8224a1504fac6c9ea620c395f0a79281db26e7",
|
||||
"lastUpdated": "2023-04-12T13:18:29",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "Popular Writer 7B v1",
|
||||
"zh": "通俗写作 7B v1"
|
||||
},
|
||||
"size": 14785389864,
|
||||
"SHA256": "5fced44febdf80d303250eef9c020f087abded43aaecc8caaea8a9e7f1fb771e",
|
||||
"lastUpdated": "2023-04-26T18:57:01",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-1B5-v11-Eng99%-Other1%-20230425-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "English 1.5B v11",
|
||||
"zh": "英文 1.5B v11"
|
||||
},
|
||||
"size": 3030279730,
|
||||
"SHA256": "4ac715aecc5b1c90e8e37eebb8163392699066ec23b18144416e91cb4e78675a",
|
||||
"lastUpdated": "2023-04-26T14:27:55",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-1B5-v11-Eng99%25-Other1%25-20230425-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-1B5-v11-Eng99%25-Other1%25-20230425-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "English 1B5 v12",
|
||||
"zh": "英文 1B5 v12"
|
||||
},
|
||||
"size": 3030279730,
|
||||
"SHA256": "6bbbffb3ee2372dfa9ef49c599e9a2bc0a01b94b6a264ba9bf5bd524fc38f723",
|
||||
"lastUpdated": "2023-05-21T07:08:56",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-1B5-v12-Eng98%25-Other2%25-20230520-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-1B5-v12-Eng98%25-Other2%25-20230520-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-3B-v11-Eng99%-Other1%-20230425-ctx4096.pth",
|
||||
@@ -52,6 +377,56 @@
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-3B-v12-Eng98%25-Other2%25-20230520-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-3B-v12-Eng98%25-Other2%25-20230520-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-3B-v11-Eng49%-Chn49%-Jpn1%-Other1%-20230429-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Chinese 3B v11",
|
||||
"zh": "中文 3B v11"
|
||||
},
|
||||
"size": 5969345074,
|
||||
"SHA256": "af12300d9875e0e166c23d6e9b20928db435073060bf1d36f874060de92ada98",
|
||||
"lastUpdated": "2023-04-29T11:51:51",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-3B-v11-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230429-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-3B-v11-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230429-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Chinese 3B v12",
|
||||
"zh": "中文 3B v12"
|
||||
},
|
||||
"size": 5969345330,
|
||||
"SHA256": "c0abb4b745ba3523b9d8b3e1293110867ee55b1ef3dc8c122212f78396755721",
|
||||
"lastUpdated": "2023-05-28T11:51:12",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-3B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230527-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-3B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230527-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-7B-v11x-Eng99%-Other1%-20230429-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "English 7B v11x",
|
||||
"zh": "英文 7B v11x"
|
||||
},
|
||||
"size": 14785389874,
|
||||
"SHA256": "f00d5c75b453f2b20ad875fb5a324564c34024eea25a015f5eb441e4f364c3fe",
|
||||
"lastUpdated": "2023-04-29T11:44:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-7B-v11x-Eng99%25-Other1%25-20230429-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-7B-v11x-Eng99%25-Other1%25-20230429-ctx8192.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "English 7B v12",
|
||||
"zh": "英文 7B v12"
|
||||
},
|
||||
"size": 14785389618,
|
||||
"SHA256": "5a725eaeb9e09b724de6c97e6845dd0283097c7920acd05b46852ab7afa9ec32",
|
||||
"lastUpdated": "2023-05-22T10:32:17",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-7B-v12-Eng98%25-Other2%25-20230521-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-7B-v12-Eng98%25-Other2%25-20230521-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-7B-v10x-Eng49%-Chn50%-Other1%-20230423-ctx4096.pth",
|
||||
"desc": {
|
||||
@@ -90,81 +465,6 @@
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-7B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230530-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-7B-v12-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230530-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "English 7B v12",
|
||||
"zh": "英文 7B v12"
|
||||
},
|
||||
"size": 14785389618,
|
||||
"SHA256": "5a725eaeb9e09b724de6c97e6845dd0283097c7920acd05b46852ab7afa9ec32",
|
||||
"lastUpdated": "2023-05-22T10:32:17",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-7B-v12-Eng98%25-Other2%25-20230521-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-7B-v12-Eng98%25-Other2%25-20230521-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-7B-v11x-Eng99%-Other1%-20230429-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "English 7B v11x",
|
||||
"zh": "英文 7B v11x"
|
||||
},
|
||||
"size": 14785389874,
|
||||
"SHA256": "f00d5c75b453f2b20ad875fb5a324564c34024eea25a015f5eb441e4f364c3fe",
|
||||
"lastUpdated": "2023-04-29T11:44:32",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-7B-v11x-Eng99%25-Other1%25-20230429-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-7B-v11x-Eng99%25-Other1%25-20230429-ctx8192.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-1B5-v11-Eng99%-Other1%-20230425-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "English 1.5B v11",
|
||||
"zh": "英文 1.5B v11"
|
||||
},
|
||||
"size": 3030279730,
|
||||
"SHA256": "4ac715aecc5b1c90e8e37eebb8163392699066ec23b18144416e91cb4e78675a",
|
||||
"lastUpdated": "2023-04-26T14:27:55",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-1B5-v11-Eng99%25-Other1%25-20230425-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-1B5-v11-Eng99%25-Other1%25-20230425-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "English 1B5 v12",
|
||||
"zh": "英文 1B5 v12"
|
||||
},
|
||||
"size": 3030279730,
|
||||
"SHA256": "6bbbffb3ee2372dfa9ef49c599e9a2bc0a01b94b6a264ba9bf5bd524fc38f723",
|
||||
"lastUpdated": "2023-05-21T07:08:56",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-1B5-v12-Eng98%25-Other2%25-20230520-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-1B5-v12-Eng98%25-Other2%25-20230520-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-3B-v11-Eng49%-Chn49%-Jpn1%-Other1%-20230429-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Chinese 3B v11",
|
||||
"zh": "中文 3B v11"
|
||||
},
|
||||
"size": 5969345074,
|
||||
"SHA256": "af12300d9875e0e166c23d6e9b20928db435073060bf1d36f874060de92ada98",
|
||||
"lastUpdated": "2023-04-29T11:51:51",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-3B-v11-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230429-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-3B-v11-Eng49%25-Chn49%25-Jpn1%25-Other1%25-20230429-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "English 14B v12",
|
||||
"zh": "英文 14B v12"
|
||||
},
|
||||
"size": 28297309490,
|
||||
"SHA256": "1193b5a9ceab572e4dbb9ed1d798eab7bf4793d18904d08bd4bf183579338ae7",
|
||||
"lastUpdated": "2023-05-23T11:22:41",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-14B-v12-Eng98%25-Other2%25-20230523-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-14B-v12-Eng98%25-Other2%25-20230523-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Raven-14B-v11x-Eng99%-Other1%-20230501-ctx8192.pth",
|
||||
"desc": {
|
||||
@@ -179,137 +479,16 @@
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth",
|
||||
"name": "RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "Professional Writer 7B v1",
|
||||
"zh": "专业写作 7B v1"
|
||||
"en": "English 14B v12",
|
||||
"zh": "英文 14B v12"
|
||||
},
|
||||
"size": 14785389618,
|
||||
"SHA256": "cd40b661930dea46c0f930c51d99cef6b484fe3d641388981dee5a0c68e2b1c7",
|
||||
"lastUpdated": "2023-04-10T13:55:52",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "Popular Writer 7B v1",
|
||||
"zh": "通俗写作 7B v1"
|
||||
},
|
||||
"size": 14785389864,
|
||||
"SHA256": "5fced44febdf80d303250eef9c020f087abded43aaecc8caaea8a9e7f1fb771e",
|
||||
"lastUpdated": "2023-04-26T18:57:01",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-Chn-20230426-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Popular Writer 3B v1",
|
||||
"zh": "通俗写作 3B v1"
|
||||
},
|
||||
"size": 5969345064,
|
||||
"SHA256": "c41e0af2cbc66e94121377680e8224a1504fac6c9ea620c395f0a79281db26e7",
|
||||
"lastUpdated": "2023-04-12T13:18:29",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-3B-v1-Chn-20230412-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "Balanced Writer 3B v1",
|
||||
"zh": "均衡写作 3B v1"
|
||||
},
|
||||
"size": 5969345064,
|
||||
"SHA256": "283c6e6fa10c52a93e9a01d9630f288473267ea152a49c6579b5c0427bdc9c61",
|
||||
"lastUpdated": "2023-04-12T13:18:29",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-3B-v1-ChnEng-20230412-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth",
|
||||
"desc": {
|
||||
"en": "Balanced Writer 7B v1",
|
||||
"zh": "均衡写作 7B v1"
|
||||
},
|
||||
"size": 14785389864,
|
||||
"SHA256": "bd08c75a296bd193dcfadb993fe06d7f9dd91ca3385231f24c592c89d25cd596",
|
||||
"lastUpdated": "2023-04-26T18:57:01",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-novel/blob/main/RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-novel/resolve/main/RWKV-4-Novel-7B-v1-ChnEng-20230426-ctx8192.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_40%_trained-20230601-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "63c060c472e45b6c3af2baaaee448ffd95f9b46e3cc6e1ef70ce7ecb1d01bcfa",
|
||||
"lastUpdated": "2023-06-02T00:09:39",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_40%25_trained-20230601-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_40%25_trained-20230601-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-7B-v1-OnlyForTest_30%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 7B v1 Test",
|
||||
"zh": "100+ 语言 7B v1 测试"
|
||||
},
|
||||
"size": 15035393581,
|
||||
"SHA256": "05f91562b2ae8b025226e40b3fb536d6f8eb3c142ac899c0808ee1c9dc189ec4",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-7B-v1-OnlyForTest_30%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-7B-v1-OnlyForTest_30%25_trained-20230529-ctx4096.pth",
|
||||
"hide": true
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-0.1B-v1-20230520-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 0.1B v1",
|
||||
"zh": "100+ 语言 0.1B v1"
|
||||
},
|
||||
"size": 385594610,
|
||||
"SHA256": "a10ef99df2a8f8a6801edf4fc92a9c49bedd63dcb900d3e5667a2136b3d671e7",
|
||||
"lastUpdated": "2023-05-25T09:21:27",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-0.1B-v1-20230520-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-1.5B-v1-OnlyForTest_57%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 1.5B v1 Test",
|
||||
"zh": "100+ 语言 1.5B v1 测试"
|
||||
},
|
||||
"size": 3155281581,
|
||||
"SHA256": "ac36770931776c5aa179690918c9a3b0b5f4ebe3301ea3574a7e182209778788",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-1.5B-v1-OnlyForTest_57%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-1.5B-v1-OnlyForTest_57%25_trained-20230529-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-3B-v1-OnlyForTest_35%_trained-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 3B v1 Test",
|
||||
"zh": "100+ 语言 3B v1 测试"
|
||||
},
|
||||
"size": 6125597613,
|
||||
"SHA256": "e4ee6e91a80d56de43bc79841f3a8be3b7b215d7d9788f79c467b9b1f7f03cb8",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-3B-v1-OnlyForTest_35%25_trained-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-3B-v1-OnlyForTest_35%25_trained-20230529-ctx4096.pth"
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-0.4B-v1-20230529-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "100+ Languages 0.4B v1",
|
||||
"zh": "100+ 语言 0.4B v1"
|
||||
},
|
||||
"size": 923362866,
|
||||
"SHA256": "4b4a2733cf5e5dc97dd62106f391d99895d16b11c5ccd10c89f28c52067a4919",
|
||||
"lastUpdated": "2023-05-29T13:25:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-world/blob/main/RWKV-4-World-0.4B-v1-20230529-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-world/resolve/main/RWKV-4-World-0.4B-v1-20230529-ctx4096.pth"
|
||||
"size": 28297309490,
|
||||
"SHA256": "1193b5a9ceab572e4dbb9ed1d798eab7bf4793d18904d08bd4bf183579338ae7",
|
||||
"lastUpdated": "2023-05-23T11:22:41",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-14B-v12-Eng98%25-Other2%25-20230523-ctx8192.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-14B-v12-Eng98%25-Other2%25-20230523-ctx8192.pth"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||