doc.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use client'
  2. import TemplateEn from './template/template.en.mdx'
  3. import TemplateZh from './template/template.zh.mdx'
  4. import TemplateChatEn from './template/template_chat.en.mdx'
  5. import TemplateChatZh from './template/template_chat.zh.mdx'
  6. import { useContext } from 'use-context-selector'
  7. import I18n from '@/context/i18n'
  8. type IDocProps = {
  9. appDetail: any
  10. }
  11. const Doc = ({ appDetail }: IDocProps) => {
  12. const { locale } = useContext(I18n)
  13. const variables = appDetail?.model_config?.configs?.prompt_variables || []
  14. const inputs = variables.reduce((res: any, variable: any) => {
  15. res[variable.key] = variable.name || '';
  16. return res
  17. }, {})
  18. return (
  19. <article className="prose prose-xl" >
  20. {appDetail?.mode === 'completion' ? (
  21. locale === 'en' ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
  22. ) : (
  23. locale === 'en' ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
  24. )}
  25. </article>
  26. )
  27. }
  28. export default Doc