doc.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 TemplateAdvancedChatEn from './template/template_advanced_chat.en.mdx'
  6. import TemplateAdvancedChatZh from './template/template_advanced_chat.zh.mdx'
  7. import TemplateWorkflowEn from './template/template_workflow.en.mdx'
  8. import TemplateWorkflowZh from './template/template_workflow.zh.mdx'
  9. import TemplateChatEn from './template/template_chat.en.mdx'
  10. import TemplateChatZh from './template/template_chat.zh.mdx'
  11. import I18n from '@/context/i18n'
  12. import { LanguagesSupported } from '@/i18n/language'
  13. type IDocProps = {
  14. appDetail: any
  15. }
  16. const Doc = ({ appDetail }: IDocProps) => {
  17. const { locale } = useContext(I18n)
  18. const variables = appDetail?.model_config?.configs?.prompt_variables || []
  19. const inputs = variables.reduce((res: any, variable: any) => {
  20. res[variable.key] = variable.name || ''
  21. return res
  22. }, {})
  23. return (
  24. <article className="prose prose-xl" >
  25. {(appDetail?.mode === 'chat' || appDetail?.mode === 'agent-chat') && (
  26. locale !== LanguagesSupported[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
  27. )}
  28. {appDetail?.mode === 'advanced-chat' && (
  29. locale !== LanguagesSupported[1] ? <TemplateAdvancedChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateAdvancedChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
  30. )}
  31. {appDetail?.mode === 'workflow' && (
  32. locale !== LanguagesSupported[1] ? <TemplateWorkflowEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateWorkflowZh appDetail={appDetail} variables={variables} inputs={inputs} />
  33. )}
  34. {appDetail?.mode === 'completion' && (
  35. locale !== LanguagesSupported[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
  36. )}
  37. </article>
  38. )
  39. }
  40. export default Doc