Compare commits

..

19 Commits

Author SHA1 Message Date
josc146
e0e846a191 release v1.2.3 2023-06-14 22:52:22 +08:00
josc146
e9cc9b0798 add additional startup condition 2023-06-14 22:50:20 +08:00
josc146
51c5696bb9 improve python dependencies installation 2023-06-14 22:21:17 +08:00
josc146
64f0610ed7 improve OpenFileFolder 2023-06-14 21:11:08 +08:00
josc146
1591430742 reset confirm for completion page 2023-06-14 20:45:52 +08:00
josc146
17c690dfb1 remember current chat input 2023-06-14 20:26:04 +08:00
josc146
4b640f884b global sse AbortController 2023-06-14 20:06:19 +08:00
github-actions[bot]
8976764ee5 release v1.2.2 2023-06-13 15:22:04 +00:00
josc146
47db663fcd release v1.2.2 2023-06-13 23:21:39 +08:00
josc146
366e67bb6e improve built-in user guides 2023-06-13 23:18:04 +08:00
josc146
b52bae6e17 update Instruction template 2023-06-13 23:15:21 +08:00
josc146
714b8834c7 chore 2023-06-13 22:47:17 +08:00
josc146
631704d04d update models and configs 2023-06-13 22:46:41 +08:00
josc146
5896593951 max_trie_len 2023-06-12 15:22:17 +08:00
josc146
8431b5d24f log Generation Prompt 2023-06-12 13:41:51 +08:00
josc146
bbd1ac1484 allow unloading model with switch-model 2023-06-12 12:34:03 +08:00
josc146
5990567a79 avoid misoperations of state_cache 2023-06-12 12:32:50 +08:00
josc146
fa0fcc2c89 add support for python3.8 3.9 2023-06-12 12:09:23 +08:00
github-actions[bot]
face4c97e8 release v1.2.1 2023-06-09 13:17:30 +00:00
28 changed files with 705 additions and 155 deletions

View File

@@ -1,13 +1,11 @@
## Changes
- CI/CD pipeline
- update InstallPyDep for better macOS support
- improve update process for macOS and Linux
- add server deploy examples for windows and linux
- organize the structure of manifest.json
- add logs for state cache and switch-model
- fix UnboundLocalError: local variable 'response' referenced before assignment
- remove `enableHighPrecisionForLastLayer`
- global sse AbortController even if switching pages
- remember current chat input even if switching pages
- reset confirm for completion page
- improve OpenFileFolder
- improve python dependencies installation
- add additional startup condition
## Install

View File

@@ -119,8 +119,14 @@ 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) 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
}

View File

