doc.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. import { LanguagesSupported } from '@/i18n/language'
  9. type IDocProps = {
  10. appDetail: any
  11. }
  12. const Doc = ({ appDetail }: IDocProps) => {
  13. const { locale } = useContext(I18n)
  14. const variables = appDetail?.model_config?.configs?.prompt_variables || []
  15. const inputs = variables.reduce((res: any, variable: any) => {
  16. res[variable.key] = variable.name || ''
  17. return res
  18. }, {})
  19. return (
  20. <article className="prose prose-xl" >
  21. {appDetail?.mode === 'completion'
  22. ? (
  23. locale !== LanguagesSupported[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
  24. )
  25. : (
  26. locale !== LanguagesSupported[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
  27. )}
  28. </article>
  29. )
  30. }
  31. export default Doc