doc.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use client'
  2. import { useContext } from 'use-context-selector'
  3. import TemplateEn from './template/template.en.mdx'
  4. import TemplateZh from './template/template.zh.mdx'
  5. import TemplateChatEn from './template/template_chat.en.mdx'
  6. import TemplateChatZh from './template/template_chat.zh.mdx'
  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. ? (
  22. locale === 'en' ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
  23. )
  24. : (
  25. locale === 'en' ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
  26. )}
  27. </article>
  28. )
  29. }
  30. export default Doc