| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 'use client' | 
					
						
							| 
									
										
										
										
											2024-01-04 15:37:51 +08:00
										 |  |  | import { useContext } from 'use-context-selector' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import TemplateEn from './template/template.en.mdx' | 
					
						
							|  |  |  | import TemplateZh from './template/template.zh.mdx' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import TemplateAdvancedChatEn from './template/template_advanced_chat.en.mdx' | 
					
						
							|  |  |  | import TemplateAdvancedChatZh from './template/template_advanced_chat.zh.mdx' | 
					
						
							|  |  |  | import TemplateWorkflowEn from './template/template_workflow.en.mdx' | 
					
						
							|  |  |  | import TemplateWorkflowZh from './template/template_workflow.zh.mdx' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import TemplateChatEn from './template/template_chat.en.mdx' | 
					
						
							|  |  |  | import TemplateChatZh from './template/template_chat.zh.mdx' | 
					
						
							|  |  |  | import I18n from '@/context/i18n' | 
					
						
							| 
									
										
										
										
											2024-02-23 14:31:06 +08:00
										 |  |  | import { LanguagesSupported } from '@/i18n/language' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | type IDocProps = { | 
					
						
							|  |  |  |   appDetail: any | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const Doc = ({ appDetail }: IDocProps) => { | 
					
						
							|  |  |  |   const { locale } = useContext(I18n) | 
					
						
							| 
									
										
										
										
											2024-02-23 14:31:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   const variables = appDetail?.model_config?.configs?.prompt_variables || [] | 
					
						
							|  |  |  |   const inputs = variables.reduce((res: any, variable: any) => { | 
					
						
							| 
									
										
										
										
											2024-01-04 15:37:51 +08:00
										 |  |  |     res[variable.key] = variable.name || '' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     return res | 
					
						
							|  |  |  |   }, {}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <article className="prose prose-xl" > | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       {(appDetail?.mode === 'chat' || appDetail?.mode === 'agent-chat') && ( | 
					
						
							|  |  |  |         locale !== LanguagesSupported[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} /> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |       {appDetail?.mode === 'advanced-chat' && ( | 
					
						
							|  |  |  |         locale !== LanguagesSupported[1] ? <TemplateAdvancedChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateAdvancedChatZh appDetail={appDetail} variables={variables} inputs={inputs} /> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |       {appDetail?.mode === 'workflow' && ( | 
					
						
							|  |  |  |         locale !== LanguagesSupported[1] ? <TemplateWorkflowEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateWorkflowZh appDetail={appDetail} variables={variables} inputs={inputs} /> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |       {appDetail?.mode === 'completion' && ( | 
					
						
							|  |  |  |         locale !== LanguagesSupported[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} /> | 
					
						
							|  |  |  |       )} | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     </article> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default Doc |