37 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-05-15 08:51:32 +08:00
'use client'
import { useContext } from 'use-context-selector'
2023-05-15 08:51:32 +08:00
import TemplateEn from './template/template.en.mdx'
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'
2024-02-23 14:31:06 +08:00
import { LanguagesSupported } from '@/i18n/language'
2023-05-15 08:51:32 +08:00
type IDocProps = {
appDetail: any
}
const Doc = ({ appDetail }: IDocProps) => {
const { locale } = useContext(I18n)
2024-02-23 14:31:06 +08:00
2023-05-15 08:51:32 +08:00
const variables = appDetail?.model_config?.configs?.prompt_variables || []
const inputs = variables.reduce((res: any, variable: any) => {
res[variable.key] = variable.name || ''
2023-05-15 08:51:32 +08:00
return res
}, {})
return (
<article className="prose prose-xl" >
{appDetail?.mode === 'completion'
? (
2024-02-23 14:31:06 +08:00
locale !== LanguagesSupported[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
)
: (
2024-02-23 14:31:06 +08:00
locale !== LanguagesSupported[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
)}
2023-05-15 08:51:32 +08:00
</article>
)
}
export default Doc