Fix/language support (#2154)

This commit is contained in:
crazywoola
2024-01-24 11:08:11 +08:00
committed by GitHub
parent 00f4e6ec44
commit e58c3ac374
28 changed files with 103 additions and 71 deletions

View File

@@ -5,6 +5,7 @@ import TemplateZh from './template/template.zh.mdx'
import TemplateChatEn from './template/template_chat.en.mdx'
import TemplateChatZh from './template/template_chat.zh.mdx'
import I18n from '@/context/i18n'
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
type IDocProps = {
appDetail: any
@@ -12,6 +13,7 @@ type IDocProps = {
const Doc = ({ appDetail }: IDocProps) => {
const { locale } = useContext(I18n)
const language = getModelRuntimeSupported(locale)
const variables = appDetail?.model_config?.configs?.prompt_variables || []
const inputs = variables.reduce((res: any, variable: any) => {
res[variable.key] = variable.name || ''
@@ -22,10 +24,10 @@ const Doc = ({ appDetail }: IDocProps) => {
<article className="prose prose-xl" >
{appDetail?.mode === 'completion'
? (
locale === 'en' ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
language !== LanguagesSupportedUnderscore[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
)
: (
locale === 'en' ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
language !== LanguagesSupportedUnderscore[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
)}
</article>
)