@@ -2,9 +2,11 @@ package backend_golang
import (
"errors"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
)
func (a *App) StartServer(python string, port int, host string) (string, error) {
@@ -48,6 +50,9 @@ func (a *App) InstallPyDep(python string, cnMirror bool) (string, error) {
var err error
if python == "" {
python, err = GetPython()
if runtime.GOOS == "windows" {
python = `"` + python + `"`
}
}
if err != nil {
return "", err
@@ -55,39 +60,24 @@ func (a *App) InstallPyDep(python string, cnMirror bool) (string, error) {
if runtime.GOOS == "windows" {
ChangeFileLine("./py310/python310._pth", 3, "Lib\\site-packages")
}
if runtime.GOOS == "windows" {
if cnMirror {
_, err = Cmd(python, "./backend-python/get-pip.py", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
} else {
_, err = Cmd(python, "./backend-python/get-pip.py")
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 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")
if cnMirror {
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, "-m", "pip", "install", "torch", "torchvision", "torchaudio")
}
if err != nil {
return "", err
}
if runtime.GOOS == "windows" {
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")
}
} else {
if cnMirror {
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_without_cyac.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
} else {
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_without_cyac.txt")
}
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_without_cyac.txt")
}
}

View File

@@ -17,7 +17,7 @@ import (
func Cmd(args ...string) (string, error) {
switch platform := runtime.GOOS; platform {
case "windows":
if err := os.WriteFile("./cmd-helper.bat", []byte("start /wait %*"), 0644); err != nil {
if err := os.WriteFile("./cmd-helper.bat", []byte("start %*"), 0644); err != nil {
return "", err
}
cmdHelper, err := filepath.Abs("./cmd-helper")
@@ -115,11 +115,19 @@ func GetPython() (string, error) {
if err != nil {
return "", errors.New("failed to unzip python")
} else {
return "py310/python.exe", nil
python, err := filepath.Abs("py310/python.exe")
if err != nil {
return "", err
}
return python, nil
}
}
} else {
return "py310/python.exe", nil
python, err := filepath.Abs("py310/python.exe")
if err != nil {
return "", err
}
return python, nil
}
case "darwin":
return "python3", nil

Binary file not shown.

View File

@@ -40,6 +40,9 @@ def switch_model(body: SwitchModelBody, response: Response, request: Request):
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)

View File

@@ -1,47 +1,60 @@
from typing import Any, Dict
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")
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
id = trie.insert(body.prompt)
device = body.state[0].device
dtrie[id] = {
@@ -53,16 +66,23 @@ def add_state(body: AddStateBody):
"device": device,
}
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"
@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"
@@ -72,6 +92,23 @@ 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
@router.post("/longest-prefix-state")
def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
global trie
@@ -85,7 +122,7 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
v = dtrie[id]
device = v["device"]
prompt = trie[id]
quick_log(request, body, "Hit: " + prompt)
quick_log(request, body, "Hit:\n" + prompt)
return {
"prompt": prompt,
"tokens": v["tokens"],
@@ -96,7 +133,13 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
"device": device,
}
else:
return {"prompt": "", "tokens": [], "state": None, "logits": None}
return {
"prompt": "",
"tokens": [],
"state": None,
"logits": None,
"device": None,
}
@router.post("/save-state")
@@ -105,6 +148,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"

View File

@@ -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)

View File

@@ -15,18 +15,24 @@ logger.addHandler(fh)
def quick_log(request: Request, body: Any, response: str):
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 ""
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}")

View File

@@ -2,6 +2,7 @@ import os
import pathlib
import copy
from typing import Dict, List
from utils.log import quick_log
from fastapi import HTTPException
from pydantic import BaseModel, Field
from rwkv_pip.utils import PIPELINE
@@ -101,6 +102,7 @@ The following is a coherent verbose detailed conversation between a girl named {
return out
def generate(self, prompt: str, stop: str = None):
quick_log(None, None, "Generation Prompt:\n" + prompt)
cache = None
delta_prompt = prompt
try:

View File

@@ -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": "模型参数",
@@ -78,12 +78,12 @@
"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": "暂停",
@@ -100,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手动下载并覆盖原程序",
@@ -137,10 +137,12 @@
"Custom Models Path": "自定义模型路径",
"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.": "切换模型失败, 请尝试以管理员权限启动程序",
"Failed to switch model, please try starting the program with administrator privileges or increasing your virtual memory.": "切换模型失败, 请尝试以管理员权限启动程序, 或增加你的虚拟内存",
"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.": "更新完成, 请重启程序"
"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": "模型文件下载未完成"
}

View File

@@ -13,17 +13,22 @@ import { ToolTipButton } from './ToolTipButton';
import { useTranslation } from 'react-i18next';
export const DialogButton: FC<{
icon: ReactElement,
tooltip: string,
text?: string | null
icon?: ReactElement,
tooltip?: string | null,
className?: string,
title: string,
contentText: string,
onConfirm: () => void
}> = ({ tooltip, icon, title, contentText, onConfirm }) => {
}> = ({ text, icon, tooltip, className, title, contentText, onConfirm }) => {
const { t } = useTranslation();
return <Dialog>
<DialogTrigger disableButtonEnhancement>
<ToolTipButton desc={tooltip} icon={icon} />
{tooltip ?
<ToolTipButton className={className} desc={tooltip} text={text} icon={icon} /> :
<Button className={className} icon={icon}>{text}</Button>
}
</DialogTrigger>
<DialogSurface>
<DialogBody>

View File

@@ -100,11 +100,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 });
@@ -113,7 +115,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;
}
@@ -191,7 +200,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
}).catch(() => {
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' });
toast(t('Failed to switch model, please try starting the program with administrator privileges or increasing your virtual memory.'), { type: 'error' });
else
toast(t('Failed to switch model'), { type: 'error' });
});

View File

@@ -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>
);

View File

