Skip to content

Commit

Permalink
perf: default prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Aug 23, 2023
1 parent 6c70f06 commit a3c4a85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
3 changes: 2 additions & 1 deletion client/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NProgress from 'nprogress'; //nprogress module
import Router from 'next/router';
import { clientInitData, feConfigs } from '@/store/static';
import { appWithTranslation, useTranslation } from 'next-i18next';
import { getLangStore } from '@/utils/i18n';
import { getLangStore, setLangStore } from '@/utils/i18n';
import { useRouter } from 'next/router';

import 'nprogress/nprogress.css';
Expand Down Expand Up @@ -58,6 +58,7 @@ function App({ Component, pageProps }: AppProps) {
useEffect(() => {
const lang = getLangStore() || 'zh';
i18n?.changeLanguage?.(lang);
setLangStore(lang);
}, [router.asPath]);

return (
Expand Down
16 changes: 4 additions & 12 deletions client/src/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@ import { serviceSideProps } from '@/utils/i18n';
import { feConfigs } from '@/store/static';
import { useTranslation } from 'react-i18next';

const Promotion = dynamic(() => import('./components/Promotion'), {
ssr: false
});
const BillTable = dynamic(() => import('./components/BillTable'), {
ssr: false
});
const PayRecordTable = dynamic(() => import('./components/PayRecordTable'), {
ssr: false
});
const InformTable = dynamic(() => import('./components/InformTable'), {
ssr: false
});
const Promotion = dynamic(() => import('./components/Promotion'));
const BillTable = dynamic(() => import('./components/BillTable'));
const PayRecordTable = dynamic(() => import('./components/PayRecordTable'));
const InformTable = dynamic(() => import('./components/InformTable'));

enum TabEnum {
'info' = 'info',
Expand Down
28 changes: 14 additions & 14 deletions client/src/service/moduleDispatch/chat/oneapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function filterQuote({
maxToken: model.quoteMaxToken,
messages: quoteQA.map((item) => ({
obj: ChatRoleEnum.System,
value: item.a ? `{user:${item.q},assistant:${item.a}}` : `{instruction:${item.q}}`
value: item.a ? `${item.q}\n${item.a}` : item.q
}))
});

Expand All @@ -210,11 +210,9 @@ function filterQuote({

const quotePrompt =
filterQuoteQA.length > 0
? `${filterQuoteQA
.map((item) =>
item.a ? `{user:${item.q},assistant:${item.a}}` : `{instruction:${item.q}}`
)
.join('\n')}`
? `"""${filterQuoteQA
.map((item) => (item.a ? `${item.q}\n${item.a}` : item.q))
.join('\n\n')}"""`
: '';

return {
Expand All @@ -238,31 +236,31 @@ function getChatMessages({
model: ChatModelItemType;
}) {
const limitText = (() => {
if (limitPrompt) return limitPrompt;
if (limitPrompt)
return `Use the provided content delimited by triple quotes to answer questions.${limitPrompt}`;
if (quotePrompt && !limitPrompt) {
return '根据我上文提供的内容回答下面问题,不要进行额外补充。';
return `Use the provided content delimited by triple quotes to answer questions.Your task is to answer the question using only the provided conetnt and to cite the passage(s) of the conetnt used to answer the question. If the conetnt does not contain the information needed to answer this question then simply write: "你的问题没有在知识库中体现".`;
}
return '';
return ``;
})();

const messages: ChatItemType[] = [
...(quotePrompt
...(systemPrompt
? [
{
obj: ChatRoleEnum.System,
value: quotePrompt
value: systemPrompt
}
]
: []),
...(systemPrompt
...(quotePrompt
? [
{
obj: ChatRoleEnum.System,
value: systemPrompt
value: quotePrompt
}
]
: []),
...history,
...(limitText
? [
{
Expand All @@ -271,6 +269,7 @@ function getChatMessages({
}
]
: []),
...history,
{
obj: ChatRoleEnum.Human,
value: userChatInput
Expand Down Expand Up @@ -301,6 +300,7 @@ function getMaxTokens({
}) {
const tokensLimit = model.contextMaxToken;
/* count response max token */

const promptsToken = modelToolMap.countTokens({
model: model.model,
messages: filterMessages
Expand Down
3 changes: 3 additions & 0 deletions docSite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 文档

## 本地运行

0 comments on commit a3c4a85

Please sign in to comment.