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