Skip to content

Commit

Permalink
improve prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Jul 25, 2024
1 parent b1a7169 commit 0c17d1a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
5 changes: 4 additions & 1 deletion frontend/src/_locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,8 @@
"See More": "もっと見る",
"State Model": "Stateモデル",
"State model mismatch": "Stateモデルの不一致",
"File format of the model or state model not supported": "モデルまたはStateモデルのファイル形式がサポートされていません"
"File format of the model or state model not supported": "モデルまたはStateモデルのファイル形式がサポートされていません",
"Note: You are using an English state": "注意: あなたは英語のstateを使用しています",
"Note: You are using a Chinese state": "注意: あなたは中国語のstateを使用しています",
"Note: You are using a Japanese state": "注意: あなたは日本語のstateを使用しています"
}
5 changes: 4 additions & 1 deletion frontend/src/_locales/zh-hans/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,8 @@
"See More": "查看更多",
"State Model": "State模型",
"State model mismatch": "State模型不匹配",
"File format of the model or state model not supported": "模型或state模型的文件格式不支持"
"File format of the model or state model not supported": "模型或state模型的文件格式不支持",
"Note: You are using an English state": "注意: 你正在使用一个英文state",
"Note: You are using a Chinese state": "注意: 你正在使用一个中文state",
"Note: You are using a Japanese state": "注意: 你正在使用一个日文state"
}
24 changes: 23 additions & 1 deletion frontend/src/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import commonStore, { Status } from '../stores/commonStore';
import { toast } from 'react-toastify';
import { TFunction } from 'i18next';

export const readRoot = async () => {
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
Expand All @@ -25,7 +27,27 @@ export const switchModel = async (body: any) => {
});
};

export const updateConfig = async (body: any) => {
export const updateConfig = async (t: TFunction<'translation', undefined, 'translation'>, body: any) => {
if (body.state) {
const stateName = body.state.toLowerCase();
if (commonStore.settings.language !== 'zh' && (stateName.includes('chn') || stateName.includes('chinese'))) {
toast(t('Note: You are using a Chinese state'), {
type: 'warning',
toastId: 'state_warning'
});
} else if (commonStore.settings.language !== 'dev' && (stateName.includes('eng') || stateName.includes('english'))) {
toast(t('Note: You are using an English state'), {
type: 'warning',
toastId: 'state_warning'
});
} else if (commonStore.settings.language !== 'ja' && (stateName.includes('jpn') || stateName.includes('japanese'))) {
toast(t('Note: You are using a Japanese state'), {
type: 'warning',
toastId: 'state_warning'
});
}
}

const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
return fetch(`http://127.0.0.1:${port}/update-config`, {
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/RunButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
commonStore.setStatus({ status: ModelStatus.Loading });
const loadingId = toast(t('Loading Model'), { type: 'info', autoClose: false });
if (!webgpu) {
updateConfig({
updateConfig(t, {
max_tokens: modelConfig.apiParameters.maxResponseToken,
temperature: modelConfig.apiParameters.temperature,
top_p: modelConfig.apiParameters.topP,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Configs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const Configs: FC = observer(() => {
if (!webgpu) {
// When clicking RunButton in Configs page, updateConfig will be called twice,
// because there are also RunButton in other pages, and the calls to updateConfig in both places are necessary.
updateConfig({
updateConfig(t, {
max_tokens: selectedConfig.apiParameters.maxResponseToken,
temperature: selectedConfig.apiParameters.temperature,
top_p: selectedConfig.apiParameters.topP,
Expand Down

0 comments on commit 0c17d1a

Please sign in to comment.