@@ -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';
@@ -43,13 +43,13 @@ export type Conversations = {
[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;
@@ -97,9 +97,9 @@ const ChatPanel: FC = observer(() => {
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('');
}
};
@@ -150,7 +150,7 @@ const ChatPanel: FC = observer(() => {
commonStore.setConversationsOrder(commonStore.conversationsOrder);
setTimeout(scrollToBottom);
let answer = '';
sseControllerRef.current = new AbortController();
chatSseController = 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
{
method: 'POST',
@@ -163,7 +163,7 @@ const ChatPanel: FC = observer(() => {
stream: true,
model: 'gpt-3.5-turbo'
}),
signal: sseControllerRef.current?.signal,
signal: chatSseController?.signal,
onmessage(e) {
console.log('sse message', e);
scrollToBottom();
@@ -256,7 +256,7 @@ const ChatPanel: FC = observer(() => {
size="large" shape="circular" appearance="subtle"
onClick={(e) => {
if (generating)
sseControllerRef.current?.abort();
chatSseController?.abort();
commonStore.setConversations({});
commonStore.setConversationsOrder([]);
}}
@@ -266,8 +266,8 @@ const ChatPanel: FC = observer(() => {
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,7 +275,7 @@ 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;

View File

@@ -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)
@@ -187,7 +189,7 @@ const CompletionPanel: FC = observer(() => {
prompt += params.injectStart.replaceAll('\\n', '\n');
let answer = '';
sseControllerRef.current = new AbortController();
completionSseController = new AbortController();
fetchEventSource(`http://127.0.0.1:${port}/completions`, // https://api.openai.com/v1/completions || http://127.0.0.1:${port}/completions
{
method: 'POST',
@@ -206,7 +208,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();
@@ -272,7 +274,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 +285,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 +349,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);

View File

@@ -166,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
@@ -177,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) => {
@@ -237,36 +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 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;
}
<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('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) => {
@@ -310,7 +312,7 @@ export const Configs: FC = observer(() => {
{
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.')}
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
@@ -349,7 +351,7 @@ export const Configs: FC = observer(() => {
{
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) => {

View File

@@ -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>

View File

@@ -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 &&

View File

@@ -1,6 +1,63 @@
import { ModelConfig } from './Configs';
export const defaultModelConfigsMac: ModelConfig[] = [
{
name: 'MAC-0.1B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-0.1B-v1-20230520-ctx4096.pth',
device: 'MPS',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
customStrategy: 'mps fp32'
}
},
{
name: 'MAC-0.4B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-0.4B-v1-20230529-ctx4096.pth',
device: 'MPS',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
customStrategy: 'mps fp32'
}
},
{
name: 'MAC-1B5-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth',
device: 'MPS',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
customStrategy: 'mps fp32'
}
},
{
name: 'MAC-1B5-EN',
apiParameters: {
@@ -17,7 +74,25 @@ export const defaultModelConfigsMac: ModelConfig[] = [
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: false,
customStrategy: 'mps fp32'
}
},
{
name: 'MAC-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'MPS',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
customStrategy: 'mps fp32'
}
},
@@ -37,7 +112,6 @@ export const defaultModelConfigsMac: ModelConfig[] = [
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: false,
customStrategy: 'mps fp32'
}
},
@@ -57,10 +131,46 @@ export const defaultModelConfigsMac: ModelConfig[] = [
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: false,
customStrategy: 'mps fp32'
}
},
{
name: 'MAC-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'MPS',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41,
customStrategy: 'mps fp32'
}
},
{
name: 'CPU-6G-1B5-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-6G-1B5-EN',
apiParameters: {
@@ -79,6 +189,24 @@ export const defaultModelConfigsMac: ModelConfig[] = [
maxStoredLayers: 41
}
},
{
name: 'CPU-12G-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-12G-3B-EN',
apiParameters: {
@@ -115,6 +243,24 @@ export const defaultModelConfigsMac: ModelConfig[] = [
maxStoredLayers: 41
}
},
{
name: 'CPU-28G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-28G-7B-EN',
apiParameters: {
@@ -154,6 +300,24 @@ export const defaultModelConfigsMac: ModelConfig[] = [
];
export const defaultModelConfigs: ModelConfig[] = [
{
name: 'GPU-2G-0.1B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-0.1B-v1-20230520-ctx4096.pth',
device: 'CUDA',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'GPU-2G-1B5-EN',
apiParameters: {
@@ -173,6 +337,42 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-4G-0.4B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-0.4B-v1-20230529-ctx4096.pth',
device: 'CUDA',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'GPU-4G-1B5-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth',
device: 'CUDA',
precision: 'fp32',
storedLayers: 8,
maxStoredLayers: 41
}
},
{
name: 'GPU-4G-1B5-EN',
apiParameters: {
@@ -192,6 +392,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-4G-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 24,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-4G-3B-EN',
apiParameters: {
@@ -230,6 +449,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-4G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 8,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-4G-7B-EN',
apiParameters: {
@@ -287,6 +525,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-6G-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-6G-3B-EN',
apiParameters: {
@@ -325,6 +582,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-6G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 18,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-6G-7B-EN',
apiParameters: {
@@ -363,6 +639,43 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-8G-1B5-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth',
device: 'CUDA',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'GPU-8G-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'CUDA',
precision: 'fp16',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-8G-3B-EN',
apiParameters: {
@@ -401,6 +714,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-8G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 27,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-8G-7B-EN',
apiParameters: {
@@ -439,6 +771,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-10G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CUDA',
precision: 'int8',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-10G-7B-EN',
apiParameters: {
@@ -496,6 +847,25 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'GPU-16G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CUDA',
precision: 'fp16',
storedLayers: 41,
maxStoredLayers: 41,
useCustomCuda: true
}
},
{
name: 'GPU-16G-7B-EN',
apiParameters: {
@@ -591,6 +961,24 @@ export const defaultModelConfigs: ModelConfig[] = [
useCustomCuda: true
}
},
{
name: 'CPU-6G-1B5-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-1.5B-v1-fixed-20230612-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-6G-1B5-EN',
apiParameters: {
@@ -609,6 +997,24 @@ export const defaultModelConfigs: ModelConfig[] = [
maxStoredLayers: 41
}
},
{
name: 'CPU-12G-3B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-3B-v1-OnlyForTest_80%_trained-20230612-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-12G-3B-EN',
apiParameters: {
@@ -645,6 +1051,24 @@ export const defaultModelConfigs: ModelConfig[] = [
maxStoredLayers: 41
}
},
{
name: 'CPU-28G-7B-World',
apiParameters: {
apiPort: 8000,
maxResponseToken: 4100,
temperature: 1.2,
topP: 0.5,
presencePenalty: 0.4,
frequencyPenalty: 0.4
},
modelParameters: {
modelName: 'RWKV-4-World-7B-v1-OnlyForTest_64%_trained-20230610-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
maxStoredLayers: 41
}
},
{
name: 'CPU-28G-7B-EN',
apiParameters: {

View File

@@ -41,6 +41,7 @@ class CommonStore {
// home
introduction: IntroductionContent = manifest.introduction;
// chat
currentInput: string = '';
conversations: Conversations = {};
conversationsOrder: string[] = [];
// completion
@@ -182,6 +183,10 @@ class CommonStore {
setPlatform(value: Platform) {
this.platform = value;
}
setCurrentInput(value: string) {
this.currentInput = value;
}
}
export default new CommonStore();

View File

@@ -250,7 +250,7 @@ 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: 30000
autoClose: false
});
setTimeout(() => {
UpdateApp(updateUrl).then(() => {

View File

@@ -24,7 +24,7 @@ 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 PauseDownload(arg1:string):Promise<void>;

View File

@@ -46,8 +46,8 @@ 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 PauseDownload(arg1) {

View File

@@ -2,6 +2,7 @@ package main
import (
"embed"
"os"
"runtime/debug"
"strings"
@@ -29,6 +30,7 @@ func main() {
backend.CopyEmbed(cyac)
backend.CopyEmbed(cyacInfo)
backend.CopyEmbed(py)
os.Mkdir("models", os.ModePerm)
}
// Create an instance of the app structure

View File

@@ -1,5 +1,5 @@
{
"version": "1.2.0",
"version": "1.2.2",
"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的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"
@@ -75,7 +75,20 @@
"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"
"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",
@@ -113,7 +126,20 @@
"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"
"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"
},
{
"name": "RWKV-4-World-7B-v1-OnlyForTest_30%_trained-20230529-ctx4096.pth",
@@ -151,7 +177,20 @@
"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"
"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"
},
{
"name": "RWKV-4-Novel-7B-v1-ChnEng-ChnPro-20230410-ctx4096.pth",
@@ -377,4 +416,4 @@
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-4-raven/resolve/main/RWKV-4-Raven-14B-v12-Eng98%25-Other2%25-20230523-ctx8192.pth"
}
]
}
}