├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── hkh │ └── ai │ ├── SpringAiApplication.java │ ├── agent │ ├── action │ │ ├── goal │ │ │ ├── Goal.java │ │ │ └── GoalStatus.java │ │ ├── plan │ │ │ └── Plan.java │ │ └── task │ │ │ ├── Task.java │ │ │ ├── TaskHandler.java │ │ │ ├── TaskProcessor.java │ │ │ ├── TaskStatus.java │ │ │ ├── analysis │ │ │ ├── ChartDataAnalysisProcessor.java │ │ │ ├── DataAnalysisProcessor.java │ │ │ └── StatisticsDataAnalysisProcessor.java │ │ │ ├── collect │ │ │ ├── crawl │ │ │ │ ├── FocusedWebCrawlProcessor.java │ │ │ │ ├── ScalableWebCrawlProcessor.java │ │ │ │ └── WebCrawlProcessor.java │ │ │ ├── file │ │ │ │ ├── ExcelFileReadProcessor.java │ │ │ │ ├── FileReadProcessor.java │ │ │ │ └── TxtFileReadProcessor.java │ │ │ ├── search │ │ │ │ ├── BaiduSearchCollectProcessor.java │ │ │ │ ├── GoogleSearchCollectProcessor.java │ │ │ │ └── SearchCollectProcessor.java │ │ │ └── uri │ │ │ │ ├── FtpRequestProcessor.java │ │ │ │ ├── HttpGetRequestProcessor.java │ │ │ │ └── UriRequestProcessor.java │ │ │ ├── decision │ │ │ ├── DecisionProcessor.java │ │ │ ├── LlmTaskDecisionProcessor.java │ │ │ └── UserTaskDecisionProcessor.java │ │ │ └── notice │ │ │ ├── app │ │ │ ├── AliPaySendProcessor.java │ │ │ ├── SocialAppSendProcessor.java │ │ │ └── WeiXinSendProcessor.java │ │ │ ├── mail │ │ │ ├── MailSendProcessor.java │ │ │ ├── NetEaseMailSendProcessor.java │ │ │ └── QqMailSendProcessor.java │ │ │ └── sms │ │ │ ├── AliSmsSendProcessor.java │ │ │ ├── JiGuangSmsSendProcessor.java │ │ │ └── SmsSendProcessor.java │ ├── core │ │ ├── AiFunctionFactory.java │ │ ├── Environment.java │ │ ├── FunctionFactory.java │ │ ├── God.java │ │ ├── ToolFunctionFactory.java │ │ └── function │ │ │ ├── AiFunctionType.java │ │ │ ├── FunctionType.java │ │ │ ├── ToolFunction.java │ │ │ └── ToolFunctionType.java │ ├── input │ │ ├── UserInputMessage.java │ │ └── demand │ │ │ └── DemandMessage.java │ └── prompt │ │ ├── demand │ │ ├── DemandProposePrompt.java │ │ ├── DemandStepRolePrompt.java │ │ └── functionObj │ │ │ ├── DemandFuncObj.java │ │ │ ├── DemandRoleFuncObj.java │ │ │ ├── DemandStepFunObj.java │ │ │ └── StepRoleFuncObj.java │ │ └── function │ │ ├── FunctionTypePrompt.java │ │ └── functionObj │ │ └── FunctionTypeFuncObj.java │ ├── chain │ ├── callback │ │ └── FunctionCaller.java │ ├── llm │ │ ├── OpenAiServiceProxy.java │ │ └── capabilities │ │ │ └── generation │ │ │ ├── BaiduChatApis.java │ │ │ ├── BaiduQianFanUtil.java │ │ │ ├── KimiAiUtil.java │ │ │ ├── KimiApis.java │ │ │ ├── ZhipuAiUtil.java │ │ │ ├── ZhipuChatApis.java │ │ │ ├── audio │ │ │ ├── AudioChatService.java │ │ │ ├── AudioChatServiceFactory.java │ │ │ ├── AudioChatServiceWrapper.java │ │ │ └── openai │ │ │ │ └── OpenAiAudioChatService.java │ │ │ ├── function │ │ │ ├── ChatFunctionObject.java │ │ │ ├── FunctionChatService.java │ │ │ ├── FunctionChatServiceFactory.java │ │ │ ├── FunctionChatServiceWrapper.java │ │ │ ├── FunctionCompletionResult.java │ │ │ ├── FunctionParameters.java │ │ │ ├── FunctionParametersField.java │ │ │ ├── FunctionParametersFieldValue.java │ │ │ ├── baidu │ │ │ │ ├── BaiduAiFunctionChatService.java │ │ │ │ └── BaiduFunctionCompletionResult.java │ │ │ ├── openai │ │ │ │ └── OpenAiFunctionChatService.java │ │ │ └── zhipu │ │ │ │ └── ZhipuAiFunctionChatService.java │ │ │ ├── image │ │ │ ├── ImageChatService.java │ │ │ ├── ImageChatServiceFactory.java │ │ │ ├── ImageChatServiceWrapper.java │ │ │ ├── baidu │ │ │ │ └── BaiduImageChatService.java │ │ │ ├── openai │ │ │ │ └── OpenAiImageChatService.java │ │ │ └── zhipu │ │ │ │ └── ZhipuImageChatService.java │ │ │ ├── text │ │ │ ├── TextChatService.java │ │ │ ├── TextChatServiceFactory.java │ │ │ ├── TextChatServiceWrapper.java │ │ │ ├── baidu │ │ │ │ ├── BaiduQianFanCompletionBizProcessor.java │ │ │ │ ├── BaiduQianFanCompletionWebClient.java │ │ │ │ ├── BaiduQianFanTextChatService.java │ │ │ │ ├── BlockCompletionResult.java │ │ │ │ └── StreamCompletionResult.java │ │ │ ├── chatglm2 │ │ │ │ ├── Chatglm2ResponseBodyCallback.java │ │ │ │ ├── Chatglm2Service.java │ │ │ │ └── Chatglm2TextChatService.java │ │ │ ├── kimi │ │ │ │ ├── BlockCompletionResult.java │ │ │ │ ├── KimiCompletionBizProcessor.java │ │ │ │ ├── KimiCompletionWebClient.java │ │ │ │ ├── KimiTextChatService.java │ │ │ │ └── StreamCompletionResult.java │ │ │ ├── openai │ │ │ │ └── OpenAiTextChatService.java │ │ │ └── zhipu │ │ │ │ ├── BlockCompletionResult.java │ │ │ │ ├── StreamCompletionResult.java │ │ │ │ ├── ZhipuCompletionBizProcessor.java │ │ │ │ ├── ZhipuCompletionWebClient.java │ │ │ │ └── ZhipuTextChatService.java │ │ │ └── vision │ │ │ ├── VisionChatService.java │ │ │ ├── VisionChatServiceFactory.java │ │ │ ├── VisionChatServiceWrapper.java │ │ │ ├── openai │ │ │ └── OpenAiVisionChatService.java │ │ │ └── zhipu │ │ │ └── ZhipuVisionChatService.java │ ├── loader │ │ ├── CodeFileLoader.java │ │ ├── CsvFileLoader.java │ │ ├── FolderLoader.java │ │ ├── GithubLoader.java │ │ ├── JsonFileLoader.java │ │ ├── MarkDownFileLoader.java │ │ ├── PdfFileLoader.java │ │ ├── ResourceLoader.java │ │ ├── ResourceLoaderFactory.java │ │ ├── TextFileLoader.java │ │ └── WordLoader.java │ ├── plugin │ │ └── search │ │ │ └── engine │ │ │ ├── BaiduWebSearchEngine.java │ │ │ ├── BingWebSearchEngine.java │ │ │ ├── GoogleWebSearchEngine.java │ │ │ ├── WebSearchEngine.java │ │ │ ├── WebSearchEngineFactory.java │ │ │ └── WebSearchEngineWrapper.java │ ├── prompt │ │ ├── ChatPromptTemplate.java │ │ ├── FewShotPromptTemplate.java │ │ └── PromptTemplate.java │ ├── retrieve │ │ └── PromptRetrieverProperties.java │ ├── split │ │ ├── CharacterTextSplitter.java │ │ ├── CodeTextSplitter.java │ │ ├── MarkdownTextSplitter.java │ │ ├── SplitterProperties.java │ │ ├── TextSplitter.java │ │ └── TokenTextSplitter.java │ ├── vectorizer │ │ ├── Vectorization.java │ │ ├── VectorizationFactory.java │ │ ├── VectorizationWrapper.java │ │ ├── baidu │ │ │ ├── BaiduQianFanVectorization.java │ │ │ └── BaiduQianFanVectorizationResult.java │ │ ├── huggingface │ │ │ └── HuggingFaceInferenceVectorization.java │ │ ├── local │ │ │ └── LocalAiVectorization.java │ │ ├── openai │ │ │ └── OpenAiVectorization.java │ │ └── zhipu │ │ │ └── ZhipuAiVectorization.java │ └── vectorstore │ │ ├── MilvusVectorStore.java │ │ ├── PgVectorStore.java │ │ ├── VectorStore.java │ │ ├── VectorStoreFactory.java │ │ ├── VectorStoreWrapper.java │ │ └── WeaviateVectorStore.java │ ├── common │ ├── PageRequest.java │ ├── ResultCodeEnum.java │ ├── ResultData.java │ ├── annotation │ │ ├── AdminRequired.java │ │ ├── RepeatSubmit.java │ │ └── TokenIgnore.java │ ├── constant │ │ ├── FileType.java │ │ └── SysConstants.java │ └── exception │ │ ├── AuthException.java │ │ ├── DbException.java │ │ ├── ParamException.java │ │ ├── Request404Exception.java │ │ ├── SessionExpiredException.java │ │ └── TokenException.java │ ├── config │ ├── AdminRequiredAspect.java │ ├── FastJson2JsonRedisSerializer.java │ ├── FreemarkerConfig.java │ ├── GlobalExceptionHandler.java │ ├── LoginFilter.java │ ├── RedisConfig.java │ ├── SwaggerConfig.java │ ├── SysConfig.java │ └── WebConfig.java │ ├── controller │ ├── AgentController.java │ ├── AudioController.java │ ├── ChatSessionController.java │ ├── CompletionController.java │ ├── ConversationController.java │ ├── KnowledgeController.java │ ├── MediaFileController.java │ ├── ResourceController.java │ ├── SpecialNounController.java │ ├── SseController.java │ ├── SysRoleController.java │ ├── WeaviateController.java │ └── view │ │ ├── AuthViewController.java │ │ ├── IndexViewController.java │ │ ├── KnowledgeViewController.java │ │ ├── RegisterController.java │ │ └── SpecialNounViewController.java │ ├── domain │ ├── AccessToken.java │ ├── AgentField.java │ ├── ChatRequestLog.java │ ├── ChatSession.java │ ├── Conversation.java │ ├── CustomChatMessage.java │ ├── Demand.java │ ├── DemandStep.java │ ├── Knowledge.java │ ├── KnowledgeAttach.java │ ├── KnowledgeFragment.java │ ├── KnowledgeShare.java │ ├── MediaFile.java │ ├── SpecialNoun.java │ ├── SysModel.java │ ├── SysRole.java │ ├── SysUser.java │ └── function │ │ ├── DatePeriod.java │ │ └── LocationWeather.java │ ├── mapper │ ├── AccessTokenMapper.java │ ├── AgentFieldMapper.java │ ├── ChatRequestLogMapper.java │ ├── ChatSessionMapper.java │ ├── ConversationMapper.java │ ├── DemandMapper.java │ ├── DemandStepMapper.java │ ├── KnowledgeAttachMapper.java │ ├── KnowledgeFragmentMapper.java │ ├── KnowledgeMapper.java │ ├── KnowledgeShareMapper.java │ ├── MediaFileMapper.java │ ├── SpecialNounMapper.java │ ├── SysModelMapper.java │ ├── SysRoleMapper.java │ └── SysUserMapper.java │ ├── request │ ├── AgentDemandProposeRequest.java │ ├── AudioChatRequest.java │ ├── AudioTranscribeRequest.java │ ├── AuthLoginRequest.java │ ├── ChatSessionRemoveRequest.java │ ├── ChatSessionSaveRequest.java │ ├── ChatSessionUseKnowledgeRequest.java │ ├── CompletionClassicRequest.java │ ├── CompletionFunctionRequest.java │ ├── CompletionFunctionWeatherRequest.java │ ├── CompletionKeywordRequest.java │ ├── CompletionSecurityRequest.java │ ├── CompletionSummaryRequest.java │ ├── CompletionTranslateRequest.java │ ├── ImageChatRequest.java │ ├── KnowledgeAttachPageRequest.java │ ├── KnowledgeAttachRemoveRequest.java │ ├── KnowledgeDetailRequest.java │ ├── KnowledgeFragmentPageRequest.java │ ├── KnowledgeFragmentRemoveRequest.java │ ├── KnowledgeFragmentSaveRequest.java │ ├── KnowledgePageRequest.java │ ├── KnowledgeRemoveRequest.java │ ├── KnowledgeSaveRequest.java │ ├── KnowledgeUploadExampleRequest.java │ ├── KnowledgeUploadRequest.java │ ├── MediaFileBase64UploadRequest.java │ ├── MediaFileUploadRequest.java │ ├── RolePageRequest.java │ ├── SpecialNounPageRequest.java │ ├── SpecialNounRemoveRequest.java │ ├── SpecialNounSaveRequest.java │ └── VisionChatRequest.java │ ├── response │ ├── AudioChatResponse.java │ ├── CreateImageChatResponse.java │ ├── KnowledgeDetailResponse.java │ └── KnowledgeListResponse.java │ ├── service │ ├── AccessTokenService.java │ ├── AgentFieldService.java │ ├── ChatRequestLogService.java │ ├── ChatSessionService.java │ ├── CompletionService.java │ ├── ConversationService.java │ ├── DemandService.java │ ├── DemandStepService.java │ ├── EmbeddingService.java │ ├── KnowledgeAttachService.java │ ├── KnowledgeFragmentService.java │ ├── KnowledgeService.java │ ├── KnowledgeShareService.java │ ├── MediaFileService.java │ ├── SpecialNounService.java │ ├── SysModelService.java │ ├── SysRoleService.java │ ├── SysUserService.java │ └── impl │ │ ├── AccessTokenServiceImpl.java │ │ ├── AgentFieldServiceImpl.java │ │ ├── ChatRequestLogServiceImpl.java │ │ ├── ChatSessionServiceImpl.java │ │ ├── CompletionServiceImpl.java │ │ ├── ConversationServiceImpl.java │ │ ├── DemandServiceImpl.java │ │ ├── DemandStepServiceImpl.java │ │ ├── EmbeddingServiceImpl.java │ │ ├── KnowledgeAttachServiceImpl.java │ │ ├── KnowledgeFragmentServiceImpl.java │ │ ├── KnowledgeServiceImpl.java │ │ ├── KnowledgeShareServiceImpl.java │ │ ├── MediaFileServiceImpl.java │ │ ├── SpecialNounServiceImpl.java │ │ ├── SysModelServiceImpl.java │ │ ├── SysRoleServiceImpl.java │ │ └── SysUserServiceImpl.java │ └── util │ └── FunctionReflect.java └── resources ├── application-dev.properties ├── application.properties ├── assets ├── functions_1.png ├── functions_2.png ├── functions_3.png ├── functions_4.png ├── functions_5.png ├── functions_6.png ├── functions_7.png ├── functions_8.png ├── functions_9.png ├── langchain+chatglm.png ├── login_app.png ├── stream-chat.png ├── use_lk.png ├── use_lk2.png ├── weixin_02.png └── weixin_qun.png ├── init-scripts ├── db.sql └── vectorstores │ ├── milvus │ └── docker-compose.yml │ ├── pgvector │ └── docker-compose.yml │ └── weaviate │ └── docker-compose.yml ├── logback-spring.xml ├── mapper ├── AccessTokenMapper.xml ├── AgentFieldMapper.xml ├── ChatRequestLogMapper.xml ├── ChatSessionMapper.xml ├── ConversationMapper.xml ├── DemandMapper.xml ├── DemandStepMapper.xml ├── KnowledgeAttachMapper.xml ├── KnowledgeFragmentMapper.xml ├── KnowledgeMapper.xml ├── KnowledgeShareMapper.xml ├── MediaFileMapper.xml ├── SpecialNounMapper.xml ├── SysModelMapper.xml ├── SysRoleMapper.xml └── SysUserMapper.xml ├── mybatis └── SqlMapperConfig.xml ├── static ├── anchor │ └── assets │ │ ├── css │ │ ├── main.css │ │ ├── main.css.map │ │ └── vendor │ │ │ ├── aos.css │ │ │ ├── bootstrap-toc.css │ │ │ └── prism.css │ │ ├── img │ │ ├── demo │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 7.jpg │ │ │ ├── 9.jpg │ │ │ ├── avatar.png │ │ │ ├── avatar2.jpg │ │ │ ├── blog1.jpg │ │ │ ├── blog2.jpg │ │ │ ├── blog3.jpg │ │ │ ├── blog4.jpg │ │ │ ├── blog5.jpg │ │ │ ├── blog6.jpg │ │ │ ├── blog7.jpg │ │ │ ├── blog8.jpg │ │ │ ├── blog9.jpg │ │ │ ├── coffee.png │ │ │ ├── dashb.png │ │ │ ├── dashb2.png │ │ │ ├── screenshot.png │ │ │ ├── screenshot1.png │ │ │ ├── screenshot2.png │ │ │ ├── screenshot3.png │ │ │ ├── screenshot4.png │ │ │ ├── slide1.jpg │ │ │ ├── slide2.jpg │ │ │ └── slide3.jpg │ │ ├── favicon.ico │ │ └── shape.svg │ │ └── js │ │ ├── functions.js │ │ └── vendor │ │ ├── aos.js │ │ ├── bootstrap-toc.js │ │ ├── bootstrap.min.js │ │ ├── jquery.min.js │ │ ├── popper.min.js │ │ ├── prism.js │ │ └── share.js ├── css │ ├── agent.css │ ├── all.css │ ├── bootstrap-icons.css │ ├── chat.css │ ├── classic.css │ ├── common │ │ └── topbar.css │ ├── function.css │ ├── googlefont.css │ ├── index.css │ ├── keyword.css │ ├── knowledge │ │ ├── attach.css │ │ ├── fragment.css │ │ └── index.css │ ├── login.css │ ├── register.css │ ├── security.css │ ├── special │ │ └── index.css │ ├── summary.css │ └── translate.css ├── fonts │ ├── XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHgKbaf2r4e_T5.woff2 │ ├── XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHjabaf2r4ew.woff2 │ ├── XRXV3I6Li01BKofINeaBTMnFcQ.woff2 │ ├── XRXV3I6Li01BKofIO-aBTMnFcQIG.woff2 │ ├── XRXV3I6Li01BKofIOOaBTMnFcQIG.woff2 │ ├── bootstrap-icons.woff │ ├── bootstrap-icons.woff2 │ └── fa-solid-900.woff2 ├── img │ ├── illustration.jpg │ └── illustration3.png └── js │ ├── agent.js │ ├── chat.js │ ├── classic.js │ ├── common │ ├── confirm.js │ ├── topbar.js │ └── vconsole.min.js │ ├── function.js │ ├── index.js │ ├── keyword.js │ ├── knowledge │ ├── attach.js │ ├── fragment.js │ └── index.js │ ├── login.js │ ├── recorder │ ├── app.js │ ├── engine │ │ ├── beta-amr-engine.js │ │ ├── beta-amr.js │ │ ├── beta-ogg-engine.js │ │ ├── beta-ogg.js │ │ ├── beta-webm.js │ │ ├── g711x.js │ │ ├── mp3-engine.js │ │ ├── mp3.js │ │ ├── pcm.js │ │ └── wav.js │ ├── extensions │ │ ├── asr.aliyun.short.js │ │ ├── buffer_stream.player.js │ │ ├── create-audio.nmn2pcm.js │ │ ├── dtmf.decode.js │ │ ├── dtmf.encode.js │ │ ├── frequency.histogram.view.js │ │ ├── lib.fft.js │ │ ├── sonic.js │ │ ├── wavesurfer.view.js │ │ └── waveview.js │ ├── recorder.mp3.min.js │ └── recorder.wav.min.js │ ├── register.js │ ├── security.js │ ├── showdown.min.js │ ├── special │ └── index.js │ ├── summary.js │ └── translate.js └── templates ├── agent.ftl ├── agent_complex.ftl ├── agent_cs.ftl ├── agent_sales.ftl ├── chat.ftl ├── classic.ftl ├── common ├── pagination.ftl └── topbar.ftl ├── duplication.ftl ├── error ├── 401.ftl ├── 404.ftl └── 500.ftl ├── function.ftl ├── index.ftl ├── keyword.ftl ├── knowledge ├── attach.ftl ├── fragment.ftl └── index.ftl ├── login.ftl ├── register.ftl ├── security.ftl ├── sentiment.ftl ├── special └── index.ftl ├── summary.ftl ├── textToImage.ftl └── translate.ftl /.gitattributes: -------------------------------------------------------------------------------- 1 | *.md linguist-language=Java 2 | *.yml linguist-language=Java 3 | *.html linguist-language=Java 4 | *.js linguist-language=Java 5 | *.xml linguist-language=Java 6 | *.css linguist-language=Java 7 | *.sql linguist-language=Java 8 | *.uml linguist-language=Java 9 | *.cmd linguist-language=Java 10 | *.ftl linguist-language=Java 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | 26 | target/ 27 | .idea/ 28 | langchain-springboot.iml 29 | application-prod.properties 30 | application-cxai.properties 31 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/SpringAiApplication.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | @SpringBootApplication() 8 | public class SpringAiApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(SpringAiApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/goal/Goal.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.goal; 2 | 3 | import com.hkh.ai.agent.action.task.Task; 4 | import lombok.Data; 5 | 6 | import java.time.LocalDateTime; 7 | import java.util.List; 8 | 9 | /** 10 | * 最终目标 11 | * @author huangkh 12 | */ 13 | @Data 14 | public class Goal { 15 | 16 | /** 17 | * 目标ID 18 | */ 19 | private String goalId; 20 | 21 | /** 22 | * 目标状态 23 | */ 24 | private int goalStatus; 25 | 26 | /** 27 | * 目标文本 28 | */ 29 | private String goalText; 30 | 31 | /** 32 | * 开始时间 33 | */ 34 | private LocalDateTime startTime; 35 | 36 | /** 37 | * 结束时间 38 | */ 39 | private LocalDateTime endTime; 40 | 41 | /** 42 | * 子任务 43 | */ 44 | private List taskList; 45 | 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/goal/GoalStatus.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.goal; 2 | 3 | /** 4 | * 目标状态 5 | * @author huangkh 6 | */ 7 | public interface GoalStatus { 8 | 9 | /** 10 | * 等待中 11 | */ 12 | public static final int WAITING = 0; 13 | 14 | /** 15 | * 思考中 16 | */ 17 | public static final int THINKING = 1; 18 | 19 | /** 20 | * 计划中 21 | */ 22 | public static final int PLANNING = 2; 23 | 24 | /** 25 | * 执行中 26 | */ 27 | public static final int EXECUTING = 3; 28 | 29 | /** 30 | * 完成 31 | */ 32 | public static final int FINISH = 4; 33 | 34 | /** 35 | * 评估中 36 | */ 37 | public static final int EVALUATING = 5; 38 | 39 | /** 40 | * 成功 41 | */ 42 | public static final int SUCCESS = 6; 43 | 44 | /** 45 | * 失败 46 | */ 47 | public static final int FAIL = 7; 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/plan/Plan.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.plan; 2 | 3 | public class Plan { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/Task.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.LinkedHashMap; 6 | 7 | /** 8 | * 任务 9 | */ 10 | @Data 11 | public class Task { 12 | 13 | /** 14 | * 任务Id 15 | */ 16 | private String taskId; 17 | 18 | /** 19 | * 任务文本 20 | */ 21 | private String taskText; 22 | 23 | /** 24 | * 对应任务处理器 25 | */ 26 | private TaskProcessor taskProcessor; 27 | 28 | /** 29 | * 依赖任务列表 30 | */ 31 | private LinkedHashMap dependTasks; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/TaskHandler.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task; 2 | 3 | public interface TaskHandler { 4 | 5 | void doHandle(String taskId, com.hkh.ai.agent.action.task.TaskProcessor taskProcessor); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/TaskProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task; 2 | 3 | /** 4 | * 任务处理器 5 | * @author huangkh 6 | */ 7 | public interface TaskProcessor { 8 | 9 | void process(String target); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/TaskStatus.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task; 2 | 3 | /** 4 | * 任务状态 5 | * @author huangkh 6 | */ 7 | public interface TaskStatus { 8 | 9 | /** 10 | * 等待中 11 | */ 12 | public static final int WAITING = 0; 13 | 14 | /** 15 | * 思考中 16 | */ 17 | public static final int THINKING = 1; 18 | 19 | /** 20 | * 计划中 21 | */ 22 | public static final int PLANNING = 2; 23 | 24 | /** 25 | * 执行中 26 | */ 27 | public static final int EXECUTING = 3; 28 | 29 | /** 30 | * 完成 31 | */ 32 | public static final int FINISH = 4; 33 | 34 | /** 35 | * 评估中 36 | */ 37 | public static final int EVALUATING = 5; 38 | 39 | /** 40 | * 成功 41 | */ 42 | public static final int SUCCESS = 6; 43 | 44 | /** 45 | * 失败 46 | */ 47 | public static final int FAIL = 7; 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/analysis/ChartDataAnalysisProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.analysis; 2 | 3 | public class ChartDataAnalysisProcessor implements DataAnalysisProcessor{ 4 | @Override 5 | public void process(String target) { 6 | this.analysis(target); 7 | } 8 | 9 | @Override 10 | public void analysis(String target) { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/analysis/DataAnalysisProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.analysis; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 数据分析处理器 7 | * @author huangkh 8 | */ 9 | public interface DataAnalysisProcessor extends TaskProcessor { 10 | 11 | void analysis(String target); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/analysis/StatisticsDataAnalysisProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.analysis; 2 | 3 | /** 4 | * 统计数据分析处理器 5 | * @author huangkh 6 | */ 7 | public class StatisticsDataAnalysisProcessor implements DataAnalysisProcessor{ 8 | 9 | @Override 10 | public void process(String target) { 11 | this.analysis(target); 12 | } 13 | 14 | @Override 15 | public void analysis(String target) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/crawl/FocusedWebCrawlProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.crawl; 2 | 3 | /** 4 | * 聚焦式网络爬虫 5 | * @author huangkh 6 | */ 7 | public class FocusedWebCrawlProcessor implements WebCrawlProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.crawl(target); 11 | } 12 | 13 | @Override 14 | public void crawl(String target) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/crawl/ScalableWebCrawlProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.crawl; 2 | 3 | /** 4 | * 发散式网络爬虫 5 | * @author huangkh 6 | */ 7 | public class ScalableWebCrawlProcessor implements WebCrawlProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.crawl(target); 11 | } 12 | 13 | @Override 14 | public void crawl(String target) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/crawl/WebCrawlProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.crawl; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 爬虫处理器 7 | * @author huangkh 8 | */ 9 | public interface WebCrawlProcessor extends TaskProcessor { 10 | 11 | void crawl(String target); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/file/ExcelFileReadProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.file; 2 | 3 | /** 4 | * 电子表格处理器 5 | */ 6 | public class ExcelFileReadProcessor implements FileReadProcessor{ 7 | 8 | @Override 9 | public void process(String target) { 10 | this.read(target); 11 | } 12 | 13 | @Override 14 | public void read(String filePath) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/file/FileReadProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.file; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 文件读取处理器 7 | */ 8 | public interface FileReadProcessor extends TaskProcessor { 9 | 10 | void read(String filePath); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/file/TxtFileReadProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.file; 2 | 3 | /** 4 | * 文本文件处理器 5 | */ 6 | public class TxtFileReadProcessor implements FileReadProcessor{ 7 | 8 | @Override 9 | public void process(String target) { 10 | this.read(target); 11 | } 12 | 13 | @Override 14 | public void read(String filePath) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/search/BaiduSearchCollectProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.search; 2 | 3 | /** 4 | * 百度搜索数据收集器 5 | */ 6 | public class BaiduSearchCollectProcessor implements SearchCollectProcessor{ 7 | @Override 8 | public void process(String question) { 9 | this.search(question); 10 | } 11 | 12 | @Override 13 | public void search(String searchTxt) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/search/GoogleSearchCollectProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.search; 2 | 3 | /** 4 | * 谷歌搜索数据收集器 5 | */ 6 | public class GoogleSearchCollectProcessor implements SearchCollectProcessor{ 7 | @Override 8 | public void process(String question) { 9 | this.search(question); 10 | } 11 | 12 | @Override 13 | public void search(String searchTxt) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/search/SearchCollectProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.search; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 搜索引擎收集处理器接口 7 | */ 8 | public interface SearchCollectProcessor extends TaskProcessor { 9 | 10 | void search(String searchTxt); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/uri/FtpRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.uri; 2 | 3 | /** 4 | * Ftp 请求处理器 5 | */ 6 | public class FtpRequestProcessor implements UriRequestProcessor { 7 | @Override 8 | public void process(String target) { 9 | this.request(target); 10 | } 11 | 12 | @Override 13 | public void request(String url) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/uri/HttpGetRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.uri; 2 | 3 | /** 4 | * Http Get 请求处理器 5 | */ 6 | public class HttpGetRequestProcessor implements UriRequestProcessor { 7 | @Override 8 | public void process(String target) { 9 | this.request(target); 10 | } 11 | 12 | @Override 13 | public void request(String url) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/collect/uri/UriRequestProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.collect.uri; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * Uri请求处理器 7 | */ 8 | public interface UriRequestProcessor extends TaskProcessor { 9 | 10 | void request(String url); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/decision/DecisionProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.decision; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 决策处理器 7 | * @author huangkh 8 | */ 9 | public interface DecisionProcessor extends TaskProcessor { 10 | 11 | String decide(String content); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/decision/LlmTaskDecisionProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.decision; 2 | 3 | /** 4 | * 大模型任务决策器 5 | * @author huangkh 6 | */ 7 | public class LlmTaskDecisionProcessor implements DecisionProcessor{ 8 | 9 | @Override 10 | public void process(String target) { 11 | String result = decide(target); 12 | System.out.println("大模型任务决策结果为:" + result); 13 | } 14 | 15 | @Override 16 | public String decide(String content) { 17 | return null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/decision/UserTaskDecisionProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.decision; 2 | 3 | /** 4 | * 用户任务决策处理器 5 | * @author huangkh 6 | */ 7 | public class UserTaskDecisionProcessor implements DecisionProcessor{ 8 | @Override 9 | public void process(String target) { 10 | String result = decide(target); 11 | System.out.println("用户决策结果为:" + result); 12 | } 13 | 14 | @Override 15 | public String decide(String content) { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/app/AliPaySendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.app; 2 | 3 | /** 4 | * 支付宝消息发送处理器 5 | * @author huangkh 6 | */ 7 | public class AliPaySendProcessor implements SocialAppSendProcessor{ 8 | 9 | @Override 10 | public void process(String target) { 11 | this.send(target); 12 | } 13 | 14 | @Override 15 | public void send(String content) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/app/SocialAppSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.app; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 社交APP通知处理器 7 | * @author huangkh 8 | */ 9 | public interface SocialAppSendProcessor extends TaskProcessor { 10 | 11 | void send(String content); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/app/WeiXinSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.app; 2 | 3 | /** 4 | * 微信通知发送处理器 5 | * @author huangkh 6 | */ 7 | public class WeiXinSendProcessor implements SocialAppSendProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.send(target); 11 | } 12 | 13 | @Override 14 | public void send(String content) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/mail/MailSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.mail; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 邮件发送处理器 7 | * @author huangkh 8 | */ 9 | public interface MailSendProcessor extends TaskProcessor { 10 | 11 | void send(String content); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/mail/NetEaseMailSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.mail; 2 | 3 | /** 4 | * 网易邮箱发送处理器 5 | * @author huangkh 6 | */ 7 | public class NetEaseMailSendProcessor implements MailSendProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.send(target); 11 | } 12 | 13 | @Override 14 | public void send(String content) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/mail/QqMailSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.mail; 2 | 3 | /** 4 | * QQ邮件发送处理器 5 | * @author huangkh 6 | */ 7 | public class QqMailSendProcessor implements MailSendProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.send(target); 11 | } 12 | 13 | @Override 14 | public void send(String content) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/sms/AliSmsSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.sms; 2 | 3 | /** 4 | * 阿里短信发送处理器 5 | * @author huangkh 6 | */ 7 | public class AliSmsSendProcessor implements SmsSendProcessor { 8 | @Override 9 | public void process(String target) { 10 | this.send(target); 11 | } 12 | 13 | @Override 14 | public void send(String content) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/sms/JiGuangSmsSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.sms; 2 | 3 | /** 4 | * 极光短信发送处理器 5 | * @author huangkh 6 | */ 7 | public class JiGuangSmsSendProcessor implements SmsSendProcessor{ 8 | @Override 9 | public void process(String target) { 10 | this.send(target); 11 | } 12 | 13 | @Override 14 | public void send(String content) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/action/task/notice/sms/SmsSendProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.action.task.notice.sms; 2 | 3 | import com.hkh.ai.agent.action.task.TaskProcessor; 4 | 5 | /** 6 | * 短信发送处理器 7 | * @author huangkh 8 | */ 9 | public interface SmsSendProcessor extends TaskProcessor { 10 | 11 | void send(String content); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/AiFunctionFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core; 2 | 3 | public class AiFunctionFactory { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/Environment.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core; 2 | 3 | import com.hkh.ai.domain.DemandStep; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 环境 10 | * @author huangkh 11 | */ 12 | public class Environment { 13 | 14 | private String demand; 15 | 16 | private String workspace; 17 | 18 | private List stepList; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/God.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * 神 7 | * @author huangkh 8 | */ 9 | @Component 10 | public class God { 11 | 12 | /** 13 | * 创建环境 14 | */ 15 | public void createEnvironment(){ 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/ToolFunctionFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core; 2 | 3 | public class ToolFunctionFactory { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/function/AiFunctionType.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core.function; 2 | 3 | /** 4 | * AI能力类型枚举 5 | * @author huangkh 6 | */ 7 | public enum AiFunctionType { 8 | 9 | TEXT_GEN("文本生成"), 10 | IMAGE_GEN("图片生成"), 11 | VIDEO_GEN("视频生成"), 12 | ; 13 | 14 | private String type; 15 | 16 | AiFunctionType(String type) { 17 | this.type = type; 18 | } 19 | 20 | public String getType() { 21 | return type; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/function/FunctionType.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core.function; 2 | 3 | /** 4 | * 能力类型枚举 5 | * @author huangkh 6 | */ 7 | public enum FunctionType { 8 | 9 | TOOL("工具"), 10 | AI("AI"); 11 | 12 | private String type; 13 | 14 | FunctionType(String type) { 15 | this.type = type; 16 | } 17 | 18 | public String getType() { 19 | return type; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/function/ToolFunction.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core.function; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.function.Function; 6 | 7 | public class ToolFunction implements Function { 8 | @Override 9 | public Object apply(Object o) { 10 | return null; 11 | } 12 | 13 | @NotNull 14 | @Override 15 | public Function andThen(@NotNull Function after) { 16 | return Function.super.andThen(after); 17 | } 18 | 19 | @NotNull 20 | @Override 21 | public Function compose(@NotNull Function before) { 22 | return Function.super.compose(before); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/core/function/ToolFunctionType.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.core.function; 2 | 3 | /** 4 | * 工具能力类型枚举 5 | * @author huangkh 6 | */ 7 | public enum ToolFunctionType { 8 | 9 | SEARCH("资料搜索"), 10 | CRAWL("网页爬取"), 11 | FILE("文件读写"), 12 | BASH("命令脚本"), 13 | ANALYSIS("数据分析"), 14 | API_PAY("网络支付"), 15 | API_WEATHER("天气查询"), 16 | API_SMS("短信发送"), 17 | API_MAIL("邮件发送"), 18 | API_ORDER("订单查询"), 19 | ; 20 | 21 | private String type; 22 | 23 | ToolFunctionType(String type) { 24 | this.type = type; 25 | } 26 | 27 | public String getType() { 28 | return type; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/input/UserInputMessage.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.input; 2 | 3 | /** 4 | * 用户输入消息接口,仅是一个标记作用 5 | * @author huangkh 6 | */ 7 | public interface UserInputMessage { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/input/demand/DemandMessage.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.input.demand; 2 | 3 | import com.hkh.ai.agent.input.UserInputMessage; 4 | import lombok.Data; 5 | 6 | /** 7 | * 需求消息 8 | */ 9 | @Data 10 | public class DemandMessage implements UserInputMessage { 11 | 12 | /** 13 | * 所属领域:如软件开发领域 14 | */ 15 | private String field; 16 | 17 | /** 18 | * 内容 19 | */ 20 | private String content; 21 | 22 | /** 23 | * 明确的 24 | */ 25 | private boolean unambiguous; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/demand/DemandStepRolePrompt.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.demand; 2 | 3 | import com.hkh.ai.chain.prompt.PromptTemplate; 4 | 5 | public class DemandStepRolePrompt extends PromptTemplate { 6 | 7 | public static String prompt(String... args){ 8 | DemandStepRolePrompt demandStepRolePrompt = new DemandStepRolePrompt(); 9 | return demandStepRolePrompt.replaceArgs(args); 10 | } 11 | 12 | @Override 13 | public String replaceArgs(String... args) { 14 | String agentField = args[0]; 15 | String propose = args[1]; 16 | String roles = args[2]; 17 | String step = args[3]; 18 | String prompt = 19 | message.replace("{{ agentField }}", agentField) 20 | .replace("{{ propose }}", propose) 21 | .replace("{{ roles }}", roles) 22 | .replace("{{ step }}", step); 23 | return prompt; 24 | } 25 | 26 | private String message = 27 | """ 28 | {{ agentField }},我们的最终目标是:{{ propose }},请从角色列表({{ roles }})中选择一个合适的角色担当负责人完成以下任务: 29 | {{ step }}。 30 | 最终结果以json格式进行输出,以方便java fastjson库进行解析。 31 | """; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/demand/functionObj/DemandFuncObj.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.demand.functionObj; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | public class DemandFuncObj { 11 | 12 | @JsonPropertyDescription("The list of roles") 13 | @JsonProperty(required = true) 14 | private List roles; 15 | 16 | @JsonPropertyDescription("The list of steps") 17 | @JsonProperty(required = true) 18 | private List steps; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/demand/functionObj/DemandRoleFuncObj.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.demand.functionObj; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 5 | import lombok.Data; 6 | 7 | @Data 8 | public class DemandRoleFuncObj { 9 | 10 | @JsonPropertyDescription("The name of the role") 11 | @JsonProperty(required = true) 12 | public String roleName; 13 | 14 | @JsonPropertyDescription("The description of the role") 15 | @JsonProperty(required = true) 16 | public String duty; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/demand/functionObj/DemandStepFunObj.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.demand.functionObj; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 5 | import lombok.Data; 6 | 7 | @Data 8 | public class DemandStepFunObj { 9 | 10 | @JsonPropertyDescription("The name of the step") 11 | @JsonProperty(required = true) 12 | public String stepName; 13 | 14 | @JsonPropertyDescription("The description of the step") 15 | @JsonProperty(required = true) 16 | public String description; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/demand/functionObj/StepRoleFuncObj.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.demand.functionObj; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 5 | import lombok.Data; 6 | 7 | @Data 8 | public class StepRoleFuncObj { 9 | 10 | @JsonPropertyDescription("role name") 11 | @JsonProperty(required = true) 12 | private String roleName; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/function/FunctionTypePrompt.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.function; 2 | 3 | import com.hkh.ai.chain.prompt.PromptTemplate; 4 | 5 | public class FunctionTypePrompt extends PromptTemplate { 6 | 7 | 8 | public static String prompt(String... args){ 9 | FunctionTypePrompt functionTypePrompt = new FunctionTypePrompt(); 10 | return functionTypePrompt.replaceArgs(args); 11 | } 12 | 13 | @Override 14 | public String replaceArgs(String... args) { 15 | String role = args[0]; 16 | String stepName = args[1]; 17 | String description = args[2]; 18 | String prompt = message.replace("{{ role }}", role).replace("{{ stepName }}", stepName).replace("{{ description }}", description); 19 | return prompt; 20 | } 21 | 22 | private String message = 23 | """ 24 | 您当前的角色是{{ role }},现在有一个{{ stepName }}任务,具体任务内容如下:{{ description }}。 25 | 请分析完成以上任务,需要用哪一种工具去完成任务,如果任务内容涉及AI相关内容,如NLP自然语言理解、文本生成、文本总结、文本提取、文本生成图片、文本生成视频等内容,请回答AI,其他请回答TOOL,最终结果以json格式进行输出,以方便java fastjson库进行解析。 26 | """; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/agent/prompt/function/functionObj/FunctionTypeFuncObj.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.agent.prompt.function.functionObj; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 5 | import com.hkh.ai.agent.core.function.FunctionType; 6 | import lombok.Data; 7 | 8 | @Data 9 | public class FunctionTypeFuncObj { 10 | 11 | @JsonPropertyDescription("type of function required to complete task,AI or TOOL") 12 | @JsonProperty(required = true) 13 | private FunctionType functionType; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/callback/FunctionCaller.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.callback; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import com.hkh.ai.domain.function.DatePeriod; 5 | import lombok.Data; 6 | import lombok.extern.slf4j.Slf4j; 7 | 8 | @Slf4j 9 | @Data 10 | public class FunctionCaller { 11 | 12 | /** 13 | * 查询天气API(模拟) 14 | * @param jsonNode 15 | * @return 16 | */ 17 | public String get_location_weather(JSONObject jsonNode){ 18 | String location = jsonNode.getString("location"); 19 | String datePeriod = jsonNode.getString("datePeriod"); 20 | // String valueByName = DatePeriod.getValueByName(datePeriod); 21 | String result = "(模拟)通过查询天气API得到:" +location + datePeriod + "天气为晴天"; 22 | log.info(result); 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/BaiduChatApis.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation; 2 | 3 | /** 4 | * 百度千帆相关 API 5 | */ 6 | public interface BaiduChatApis { 7 | 8 | String ERNIE_BOT = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions"; 9 | 10 | String ERNIE_BOT4 = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro"; 11 | 12 | String ERNIE_BOT_TURBO = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant"; 13 | 14 | String GET_TOKEN = "https://aip.baidubce.com/oauth/2.0/token"; 15 | 16 | String EMBEDDING_EMBEDDING_V1 = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/embeddings/embedding-v1"; 17 | 18 | String EMBEDDING_BGE_LARGE_ZH = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/embeddings/bge_large_zh"; 19 | 20 | String EMBEDDING_BGE_LARGE_EN = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/embeddings/bge_large_en"; 21 | 22 | String IMAGE_CREATE = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/text2image/sd_xl"; 23 | 24 | String IMAGE_VISION = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/image2text/{yourServiceId}"; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/KimiAiUtil.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * Kimi 工具类 9 | * @author huangkh 10 | */ 11 | @Component 12 | @Slf4j 13 | public class KimiAiUtil { 14 | 15 | @Value("${chain.llm.kimi.model}") 16 | private String completionModel; 17 | 18 | @Value("${kimi.ai.token}") 19 | private String appKey; 20 | 21 | public String getCompletionModel(){ 22 | return this.completionModel; 23 | } 24 | 25 | public String getAppKey(){ 26 | return this.appKey; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/KimiApis.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation; 2 | 3 | /** 4 | * Kimi AI相关 API 5 | */ 6 | public interface KimiApis { 7 | 8 | String COMPLETION_TEXT = "https://api.moonshot.cn/v1/chat/completions"; 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/ZhipuChatApis.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation; 2 | 3 | /** 4 | * 智普AI相关 API 5 | */ 6 | public interface ZhipuChatApis { 7 | 8 | String COMPLETION_TEXT = "https://open.bigmodel.cn/api/paas/v4/chat/completions"; 9 | 10 | String COMPLETION_IMAGE = "https://open.bigmodel.cn/api/paas/v4/images/generations"; 11 | 12 | String COMPLETION_CHARACTER = "https://open.bigmodel.cn/api/paas/v3/model-api/charglm-3/sse-invoke"; 13 | 14 | String COMPLETION_VISION = "https://open.bigmodel.cn/api/paas/v4/chat/completions"; 15 | 16 | String EMBEDDING_EMBEDDING_V2 = "https://open.bigmodel.cn/api/paas/v4/embeddings"; 17 | 18 | String FILE_UPLOAD = "https://open.bigmodel.cn/api/paas/v4/files"; 19 | 20 | String FILE_LIST = "https://open.bigmodel.cn/api/paas/v4/files"; 21 | 22 | String FINE_TURNING_CREATE_JOB = "https://open.bigmodel.cn/api/paas/v4/fine_tuning/jobs"; 23 | 24 | String FINE_TURNING_JOB_EVENTS = "https://open.bigmodel.cn/api/paas/v4/fine_tuning/jobs//events?limit=50"; 25 | 26 | String FINE_TURNING_JOB = "https://open.bigmodel.cn/api/paas/v4/fine_tuning/jobs/"; 27 | 28 | String FINE_TURNING_JOBS = "https://open.bigmodel.cn/api/paas/v4/fine_tuning/jobs"; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/audio/AudioChatService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.audio; 2 | 3 | import com.hkh.ai.domain.Conversation; 4 | import com.hkh.ai.domain.CustomChatMessage; 5 | import com.hkh.ai.domain.SysUser; 6 | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; 7 | 8 | import java.io.File; 9 | import java.io.InputStream; 10 | import java.util.List; 11 | 12 | /** 13 | * 语音聊天服务 14 | * @author huangkh 15 | */ 16 | public interface AudioChatService { 17 | String audioToText(File audio, String prompt); 18 | 19 | void audioChat(CustomChatMessage customChatMessage, List nearestList, List history, SseEmitter sseEmitter, SysUser sysUser, String mediaId); 20 | 21 | InputStream createSpeech(String content); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/audio/AudioChatServiceFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.audio; 2 | 3 | import com.hkh.ai.chain.llm.capabilities.generation.audio.openai.OpenAiAudioChatService; 4 | import com.hkh.ai.chain.llm.capabilities.generation.text.TextChatService; 5 | import com.hkh.ai.chain.llm.capabilities.generation.text.baidu.BaiduQianFanTextChatService; 6 | import com.hkh.ai.chain.llm.capabilities.generation.text.chatglm2.Chatglm2TextChatService; 7 | import com.hkh.ai.chain.llm.capabilities.generation.text.openai.OpenAiTextChatService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | @Slf4j 14 | public class AudioChatServiceFactory { 15 | 16 | @Value("${chain.llm.audio.type}") 17 | private String type; 18 | 19 | private final OpenAiAudioChatService openAiAudioChatService; 20 | 21 | public AudioChatServiceFactory(OpenAiAudioChatService openAiAudioChatService) { 22 | this.openAiAudioChatService = openAiAudioChatService; 23 | } 24 | 25 | public AudioChatService getAudioChatService(){ 26 | if("openai".equals(type)){ 27 | return openAiAudioChatService; 28 | }else { 29 | return null; 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/ChatFunctionObject.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | @Data 10 | public class ChatFunctionObject { 11 | 12 | private String name; 13 | private String description; 14 | private FunctionParameters parameters; 15 | private String[] required; 16 | 17 | public ChatFunctionObject build(String functionName, String functionDescription, List filedNameList,List filedTypeList,List fieldDescriptionList, String[] required){ 18 | ChatFunctionObject chatFunctionObject = new ChatFunctionObject(); 19 | chatFunctionObject.setName(functionName); 20 | chatFunctionObject.setDescription(functionDescription); 21 | Map properties = new HashMap<>(); 22 | for (int i = 0; i < filedNameList.size(); i++) { 23 | properties.put(filedNameList.get(i),new FunctionParametersFieldValue(filedTypeList.get(i),fieldDescriptionList.get(i))); 24 | } 25 | FunctionParameters functionParameters = new FunctionParameters("object",properties); 26 | chatFunctionObject.setParameters(functionParameters); 27 | chatFunctionObject.setRequired(required); 28 | return chatFunctionObject; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionChatService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 函数调用服务接口 7 | * @author huangkh 8 | */ 9 | public interface FunctionChatService { 10 | /** 11 | * 函数调用:输出结构化参数数据 12 | * @param content 13 | * @return 14 | */ 15 | List functionCompletion(String content, List functionObjectList); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionChatServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.context.annotation.Primary; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 函数调用服务接口 12 | * @author huangkh 13 | */ 14 | @Slf4j 15 | @Service 16 | @Primary 17 | @AllArgsConstructor 18 | public class FunctionChatServiceWrapper implements FunctionChatService{ 19 | 20 | private final FunctionChatServiceFactory functionChatServiceFactory; 21 | @Override 22 | public List functionCompletion(String content, List functionObjectList) { 23 | FunctionChatService functionChatService = functionChatServiceFactory.getFunctionChatService(); 24 | return functionChatService.functionCompletion(content,functionObjectList); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionCompletionResult.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class FunctionCompletionResult { 8 | 9 | private String type; 10 | 11 | private String name; 12 | 13 | private JSONObject arguments; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionParameters.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.util.Map; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | public class FunctionParameters { 11 | private String type = "object"; 12 | private Map properties; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionParametersField.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class FunctionParametersField { 9 | private String name; 10 | private String type; 11 | private String description; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/FunctionParametersFieldValue.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class FunctionParametersFieldValue { 9 | private String type; 10 | private String description; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/function/baidu/BaiduFunctionCompletionResult.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.function.baidu; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class BaiduFunctionCompletionResult { 8 | 9 | private String id; 10 | 11 | private String object; 12 | 13 | private Long created; 14 | 15 | private String result; 16 | 17 | private Boolean is_truncated; 18 | 19 | private Boolean need_clear_history; 20 | 21 | private JSONObject function_call; 22 | 23 | private BlockCompletionResultUsage usage; 24 | 25 | @Data 26 | class BlockCompletionResultUsage{ 27 | private int prompt_tokens; 28 | 29 | private int completion_tokens; 30 | 31 | private int total_tokens; 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/image/ImageChatService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.image; 2 | 3 | import java.util.List; 4 | 5 | public interface ImageChatService { 6 | 7 | List createImage(String prompt); 8 | 9 | List editImage(String content, List httpUrls); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/image/ImageChatServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.image; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.context.annotation.Primary; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | @Service 11 | @Primary 12 | @Slf4j 13 | @AllArgsConstructor 14 | public class ImageChatServiceWrapper implements ImageChatService{ 15 | 16 | private final ImageChatServiceFactory imageChatServiceFactory; 17 | @Override 18 | public List createImage(String prompt) { 19 | ImageChatService imageChatService = imageChatServiceFactory.getImageChatService(); 20 | return imageChatService.createImage(prompt); 21 | } 22 | 23 | @Override 24 | public List editImage(String content, List httpUrls) { 25 | ImageChatService imageChatService = imageChatServiceFactory.getImageChatService(); 26 | return imageChatService.editImage(content,httpUrls); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/text/TextChatService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.text; 2 | 3 | import com.hkh.ai.domain.Conversation; 4 | import com.hkh.ai.domain.CustomChatMessage; 5 | import com.hkh.ai.domain.SysUser; 6 | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; 7 | 8 | import java.io.IOException; 9 | import java.util.List; 10 | 11 | /** 12 | * 文本聊天服务接口 13 | * @author huangkh 14 | */ 15 | public interface TextChatService { 16 | /** 17 | * 流式聊天 18 | * @param request 19 | * @param nearestList 20 | * @param history 21 | * @param sseEmitter 22 | * @param sysUser 23 | */ 24 | void streamChat(CustomChatMessage request, List nearestList, List history, SseEmitter sseEmitter, SysUser sysUser) throws IOException; 25 | 26 | /** 27 | * 阻塞推理 28 | * @param content 29 | * @return 30 | */ 31 | String blockCompletion(String content); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/text/TextChatServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.text; 2 | 3 | import com.hkh.ai.domain.Conversation; 4 | import com.hkh.ai.domain.CustomChatMessage; 5 | import com.hkh.ai.domain.SysUser; 6 | import lombok.AllArgsConstructor; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.context.annotation.Primary; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; 11 | 12 | import java.io.IOException; 13 | import java.util.List; 14 | 15 | @Slf4j 16 | @Service 17 | @Primary 18 | @AllArgsConstructor 19 | public class TextChatServiceWrapper implements TextChatService{ 20 | 21 | private final TextChatServiceFactory textChatServiceFactory; 22 | 23 | @Override 24 | public void streamChat(CustomChatMessage request, List nearestList, List history, SseEmitter sseEmitter, SysUser sysUser) throws IOException { 25 | TextChatService textChatService = textChatServiceFactory.getTextChatService(); 26 | textChatService.streamChat(request, nearestList, history,sseEmitter,sysUser); 27 | } 28 | 29 | @Override 30 | public String blockCompletion(String content) { 31 | TextChatService textChatService = textChatServiceFactory.getTextChatService(); 32 | return textChatService.blockCompletion(content); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/text/baidu/BlockCompletionResult.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.text.baidu; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class BlockCompletionResult { 7 | 8 | private String id; 9 | 10 | private String object; 11 | 12 | private Long created; 13 | 14 | private String result; 15 | 16 | private Boolean is_truncated; 17 | 18 | private Boolean need_clear_history; 19 | 20 | private BlockCompletionResultUsage usage; 21 | 22 | @Data 23 | class BlockCompletionResultUsage{ 24 | private int prompt_tokens; 25 | 26 | private int completion_tokens; 27 | 28 | private int total_tokens; 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/text/baidu/StreamCompletionResult.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.text.baidu; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 流式响应结果 7 | * @author huangkh 8 | */ 9 | @Data 10 | public class StreamCompletionResult { 11 | 12 | private String id; 13 | 14 | private String object; 15 | 16 | private Long created; 17 | 18 | private Integer sentence_id; 19 | 20 | private Boolean is_end; 21 | 22 | private Boolean is_truncated; 23 | 24 | private String result; 25 | 26 | private Boolean need_clear_history; 27 | 28 | private BlockCompletionResultUsage usage; 29 | 30 | @Data 31 | class BlockCompletionResultUsage{ 32 | private int prompt_tokens; 33 | 34 | private int completion_tokens; 35 | 36 | private int total_tokens; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/vision/VisionChatService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.vision; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 图文多模态接口(即图像理解) 7 | * @author huangkh 8 | */ 9 | public interface VisionChatService { 10 | 11 | 12 | /** 13 | * 图像理解 14 | * @param content 15 | * @param imageUrlList 16 | * @return 17 | */ 18 | String visionCompletion(String content, List imageUrlList); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/vision/VisionChatServiceFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.vision; 2 | 3 | import com.hkh.ai.chain.llm.capabilities.generation.vision.openai.OpenAiVisionChatService; 4 | import com.hkh.ai.chain.llm.capabilities.generation.vision.zhipu.ZhipuVisionChatService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | @Slf4j 11 | public class VisionChatServiceFactory { 12 | 13 | @Value("${chain.llm.vision.type}") 14 | private String type; 15 | 16 | private final OpenAiVisionChatService openAiVisionChatService; 17 | private final ZhipuVisionChatService zhipuVisionChatService; 18 | 19 | public VisionChatServiceFactory(OpenAiVisionChatService openAiVisionChatService, ZhipuVisionChatService zhipuVisionChatService) { 20 | this.openAiVisionChatService = openAiVisionChatService; 21 | this.zhipuVisionChatService = zhipuVisionChatService; 22 | } 23 | 24 | public VisionChatService getVisionChatService(){ 25 | if("openai".equals(type)){ 26 | return openAiVisionChatService; 27 | }else if("zhipu".equals(type)){ 28 | return zhipuVisionChatService; 29 | }else { 30 | return null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/llm/capabilities/generation/vision/VisionChatServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.llm.capabilities.generation.vision; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.context.annotation.Primary; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | @Service 11 | @Slf4j 12 | @Primary 13 | @AllArgsConstructor 14 | public class VisionChatServiceWrapper implements VisionChatService{ 15 | 16 | private final VisionChatServiceFactory visionChatServiceFactory; 17 | 18 | @Override 19 | public String visionCompletion(String content, List imageUrlList) { 20 | VisionChatService visionChatService = visionChatServiceFactory.getVisionChatService(); 21 | return visionChatService.visionCompletion(content,imageUrlList); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/CodeFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.chain.split.TextSplitter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | import java.util.List; 13 | 14 | @Component 15 | @AllArgsConstructor 16 | @Slf4j 17 | public class CodeFileLoader implements ResourceLoader{ 18 | private final TextSplitter textSplitter; 19 | @Override 20 | public String getContent(InputStream inputStream) { 21 | StringBuffer stringBuffer = new StringBuffer(); 22 | try (InputStreamReader reader = new InputStreamReader(inputStream); 23 | BufferedReader bufferedReader = new BufferedReader(reader)){ 24 | String line; 25 | while ((line = bufferedReader.readLine()) != null) { 26 | stringBuffer.append(line).append("\n"); 27 | } 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } 31 | return stringBuffer.toString(); 32 | } 33 | @Override 34 | public List getChunkList(String content){ 35 | return textSplitter.split(content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/CsvFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | public class CsvFileLoader implements ResourceLoader{ 7 | @Override 8 | public String getContent(InputStream inputStream) { 9 | return null; 10 | } 11 | 12 | @Override 13 | public List getChunkList(String content) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/FolderLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | public class FolderLoader implements ResourceLoader{ 7 | @Override 8 | public String getContent(InputStream inputStream) { 9 | return null; 10 | } 11 | 12 | @Override 13 | public List getChunkList(String content) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/GithubLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | public class GithubLoader implements ResourceLoader{ 7 | @Override 8 | public String getContent(InputStream inputStream) { 9 | return null; 10 | } 11 | 12 | @Override 13 | public List getChunkList(String content) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/JsonFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | public class JsonFileLoader implements ResourceLoader{ 7 | @Override 8 | public String getContent(InputStream inputStream) { 9 | return null; 10 | } 11 | 12 | @Override 13 | public List getChunkList(String content) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/MarkDownFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.chain.split.TextSplitter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | import java.util.List; 13 | 14 | @Component 15 | @AllArgsConstructor 16 | @Slf4j 17 | public class MarkDownFileLoader implements ResourceLoader{ 18 | private final TextSplitter textSplitter; 19 | @Override 20 | public String getContent(InputStream inputStream) { 21 | StringBuffer stringBuffer = new StringBuffer(); 22 | try (InputStreamReader reader = new InputStreamReader(inputStream); 23 | BufferedReader bufferedReader = new BufferedReader(reader)){ 24 | String line; 25 | while ((line = bufferedReader.readLine()) != null) { 26 | stringBuffer.append(line).append("\n"); 27 | } 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } 31 | return stringBuffer.toString(); 32 | } 33 | @Override 34 | public List getChunkList(String content){ 35 | return textSplitter.split(content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/PdfFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.chain.split.TextSplitter; 4 | import lombok.AllArgsConstructor; 5 | import org.apache.pdfbox.pdmodel.PDDocument; 6 | import org.apache.pdfbox.text.PDFTextStripper; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.util.List; 12 | 13 | @Component 14 | @AllArgsConstructor 15 | public class PdfFileLoader implements ResourceLoader{ 16 | private final TextSplitter characterTextSplitter; 17 | @Override 18 | public String getContent(InputStream inputStream) { 19 | PDDocument document = null; 20 | try { 21 | document = PDDocument.load(inputStream); 22 | PDFTextStripper textStripper = new PDFTextStripper(); 23 | String content = textStripper.getText(document); 24 | return content; 25 | } catch (IOException e) { 26 | throw new RuntimeException(e); 27 | } 28 | } 29 | 30 | @Override 31 | public List getChunkList(String content) { 32 | return characterTextSplitter.split(content); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | /** 7 | * 资源载入 8 | */ 9 | public interface ResourceLoader { 10 | String getContent(InputStream inputStream); 11 | List getChunkList(String content); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/ResourceLoaderFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.common.constant.FileType; 4 | import com.hkh.ai.chain.split.CharacterTextSplitter; 5 | import com.hkh.ai.chain.split.CodeTextSplitter; 6 | import com.hkh.ai.chain.split.MarkdownTextSplitter; 7 | import com.hkh.ai.chain.split.TokenTextSplitter; 8 | import lombok.AllArgsConstructor; 9 | import org.springframework.stereotype.Component; 10 | 11 | @AllArgsConstructor 12 | @Component 13 | public class ResourceLoaderFactory { 14 | private final CharacterTextSplitter characterTextSplitter; 15 | private final CodeTextSplitter codeTextSplitter; 16 | private final MarkdownTextSplitter markdownTextSplitter; 17 | private final TokenTextSplitter tokenTextSplitter; 18 | public ResourceLoader getLoaderByFileType(String fileType){ 19 | if (FileType.isTextFile(fileType)){ 20 | return new TextFileLoader(characterTextSplitter); 21 | } else if (FileType.isWord(fileType)) { 22 | return new WordLoader(characterTextSplitter); 23 | } else if (FileType.isPdf(fileType)) { 24 | return new PdfFileLoader(characterTextSplitter); 25 | } else if (FileType.isMdFile(fileType)) { 26 | return new MarkDownFileLoader(markdownTextSplitter); 27 | }else if (FileType.isCodeFile(fileType)) { 28 | return new CodeFileLoader(codeTextSplitter); 29 | }else { 30 | return new TextFileLoader(characterTextSplitter); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/TextFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.chain.split.TextSplitter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | import java.util.List; 13 | 14 | @Component 15 | @AllArgsConstructor 16 | @Slf4j 17 | public class TextFileLoader implements ResourceLoader{ 18 | private final TextSplitter textSplitter; 19 | @Override 20 | public String getContent(InputStream inputStream) { 21 | StringBuffer stringBuffer = new StringBuffer(); 22 | try (InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8"); 23 | BufferedReader bufferedReader = new BufferedReader(reader)){ 24 | String line; 25 | while ((line = bufferedReader.readLine()) != null) { 26 | stringBuffer.append(line).append("\n"); 27 | } 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } 31 | return stringBuffer.toString(); 32 | } 33 | @Override 34 | public List getChunkList(String content){ 35 | return textSplitter.split(content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/loader/WordLoader.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.loader; 2 | 3 | import com.hkh.ai.chain.split.TextSplitter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.poi.xwpf.extractor.XWPFWordExtractor; 7 | import org.apache.poi.xwpf.usermodel.XWPFDocument; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.util.List; 13 | 14 | @Component 15 | @AllArgsConstructor 16 | @Slf4j 17 | public class WordLoader implements ResourceLoader{ 18 | private final TextSplitter textSplitter; 19 | @Override 20 | public String getContent(InputStream inputStream) { 21 | XWPFDocument document = null; 22 | try { 23 | document = new XWPFDocument(inputStream); 24 | XWPFWordExtractor extractor = new XWPFWordExtractor(document); 25 | String content = extractor.getText(); 26 | return content; 27 | } catch (IOException e) { 28 | throw new RuntimeException(e); 29 | } 30 | } 31 | 32 | @Override 33 | public List getChunkList(String content) { 34 | return textSplitter.split(content); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/plugin/search/engine/WebSearchEngine.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.plugin.search.engine; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.MalformedURLException; 6 | 7 | /** 8 | * 搜索引擎结果 9 | * @author huangkh 10 | */ 11 | public interface WebSearchEngine { 12 | 13 | InputStream search(String searchWord); 14 | 15 | String load(InputStream inputStream); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/plugin/search/engine/WebSearchEngineFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.plugin.search.engine; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @Slf4j 9 | public class WebSearchEngineFactory { 10 | 11 | @Value("${chain.plugin.search.type}") 12 | private String type; 13 | 14 | private final BaiduWebSearchEngine baiduWebSearchEngine; 15 | private final BingWebSearchEngine bingWebSearchEngine; 16 | private final GoogleWebSearchEngine googleWebSearchEngine; 17 | 18 | public WebSearchEngineFactory(BaiduWebSearchEngine baiduWebSearchEngine, BingWebSearchEngine bingWebSearchEngine, GoogleWebSearchEngine googleWebSearchEngine) { 19 | this.baiduWebSearchEngine = baiduWebSearchEngine; 20 | this.bingWebSearchEngine = bingWebSearchEngine; 21 | this.googleWebSearchEngine = googleWebSearchEngine; 22 | } 23 | 24 | public WebSearchEngine getEngine(){ 25 | if ("baidu".equals(type)){ 26 | return baiduWebSearchEngine; 27 | }else if ("google".equals(type)){ 28 | return googleWebSearchEngine; 29 | }else if ("bing".equals(type)){ 30 | return bingWebSearchEngine; 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/plugin/search/engine/WebSearchEngineWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.plugin.search.engine; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.context.annotation.Primary; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | 11 | @Slf4j 12 | @Service 13 | @Primary 14 | @AllArgsConstructor 15 | public class WebSearchEngineWrapper implements WebSearchEngine{ 16 | 17 | private final WebSearchEngineFactory webSearchEngineFactory; 18 | @Override 19 | public InputStream search(String searchWord) { 20 | WebSearchEngine engine = webSearchEngineFactory.getEngine(); 21 | return engine.search(searchWord); 22 | } 23 | 24 | @Override 25 | public String load(InputStream inputStream) { 26 | WebSearchEngine engine = webSearchEngineFactory.getEngine(); 27 | return engine.load(inputStream); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/prompt/ChatPromptTemplate.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.prompt; 2 | 3 | public class ChatPromptTemplate extends PromptTemplate{ 4 | 5 | public String replaceArgs(String... args) { 6 | return null; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/prompt/FewShotPromptTemplate.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.prompt; 2 | 3 | public class FewShotPromptTemplate extends PromptTemplate { 4 | 5 | public String replaceArgs(String... args) { 6 | return null; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/prompt/PromptTemplate.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.prompt; 2 | 3 | public class PromptTemplate { 4 | 5 | public String replaceArgs(String... args) { 6 | return null; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/retrieve/PromptRetrieverProperties.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.retrieve; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Data 8 | @Component 9 | @ConfigurationProperties(prefix = "chain.prompt.retriever") 10 | public class PromptRetrieverProperties { 11 | /** 12 | * 从知识库中检索的条数,limits 应大于 num 13 | */ 14 | private int limits; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/split/CodeTextSplitter.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.split; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | @AllArgsConstructor 11 | @Slf4j 12 | public class CodeTextSplitter implements TextSplitter{ 13 | @Override 14 | public List split(String content) { 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/split/MarkdownTextSplitter.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.split; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | @AllArgsConstructor 11 | @Slf4j 12 | public class MarkdownTextSplitter implements TextSplitter{ 13 | @Override 14 | public List split(String content) { 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/split/SplitterProperties.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.split; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Data 8 | @Component 9 | @ConfigurationProperties(prefix = "chain.split.chunk") 10 | public class SplitterProperties { 11 | private String endspliter; 12 | private String qaspliter; 13 | private int size; 14 | private int overlay; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/split/TextSplitter.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.split; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 文本切分 7 | */ 8 | public interface TextSplitter { 9 | 10 | List split(String content); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/split/TokenTextSplitter.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.split; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | @AllArgsConstructor 11 | @Slf4j 12 | public class TokenTextSplitter implements TextSplitter{ 13 | @Override 14 | public List split(String content) { 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorizer/Vectorization.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorizer; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 向量化 7 | */ 8 | public interface Vectorization { 9 | List> batchVectorization(List chunkList); 10 | List singleVectorization(String chunk); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorizer/VectorizationWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorizer; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.context.annotation.Primary; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | @Slf4j 12 | @Primary 13 | @AllArgsConstructor 14 | public class VectorizationWrapper implements Vectorization{ 15 | 16 | private final VectorizationFactory vectorizationFactory; 17 | @Override 18 | public List> batchVectorization(List chunkList) { 19 | Vectorization embedding = vectorizationFactory.getEmbedding(); 20 | return embedding.batchVectorization(chunkList); 21 | } 22 | 23 | @Override 24 | public List singleVectorization(String chunk) { 25 | Vectorization embedding = vectorizationFactory.getEmbedding(); 26 | return embedding.singleVectorization(chunk); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorizer/huggingface/HuggingFaceInferenceVectorization.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorizer.huggingface; 2 | 3 | import com.hkh.ai.chain.vectorizer.Vectorization; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | @Slf4j 11 | public class HuggingFaceInferenceVectorization implements Vectorization { 12 | @Override 13 | public List> batchVectorization(List chunkList) { 14 | return null; 15 | } 16 | 17 | @Override 18 | public List singleVectorization(String chunk) { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorizer/local/LocalAiVectorization.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorizer.local; 2 | 3 | import com.hkh.ai.chain.vectorizer.Vectorization; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 本地向量化(这里指 weaviate 内置的向量模型) 11 | * 说明:文本保存到向量库时自动生成文本的向量,所有方法的返回结果为 null 12 | */ 13 | @Component 14 | @Slf4j 15 | @Deprecated 16 | public class LocalAiVectorization implements Vectorization { 17 | @Override 18 | public List> batchVectorization(List chunkList) { 19 | return null; 20 | } 21 | 22 | @Override 23 | public List singleVectorization(String chunk) { 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorstore/VectorStore.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorstore; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 向量存储 7 | */ 8 | public interface VectorStore { 9 | void storeEmbeddings(List chunkList,List> vectorList, String kid, String docId,List fidList); 10 | void removeByDocId(String kid,String docId); 11 | void removeByKid(String kid); 12 | List nearest(List queryVector,String kid); 13 | List nearest(String query,String kid); 14 | 15 | void newSchema(String kid); 16 | 17 | void removeByKidAndFid(String kid, String fid); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/chain/vectorstore/VectorStoreFactory.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.chain.vectorstore; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @Slf4j 9 | public class VectorStoreFactory { 10 | 11 | @Value("${chain.vector.store.type}") 12 | private String type; 13 | 14 | private final WeaviateVectorStore weaviateVectorStore; 15 | 16 | private final MilvusVectorStore milvusVectorStore; 17 | 18 | private final PgVectorStore pgVectorStore; 19 | 20 | public VectorStoreFactory(WeaviateVectorStore weaviateVectorStore, MilvusVectorStore milvusVectorStore, PgVectorStore pgVectorStore) { 21 | this.weaviateVectorStore = weaviateVectorStore; 22 | this.milvusVectorStore = milvusVectorStore; 23 | this.pgVectorStore = pgVectorStore; 24 | } 25 | 26 | public VectorStore getVectorStore(){ 27 | if ("weaviate".equals(type)){ 28 | return weaviateVectorStore; 29 | }else if ("milvus".equals(type)){ 30 | return milvusVectorStore; 31 | }else if ("pg".equals(type)){ 32 | return pgVectorStore; 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/PageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.Data; 5 | 6 | /** 7 | * 分页查询参数基类 8 | * @author huangkh 9 | */ 10 | @Schema(title = "分页查询参数基类",description="用于分页查询参数基类,供其他类继承") 11 | @Data 12 | public class PageRequest { 13 | 14 | @Schema(title = "当前第几页,默认1",description = "当前第几页,默认1",defaultValue = "1",requiredMode = Schema.RequiredMode.REQUIRED) 15 | private Integer pageNum = 1; 16 | @Schema(title = "每页条数,默认8",description = "每页条数,默认8",defaultValue = "8",requiredMode = Schema.RequiredMode.REQUIRED) 17 | private Integer pageSize = 8; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/ResultCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common; 2 | 3 | public enum ResultCodeEnum { 4 | 5 | SUCCESS("200", "成功"), 6 | 7 | FAIL("400", "操作失败"), 8 | 9 | AUTH_FAIL("401", "认证失败"), 10 | 11 | SYS_ERR("500", "系统错误"), 12 | PARAM_ERROR("50001", "参数校验错误"), 13 | 14 | TOKEN_ERROR("50002", "TOKEN校验异常"), 15 | 16 | REPEAT_SUBMIT("50003", "重读提交"), 17 | 18 | DB_ERR("50004","数据库操作错误"), 19 | 20 | NO_PERMISSION("60001", "无权限"); 21 | 22 | 23 | private final String code; 24 | private final String message; 25 | 26 | ResultCodeEnum(String code, String message) { 27 | this.code = code; 28 | this.message = message; 29 | } 30 | 31 | public String getCode() { 32 | return code; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/annotation/AdminRequired.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Admin权限 注解 10 | * @author huangkh 11 | */ 12 | 13 | @Target({ElementType.METHOD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface AdminRequired { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/annotation/RepeatSubmit.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 自定义注解防止表单重复提交 7 | * 8 | * @author huangkh 9 | * 10 | */ 11 | @Inherited 12 | @Target(ElementType.METHOD) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface RepeatSubmit 16 | { 17 | /** 18 | * 间隔时间(ms),小于此时间视为重复提交 19 | */ 20 | public int interval() default 5000; 21 | 22 | /** 23 | * 提示消息 24 | */ 25 | public String message() default "不允许重复提交,请稍候再试"; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/annotation/TokenIgnore.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 忽略 token 注解 10 | * @author huangkh 11 | */ 12 | 13 | @Target({ElementType.METHOD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface TokenIgnore { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/constant/SysConstants.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.constant; 2 | 3 | public class SysConstants { 4 | 5 | public static final String SESSION_LOGIN_USER_KEY = "loginUser"; 6 | 7 | public static final String FORMAT_DATE_YYYY_MM_DD = "yyyy-MM-dd"; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/AuthException.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | public class AuthException extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public AuthException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/DbException.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | public class DbException extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public DbException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/ParamException.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | /** 4 | * 参数异常定义 5 | */ 6 | public class ParamException extends RuntimeException{ 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | public ParamException(String message) { 11 | super(message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/Request404Exception.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | public class Request404Exception extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public Request404Exception(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/SessionExpiredException.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | public class SessionExpiredException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public SessionExpiredException(String message) { 8 | super(message); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/common/exception/TokenException.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.common.exception; 2 | 3 | public class TokenException extends RuntimeException{ 4 | private static final long serialVersionUID = 1L; 5 | 6 | public TokenException(String message) { 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/config/FastJson2JsonRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.config; 2 | 3 | import com.alibaba.fastjson2.JSON; 4 | import com.alibaba.fastjson2.JSONReader; 5 | import com.alibaba.fastjson2.JSONWriter; 6 | import org.springframework.data.redis.serializer.RedisSerializer; 7 | import org.springframework.data.redis.serializer.SerializationException; 8 | 9 | import java.nio.charset.Charset; 10 | 11 | /** 12 | * Redis使用FastJson序列化 13 | * 14 | * @author huangkh 15 | */ 16 | public class FastJson2JsonRedisSerializer implements RedisSerializer 17 | { 18 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 19 | 20 | private Class clazz; 21 | 22 | public FastJson2JsonRedisSerializer(Class clazz) 23 | { 24 | super(); 25 | this.clazz = clazz; 26 | } 27 | 28 | @Override 29 | public byte[] serialize(T t) throws SerializationException 30 | { 31 | if (t == null) 32 | { 33 | return new byte[0]; 34 | } 35 | return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); 36 | } 37 | 38 | @Override 39 | public T deserialize(byte[] bytes) throws SerializationException 40 | { 41 | if (bytes == null || bytes.length <= 0) 42 | { 43 | return null; 44 | } 45 | String str = new String(bytes, DEFAULT_CHARSET); 46 | 47 | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/config/FreemarkerConfig.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.config; 2 | 3 | import no.api.freemarker.java8.Java8ObjectWrapper; 4 | import org.springframework.beans.BeansException; 5 | import org.springframework.beans.factory.config.BeanPostProcessor; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; 8 | 9 | @Configuration 10 | public class FreemarkerConfig implements BeanPostProcessor { 11 | 12 | @Override 13 | public Object postProcessAfterInitialization(Object bean, String beanName) 14 | throws BeansException { 15 | if (bean instanceof FreeMarkerConfigurer) { 16 | FreeMarkerConfigurer configurer = (FreeMarkerConfigurer) bean; 17 | configurer.getConfiguration().setObjectWrapper(new Java8ObjectWrapper(freemarker.template.Configuration.getVersion())); 18 | } 19 | return bean; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.config; 2 | 3 | import io.swagger.v3.oas.models.OpenAPI; 4 | import io.swagger.v3.oas.models.info.Info; 5 | import io.swagger.v3.oas.models.info.License; 6 | import org.springdoc.core.models.GroupedOpenApi; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Configuration 11 | public class SwaggerConfig { 12 | 13 | @Bean 14 | public OpenAPI customOpenAPI() { 15 | return new OpenAPI() 16 | .info(new Info() 17 | .title("langchain-springboot api") 18 | .version("1.0") 19 | .description( "接口文档") 20 | .termsOfService("https://github.com/hkh1012/langchain-springboot") 21 | .license(new License().name("Apache 2.0") 22 | .url("https://license.cxjk.com"))); 23 | } 24 | 25 | @Bean 26 | public GroupedOpenApi allApi(){ 27 | return GroupedOpenApi.builder() 28 | .group("1全部") 29 | .packagesToScan("com.hkh.ai.controller") 30 | .build(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/config/SysConfig.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @Data 9 | public class SysConfig { 10 | 11 | @Value("${upload.path}") 12 | private String uploadPath; 13 | 14 | @Value("${resource.domain}") 15 | private String resourceDomain; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class WebConfig implements WebMvcConfigurer { 9 | 10 | private String[] swaggerUrls = {"/doc.html", "/webjars/**","/swagger-ui/**","/swagger-ui*/**","/swagger-resources/**", "/v3/api-docs/**"}; 11 | 12 | @Override 13 | public void addCorsMappings(CorsRegistry registry) { 14 | registry.addMapping("/*/**") 15 | .allowedOriginPatterns("*") 16 | .allowedMethods("*") 17 | .allowedHeaders("*") 18 | .exposedHeaders("*") 19 | .allowCredentials(true).maxAge(3600); 20 | 21 | } 22 | 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/controller/ConversationController.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.controller; 2 | 3 | import com.hkh.ai.common.ResultData; 4 | import com.hkh.ai.domain.Conversation; 5 | import com.hkh.ai.request.ChatSessionRemoveRequest; 6 | import com.hkh.ai.service.ConversationService; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.validation.Valid; 9 | import lombok.AllArgsConstructor; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * 对话 16 | */ 17 | @RestController 18 | @AllArgsConstructor 19 | @RequestMapping("conversation") 20 | public class ConversationController { 21 | 22 | private final ConversationService conversationService; 23 | 24 | @GetMapping("/list/{sessionId}") 25 | public ResultData> list(@PathVariable(value = "sessionId") String sessionId) { 26 | List conversationList = conversationService.listBySessionId(sessionId); 27 | return ResultData.success(conversationList); 28 | } 29 | 30 | @PostMapping("/remove") 31 | public ResultData delete(HttpServletRequest httpServletRequest, @RequestBody @Valid ChatSessionRemoveRequest request) { 32 | conversationService.removeBySid(request.getSid()); 33 | return ResultData.success("删除成功"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/controller/view/RegisterController.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.controller.view; 2 | 3 | import lombok.AllArgsConstructor; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | 9 | /** 10 | * 注册 11 | */ 12 | @Controller 13 | @AllArgsConstructor 14 | public class RegisterController { 15 | 16 | @GetMapping("/register") 17 | public String registerUi(Model model) { 18 | return "register"; 19 | } 20 | 21 | 22 | @PostMapping("/register") 23 | public String register(){ 24 | return "chat"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/controller/view/SpecialNounViewController.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.controller.view; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.common.annotation.AdminRequired; 5 | import com.hkh.ai.common.constant.SysConstants; 6 | import com.hkh.ai.domain.SpecialNoun; 7 | import com.hkh.ai.domain.SysUser; 8 | import com.hkh.ai.request.SpecialNounPageRequest; 9 | import com.hkh.ai.service.SpecialNounService; 10 | import jakarta.servlet.http.HttpServletRequest; 11 | import lombok.AllArgsConstructor; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.ui.Model; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | 16 | @Controller 17 | @AllArgsConstructor 18 | public class SpecialNounViewController { 19 | 20 | private final SpecialNounService specialNounService; 21 | 22 | /** 23 | * 专有名词管理页面 24 | * @param request 25 | * @param model 26 | * @return 27 | */ 28 | @GetMapping(value = {"/special/index"}) 29 | @AdminRequired 30 | public String specialIndex(HttpServletRequest request, Model model, SpecialNounPageRequest specialNounPageRequest) { 31 | SysUser sysUser = (SysUser) request.getSession().getAttribute(SysConstants.SESSION_LOGIN_USER_KEY); 32 | model.addAttribute("sysUser",sysUser); 33 | PageInfo pageInfo = specialNounService.pageInfo(specialNounPageRequest); 34 | model.addAttribute("pageInfo",pageInfo); 35 | model.addAttribute("formData",specialNounPageRequest); 36 | return "special/index"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/AccessToken.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | import java.util.Date; 10 | 11 | import com.fasterxml.jackson.annotation.JsonFormat; 12 | import lombok.Data; 13 | 14 | /** 15 | * 第三方接口访问token 16 | * @TableName access_token 17 | */ 18 | @TableName(value ="access_token") 19 | @Data 20 | public class AccessToken implements Serializable { 21 | /** 22 | * 23 | */ 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | /** 28 | * 应用 29 | */ 30 | @TableField(value = "app") 31 | private String app; 32 | 33 | /** 34 | * token值 35 | */ 36 | @TableField(value = "token") 37 | private String token; 38 | 39 | /** 40 | * 过期时间 41 | */ 42 | @TableField(value = "expired_time") 43 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 44 | private LocalDateTime expiredTime; 45 | 46 | /** 47 | * 48 | */ 49 | @TableField(value = "create_time") 50 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 51 | private LocalDateTime createTime; 52 | 53 | /** 54 | * 55 | */ 56 | @TableField(value = "create_by") 57 | private String createBy; 58 | 59 | @TableField(exist = false) 60 | private static final long serialVersionUID = 1L; 61 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/AgentField.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import com.fasterxml.jackson.annotation.JsonFormat; 11 | import lombok.Data; 12 | 13 | /** 14 | * 代理领域 15 | * @TableName agent_field 16 | */ 17 | @TableName(value ="agent_field") 18 | @Data 19 | public class AgentField implements Serializable { 20 | /** 21 | * 22 | */ 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | /** 27 | * 领域ID 28 | */ 29 | @TableField(value = "fid") 30 | private String fid; 31 | 32 | /** 33 | * 领域名称 34 | */ 35 | @TableField(value = "field_name") 36 | private String fieldName; 37 | 38 | /** 39 | * 领域描述 40 | */ 41 | @TableField(value = "description") 42 | private String description; 43 | 44 | /** 45 | * 是否生效:0无效1有效 46 | */ 47 | @TableField(value = "status") 48 | private Boolean status; 49 | 50 | /** 51 | * 52 | */ 53 | @TableField(value = "create_time") 54 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 55 | private Date createTime; 56 | 57 | /** 58 | * 59 | */ 60 | @TableField(value = "create_by") 61 | private String createBy; 62 | 63 | @TableField(exist = false) 64 | private static final long serialVersionUID = 1L; 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/ChatSession.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | 10 | import com.fasterxml.jackson.annotation.JsonFormat; 11 | import lombok.Data; 12 | 13 | /** 14 | * 用户会话 15 | * @TableName chat_session 16 | */ 17 | @TableName(value ="chat_session") 18 | @Data 19 | public class ChatSession implements Serializable { 20 | /** 21 | * 22 | */ 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | /** 27 | * 会话ID 28 | */ 29 | @TableField(value = "sid") 30 | private String sid; 31 | 32 | /** 33 | * 会后标题 34 | */ 35 | @TableField(value = "title") 36 | private String title; 37 | 38 | /** 39 | * 模型ID 40 | */ 41 | @TableField(value = "model_id") 42 | private Integer modelId; 43 | 44 | /** 45 | * 用户ID 46 | */ 47 | @TableField(value = "user_id") 48 | private Integer userId; 49 | 50 | /** 51 | * 52 | */ 53 | @TableField(value = "create_time") 54 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 55 | private LocalDateTime createTime; 56 | 57 | /** 58 | * 59 | */ 60 | @TableField(value = "create_by") 61 | private String createBy; 62 | 63 | @TableField(exist = false) 64 | private static final long serialVersionUID = 1L; 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/CustomChatMessage.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class CustomChatMessage { 9 | 10 | private String content; 11 | 12 | private String sessionId; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/Knowledge.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | 10 | import com.fasterxml.jackson.annotation.JsonFormat; 11 | import lombok.Data; 12 | 13 | /** 14 | * 知识库 15 | * @TableName knowledge 16 | */ 17 | @TableName(value ="knowledge") 18 | @Data 19 | public class Knowledge implements Serializable { 20 | /** 21 | * 22 | */ 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | /** 27 | * 知识库ID 28 | */ 29 | @TableField(value = "kid") 30 | private String kid; 31 | 32 | /** 33 | * 用户ID 34 | */ 35 | @TableField(value = "uid") 36 | private Integer uid; 37 | 38 | /** 39 | * 知识库名称 40 | */ 41 | @TableField(value = "kname") 42 | private String kname; 43 | 44 | /** 45 | * 描述 46 | */ 47 | @TableField(value = "description") 48 | private String description; 49 | 50 | /** 51 | * 52 | */ 53 | @TableField(value = "create_time") 54 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 55 | private LocalDateTime createTime; 56 | 57 | /** 58 | * 59 | */ 60 | @TableField(value = "create_by") 61 | private String createBy; 62 | 63 | @TableField(exist = false) 64 | private static final long serialVersionUID = 1L; 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/KnowledgeShare.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import lombok.Data; 9 | 10 | /** 11 | * 知识库分享表 12 | * @TableName knowledge_share 13 | */ 14 | @TableName(value ="knowledge_share") 15 | @Data 16 | public class KnowledgeShare implements Serializable { 17 | /** 18 | * 19 | */ 20 | @TableId(value = "id", type = IdType.AUTO) 21 | private Integer id; 22 | 23 | /** 24 | * 知识库ID 25 | */ 26 | @TableField(value = "kid") 27 | private String kid; 28 | 29 | /** 30 | * 用户ID 31 | */ 32 | @TableField(value = "uid") 33 | private Integer uid; 34 | 35 | /** 36 | * 知识库名称 37 | */ 38 | @TableField(value = "kname") 39 | private String kname; 40 | 41 | @TableField(exist = false) 42 | private static final long serialVersionUID = 1L; 43 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/SpecialNoun.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | import java.util.Date; 10 | 11 | import com.fasterxml.jackson.annotation.JsonFormat; 12 | import lombok.Data; 13 | 14 | /** 15 | * 专业名词 16 | * @TableName special_noun 17 | */ 18 | @TableName(value ="special_noun") 19 | @Data 20 | public class SpecialNoun implements Serializable { 21 | /** 22 | * 23 | */ 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | /** 28 | * 拼音 29 | */ 30 | @TableField(value = "pinyin") 31 | private String pinyin; 32 | 33 | /** 34 | * 名词内容 35 | */ 36 | @TableField(value = "content") 37 | private String content; 38 | 39 | /** 40 | * 排序字段 41 | */ 42 | @TableField(value = "sort") 43 | private Integer sort; 44 | 45 | /** 46 | * 47 | */ 48 | @TableField(value = "create_time") 49 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 50 | private LocalDateTime createTime; 51 | 52 | /** 53 | * 54 | */ 55 | @TableField(value = "create_by") 56 | private String createBy; 57 | 58 | @TableField(exist = false) 59 | private static final long serialVersionUID = 1L; 60 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | import java.util.Date; 10 | 11 | import com.fasterxml.jackson.annotation.JsonFormat; 12 | import lombok.Data; 13 | 14 | /** 15 | * 角色表 16 | * @TableName sys_role 17 | */ 18 | @TableName(value ="sys_role") 19 | @Data 20 | public class SysRole implements Serializable { 21 | /** 22 | * 主键 23 | */ 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | /** 28 | * 角色ID 29 | */ 30 | @TableField(value = "rid") 31 | private String rid; 32 | 33 | /** 34 | * 角色名 35 | */ 36 | @TableField(value = "role_name") 37 | private String roleName; 38 | 39 | /** 40 | * 角色描述 41 | */ 42 | @TableField(value = "description") 43 | private String description; 44 | 45 | /** 46 | * 创建时间 47 | */ 48 | @TableField(value = "create_time") 49 | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") 50 | private LocalDateTime createTime; 51 | 52 | /** 53 | * 创建人 54 | */ 55 | @TableField(value = "create_by") 56 | private String createBy; 57 | 58 | @TableField(exist = false) 59 | private static final long serialVersionUID = 1L; 60 | } -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/function/DatePeriod.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain.function; 2 | 3 | /** 4 | * 日期区间枚举 5 | */ 6 | public enum DatePeriod { 7 | THE_DAY_BEFORE_YESTERDAY("前天"), 8 | YESTERDAY("昨天"), 9 | TODAY("今天"), 10 | TOMORROW("明天"), 11 | THE_DAY_AFTER_TOMORROW("后天"), 12 | WITHIN_THE_NEXT_WEEK("未来一周"); 13 | 14 | private String message; 15 | 16 | DatePeriod(String message) { 17 | this.message = message; 18 | } 19 | 20 | public String getMessage() { 21 | return message; 22 | } 23 | 24 | public void setMessage(String message) { 25 | this.message = message; 26 | } 27 | 28 | public static String getValueByName(String name) { 29 | for (DatePeriod datePeriod : DatePeriod.values()) { 30 | if (datePeriod.name().equals(name)) { 31 | return datePeriod.getMessage(); 32 | } 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/domain/function/LocationWeather.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.domain.function; 2 | 3 | import com.fasterxml.jackson.annotation.JsonClassDescription; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyDescription; 6 | import lombok.Data; 7 | 8 | /** 9 | * 地区天气 10 | */ 11 | @Data 12 | @JsonClassDescription("weather of a location") 13 | public class LocationWeather { 14 | 15 | @JsonPropertyDescription("city, for example: 常州,苏州,上海") 16 | @JsonProperty(required = true) 17 | public String location; 18 | 19 | @JsonPropertyDescription("date period of weather") 20 | @JsonProperty(required = true) 21 | public DatePeriod datePeriod; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/AccessTokenMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.AccessToken; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【access_token(第三方接口访问token)】的数据库操作Mapper 10 | * @createDate 2023-11-06 20:33:39 11 | * @Entity com.hkh.ai.domain.AccessToken 12 | */ 13 | @Mapper 14 | public interface AccessTokenMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/AgentFieldMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.AgentField; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【agent_field(代理领域)】的数据库操作Mapper 10 | * @createDate 2023-09-23 20:40:24 11 | * @Entity com.hkh.ai.domain.AgentField 12 | */ 13 | @Mapper 14 | public interface AgentFieldMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/ChatRequestLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.ChatRequestLog; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【chat_request_log(对话请求日志)】的数据库操作Mapper 10 | * @createDate 2023-12-23 13:55:32 11 | * @Entity com.hkh.ai.domain.ChatRequestLog 12 | */ 13 | @Mapper 14 | public interface ChatRequestLogMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/ChatSessionMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.ChatSession; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【chat_session(用户会话)】的数据库操作Mapper 10 | * @createDate 2023-06-20 16:47:01 11 | * @Entity com.hkh.openai.domain.ChatSession 12 | */ 13 | @Mapper 14 | public interface ChatSessionMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/ConversationMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.Conversation; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【conversation(对话)】的数据库操作Mapper 10 | * @createDate 2023-06-20 16:58:23 11 | * @Entity com.hkh.openai.domain.Conversation 12 | */ 13 | @Mapper 14 | public interface ConversationMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/DemandMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.Demand; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【demand(需求)】的数据库操作Mapper 10 | * @createDate 2023-09-23 20:42:03 11 | * @Entity com.hkh.ai.domain.Demand 12 | */ 13 | @Mapper 14 | public interface DemandMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/DemandStepMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.DemandStep; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【demand_step(需求步骤)】的数据库操作Mapper 10 | * @createDate 2023-09-26 23:46:14 11 | * @Entity com.hkh.ai.domain.DemandStepFunObj 12 | */ 13 | @Mapper 14 | public interface DemandStepMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/KnowledgeAttachMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.KnowledgeAttach; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【knowledge_attach(知识库附件)】的数据库操作Mapper 10 | * @createDate 2023-06-20 21:01:41 11 | * @Entity com.hkh.openai.domain.KnowledgeAttach 12 | */ 13 | @Mapper 14 | public interface KnowledgeAttachMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/KnowledgeFragmentMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.KnowledgeFragment; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【knowledge_fragment(知识片段)】的数据库操作Mapper 10 | * @createDate 2023-12-14 16:43:31 11 | * @Entity com.hkh.ai.domain.KnowledgeFragment 12 | */ 13 | @Mapper 14 | public interface KnowledgeFragmentMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/KnowledgeMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.Knowledge; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【knowledge(知识库)】的数据库操作Mapper 10 | * @createDate 2023-06-20 21:01:33 11 | * @Entity com.hkh.openai.domain.Knowledge 12 | */ 13 | @Mapper 14 | public interface KnowledgeMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/KnowledgeShareMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.KnowledgeShare; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【knowledge_share(知识库分享表)】的数据库操作Mapper 10 | * @createDate 2023-08-21 11:31:38 11 | * @Entity com.hkh.ai.domain.KnowledgeShare 12 | */ 13 | @Mapper 14 | public interface KnowledgeShareMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/MediaFileMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.MediaFile; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【media_file(媒体文件)】的数据库操作Mapper 10 | * @createDate 2024-01-11 13:57:30 11 | * @Entity com.hkh.ai.domain.MediaFile 12 | */ 13 | @Mapper 14 | public interface MediaFileMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/SpecialNounMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.SpecialNoun; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【special_noun(特殊名词)】的数据库操作Mapper 10 | * @createDate 2024-01-25 08:50:26 11 | * @Entity com.hkh.ai.domain.SpecialNoun 12 | */ 13 | @Mapper 14 | public interface SpecialNounMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/SysModelMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.SysModel; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【sys_model(系统模型)】的数据库操作Mapper 10 | * @createDate 2023-08-17 08:28:46 11 | * @Entity com.hkh.ai.domain.SysModel 12 | */ 13 | @Mapper 14 | public interface SysModelMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/SysRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.SysRole; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【sys_role(角色表)】的数据库操作Mapper 10 | * @createDate 2024-03-20 14:40:39 11 | * @Entity com.hkh.ai.domain.SysRole 12 | */ 13 | @Mapper 14 | public interface SysRoleMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.mapper; 2 | 3 | import com.hkh.ai.domain.SysUser; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【sys_user(用户表)】的数据库操作Mapper 10 | * @createDate 2023-06-07 14:40:30 11 | * @Entity com.hkh.openai.domain.SysUser 12 | */ 13 | @Mapper 14 | public interface SysUserMapper extends BaseMapper { 15 | 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/AgentDemandProposeRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AgentDemandProposeRequest { 7 | /** 8 | * 所属领域ID 9 | */ 10 | private String fid; 11 | 12 | /** 13 | * 内容 14 | */ 15 | private String content; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/AudioChatRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AudioChatRequest { 7 | 8 | private String sessionId; 9 | private String mediaId; 10 | private String content; 11 | private String kid; 12 | private String sid; 13 | private Boolean useLk; 14 | private Boolean useHistory; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/AudioTranscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AudioTranscribeRequest { 7 | 8 | private String mediaId; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/AuthLoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AuthLoginRequest { 7 | 8 | private String username; 9 | 10 | private String password; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/ChatSessionRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ChatSessionRemoveRequest { 7 | 8 | private String sid; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/ChatSessionSaveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ChatSessionSaveRequest { 7 | 8 | private String title; 9 | 10 | private Integer modelId; 11 | 12 | private String sid; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/ChatSessionUseKnowledgeRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ChatSessionUseKnowledgeRequest { 7 | 8 | private Boolean useKnowledge; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionClassicRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionClassicRequest { 7 | 8 | private String content; 9 | 10 | private String categoryList; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionFunctionRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionFunctionRequest { 7 | 8 | private String content; 9 | 10 | private String functionName; 11 | 12 | private String description; 13 | 14 | private Class clazz; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionFunctionWeatherRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionFunctionWeatherRequest { 7 | 8 | private String content; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionKeywordRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionKeywordRequest { 7 | 8 | private String content; 9 | 10 | private String keywordArea; 11 | 12 | private Integer keywordNum = 3; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionSecurityRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionSecurityRequest { 7 | 8 | private String content; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionSummaryRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionSummaryRequest { 7 | 8 | private String content; 9 | 10 | private String prompt; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/CompletionTranslateRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CompletionTranslateRequest { 7 | 8 | private String content; 9 | 10 | private String targetLanguage; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/ImageChatRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class ImageChatRequest { 9 | 10 | private String sessionId; 11 | private List mediaIds; 12 | private String content; 13 | private String kid; 14 | private String sid; 15 | private Boolean useLk; 16 | private Boolean useHistory; 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeAttachPageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import com.hkh.ai.common.PageRequest; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.Data; 6 | 7 | @Schema(title = "知识库附件分页查询参数",description="知识库附件分页查询参数") 8 | @Data 9 | public class KnowledgeAttachPageRequest extends PageRequest { 10 | 11 | @Schema(title = "知识库kid",description = "知识库kid",requiredMode = Schema.RequiredMode.REQUIRED) 12 | private String kid = ""; 13 | 14 | @Schema(title = "知识库名称",description = "知识库名称",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 15 | private String kname = ""; 16 | 17 | @Schema(title = "搜索内容",description = "搜索内容",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 18 | private String searchContent = ""; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeAttachRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class KnowledgeAttachRemoveRequest { 7 | 8 | private String kid; 9 | private String docId; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeDetailRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class KnowledgeDetailRequest { 8 | 9 | private String kid; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeFragmentPageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import com.hkh.ai.common.PageRequest; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.Data; 6 | 7 | @Schema(title = "知识片段分页查询参数",description="知识库片段分页查询参数") 8 | @Data 9 | public class KnowledgeFragmentPageRequest extends PageRequest { 10 | 11 | @Schema(title = "知识库kid",description = "知识库kid",requiredMode = Schema.RequiredMode.REQUIRED) 12 | private String kid = ""; 13 | 14 | @Schema(title = "知识库名称",description = "知识库名称",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 15 | private String kname = ""; 16 | 17 | @Schema(title = "附件docId",description = "附件docId",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 18 | private String docId = ""; 19 | 20 | @Schema(title = "附件名称",description = "附件名称",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 21 | private String docName = ""; 22 | 23 | @Schema(title = "搜索内容",description = "搜索内容",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 24 | private String searchContent = ""; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeFragmentRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class KnowledgeFragmentRemoveRequest { 7 | 8 | private String kid; 9 | private String fid; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeFragmentSaveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class KnowledgeFragmentSaveRequest { 7 | 8 | private String kid; 9 | private String content; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgePageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import com.hkh.ai.common.PageRequest; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.Data; 6 | 7 | @Schema(title = "知识库分页查询参数",description="知识库分页查询参数") 8 | @Data 9 | public class KnowledgePageRequest extends PageRequest { 10 | 11 | @Schema(title = "搜索内容",description = "搜索内容",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 12 | private String searchContent = ""; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class KnowledgeRemoveRequest { 7 | 8 | private String kid; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeSaveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class KnowledgeSaveRequest { 8 | 9 | private Integer id; 10 | 11 | private String kid; 12 | 13 | private Integer uid; 14 | 15 | private String kname; 16 | 17 | private String description; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeUploadExampleRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class KnowledgeUploadExampleRequest { 8 | 9 | private String kid; 10 | 11 | private MultipartFile file; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/KnowledgeUploadRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class KnowledgeUploadRequest { 8 | 9 | private String kid; 10 | 11 | private MultipartFile file; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/MediaFileBase64UploadRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class MediaFileBase64UploadRequest { 8 | 9 | private String base64Image; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/MediaFileUploadRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | @Data 7 | public class MediaFileUploadRequest { 8 | 9 | private MultipartFile file; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/RolePageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import com.hkh.ai.common.PageRequest; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.Data; 6 | 7 | @Schema(title = "角色分页查询参数",description="角色分页查询参数") 8 | @Data 9 | public class RolePageRequest extends PageRequest { 10 | 11 | @Schema(title = "搜索内容",description = "搜索内容",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 12 | private String searchContent = ""; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/SpecialNounPageRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import com.hkh.ai.common.PageRequest; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.Data; 6 | 7 | @Schema(title = "专有名词分页查询参数",description="专有名词分页查询参数") 8 | @Data 9 | public class SpecialNounPageRequest extends PageRequest { 10 | 11 | @Schema(title = "搜索内容",description = "搜索内容",requiredMode = Schema.RequiredMode.NOT_REQUIRED) 12 | private String searchContent = ""; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/SpecialNounRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SpecialNounRemoveRequest { 7 | 8 | private Integer id; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/SpecialNounSaveRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SpecialNounSaveRequest { 7 | 8 | private Integer id; 9 | 10 | private String pinyin; 11 | 12 | private String content; 13 | 14 | private Integer sort; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/request/VisionChatRequest.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.request; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class VisionChatRequest { 9 | 10 | private String sessionId; 11 | private List mediaIds; 12 | private String content; 13 | private String kid; 14 | private String sid; 15 | private Boolean useLk; 16 | private Boolean useHistory; 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/response/AudioChatResponse.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.response; 2 | 3 | import com.hkh.ai.domain.KnowledgeAttach; 4 | import com.hkh.ai.domain.MediaFile; 5 | import lombok.Data; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | @Data 11 | public class AudioChatResponse { 12 | 13 | 14 | /** 15 | * 文本内容 16 | */ 17 | private String content; 18 | 19 | /** 20 | * 媒体文件 21 | */ 22 | private MediaFile mediaFile; 23 | 24 | /** 25 | * 相似片段列表 26 | */ 27 | private List nearestList; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/response/CreateImageChatResponse.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.response; 2 | 3 | import com.hkh.ai.domain.MediaFile; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class CreateImageChatResponse { 10 | 11 | private String textMsg; 12 | 13 | private List mediaFileList; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/response/KnowledgeDetailResponse.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.response; 2 | 3 | import com.hkh.ai.domain.KnowledgeAttach; 4 | import lombok.Data; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Data 10 | public class KnowledgeDetailResponse { 11 | 12 | private Integer id; 13 | 14 | /** 15 | * 知识库ID 16 | */ 17 | private String kid; 18 | 19 | /** 20 | * 知识库名称 21 | */ 22 | private String kname; 23 | 24 | /** 25 | * 26 | */ 27 | private List attachList = new ArrayList<>(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/response/KnowledgeListResponse.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.response; 2 | 3 | import com.hkh.ai.domain.KnowledgeAttach; 4 | import lombok.Data; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Data 10 | public class KnowledgeListResponse { 11 | 12 | private Integer id; 13 | 14 | /** 15 | * 知识库ID 16 | */ 17 | private String kid; 18 | 19 | /** 20 | * 知识库名称 21 | */ 22 | private String kname; 23 | 24 | 25 | /** 26 | * 角色 27 | */ 28 | private String role; 29 | 30 | /** 31 | * 附件列表 32 | */ 33 | private List attachList = new ArrayList<>(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/AccessTokenService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.AccessToken; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【access_token(第三方接口访问token)】的数据库操作Service 9 | * @createDate 2023-11-06 20:33:39 10 | */ 11 | public interface AccessTokenService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/AgentFieldService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.AgentField; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【agent_field(代理领域)】的数据库操作Service 9 | * @createDate 2023-09-23 20:40:24 10 | */ 11 | public interface AgentFieldService extends IService { 12 | 13 | AgentField getByFid(String fid); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/ChatRequestLogService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.ChatRequestLog; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【chat_request_log(对话请求日志)】的数据库操作Service 9 | * @createDate 2023-12-23 13:55:32 10 | */ 11 | public interface ChatRequestLogService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/ChatSessionService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.ChatSession; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.hkh.ai.domain.SysUser; 6 | import com.hkh.ai.request.ChatSessionSaveRequest; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author huangkh 12 | * @description 针对表【chat_session(用户会话)】的数据库操作Service 13 | * @createDate 2023-06-20 16:47:01 14 | */ 15 | public interface ChatSessionService extends IService { 16 | 17 | void saveChatSession(ChatSessionSaveRequest request, SysUser sysUser); 18 | 19 | List listByUserId(Integer id); 20 | 21 | void removeBySid(String sid, SysUser sysUser); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/CompletionService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.agent.prompt.demand.functionObj.DemandFuncObj; 4 | import com.hkh.ai.chain.llm.capabilities.generation.function.ChatFunctionObject; 5 | import com.hkh.ai.domain.SysUser; 6 | import com.hkh.ai.request.*; 7 | 8 | import java.util.List; 9 | 10 | public interface CompletionService { 11 | String summary(SysUser sysUser, CompletionSummaryRequest request); 12 | 13 | String keyword(SysUser sysUser, CompletionKeywordRequest request); 14 | 15 | String translate(SysUser sysUser, CompletionTranslateRequest request); 16 | 17 | String classic(SysUser sysUser, CompletionClassicRequest request); 18 | 19 | String security(SysUser sysUser, CompletionSecurityRequest request); 20 | 21 | String function(SysUser sysUser, String content, List functionObjectList); 22 | 23 | String functionWeather(SysUser sysUser, CompletionFunctionWeatherRequest request); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/ConversationService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.Conversation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author huangkh 10 | * @description 针对表【conversation(对话)】的数据库操作Service 11 | * @createDate 2023-06-20 16:58:23 12 | */ 13 | public interface ConversationService extends IService { 14 | 15 | int saveConversation(Integer userId, String sessionId, String content, String qa); 16 | 17 | List listBySessionId(String sessionId); 18 | 19 | void removeBySid(String sid); 20 | 21 | List history(String sid); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/DemandService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.agent.prompt.demand.functionObj.DemandRoleFuncObj; 4 | import com.hkh.ai.agent.prompt.demand.functionObj.DemandStepFunObj; 5 | import com.hkh.ai.domain.AgentField; 6 | import com.hkh.ai.domain.Demand; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | import com.hkh.ai.domain.SysUser; 9 | import com.hkh.ai.request.AgentDemandProposeRequest; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author huangkh 15 | * @description 针对表【demand(需求)】的数据库操作Service 16 | * @createDate 2023-09-23 20:42:03 17 | */ 18 | public interface DemandService extends IService { 19 | 20 | void propose(SysUser sysUser, AgentDemandProposeRequest request); 21 | 22 | Demand saveDemand(SysUser sysUser, String did, String fid, String content); 23 | 24 | void stepRole(SysUser sysUser, AgentField agentField, Demand demand, List roles, List steps); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/DemandStepService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.DemandStep; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【demand_step(需求步骤)】的数据库操作Service 9 | * @createDate 2023-09-26 23:46:14 10 | */ 11 | public interface DemandStepService extends IService { 12 | 13 | DemandStep saveDemandStep(String did, String fid, String stepName, String description, String roleName, Integer userId); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/EmbeddingService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import java.util.List; 4 | 5 | public interface EmbeddingService { 6 | 7 | void storeEmbeddings(List chunkList, String kid, String docId,List fidList); 8 | 9 | void removeByDocId(String kid,String docId); 10 | 11 | void removeByKid(String kid); 12 | 13 | List getQueryVector(String query); 14 | 15 | void createSchema(String kid); 16 | 17 | void removeByKidAndFid(String kid, String fid); 18 | 19 | void saveFragment(String kid, String docId, String fid, String content); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/KnowledgeAttachService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.domain.KnowledgeAttach; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.hkh.ai.request.KnowledgeAttachPageRequest; 7 | 8 | /** 9 | * @author huangkh 10 | * @description 针对表【knowledge_attach(知识库附件)】的数据库操作Service 11 | * @createDate 2023-06-20 21:01:41 12 | */ 13 | public interface KnowledgeAttachService extends IService { 14 | 15 | PageInfo pageInfo(KnowledgeAttachPageRequest knowledgeAttachPageRequest); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/KnowledgeFragmentService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.domain.KnowledgeFragment; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.hkh.ai.request.KnowledgeFragmentPageRequest; 7 | import com.hkh.ai.request.KnowledgeFragmentRemoveRequest; 8 | import com.hkh.ai.request.KnowledgeFragmentSaveRequest; 9 | 10 | /** 11 | * @author huangkh 12 | * @description 针对表【knowledge_fragment(知识片段)】的数据库操作Service 13 | * @createDate 2023-12-14 16:43:31 14 | */ 15 | public interface KnowledgeFragmentService extends IService { 16 | 17 | PageInfo pageInfo(KnowledgeFragmentPageRequest knowledgeFragmentPageRequest); 18 | 19 | void removeFragment(KnowledgeFragmentRemoveRequest request); 20 | 21 | void saveFragment(KnowledgeFragmentSaveRequest request); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/KnowledgeService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.domain.Knowledge; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.hkh.ai.domain.KnowledgeShare; 7 | import com.hkh.ai.domain.SysUser; 8 | import com.hkh.ai.request.*; 9 | import com.hkh.ai.response.KnowledgeDetailResponse; 10 | import com.hkh.ai.response.KnowledgeListResponse; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | /** 17 | * @author huangkh 18 | * @description 针对表【knowledge(知识库)】的数据库操作Service 19 | * @createDate 2023-06-20 21:01:33 20 | */ 21 | public interface KnowledgeService extends IService { 22 | 23 | void saveOne(KnowledgeSaveRequest request, SysUser sysUser); 24 | 25 | void upload(KnowledgeUploadRequest request); 26 | 27 | void storeContent(MultipartFile file, String kid) throws IOException; 28 | 29 | KnowledgeDetailResponse detail(String kid); 30 | 31 | void removeAttach(KnowledgeAttachRemoveRequest request); 32 | 33 | void removeKnowledge(KnowledgeRemoveRequest request); 34 | 35 | List all(List mineList, List shareList); 36 | 37 | PageInfo pageInfo(KnowledgePageRequest knowledgePageRequest); 38 | 39 | Knowledge getOneByKid(String kid); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/KnowledgeShareService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.KnowledgeShare; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【knowledge_share(知识库分享表)】的数据库操作Service 9 | * @createDate 2023-08-21 11:31:38 10 | */ 11 | public interface KnowledgeShareService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/MediaFileService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.MediaFile; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.hkh.ai.request.MediaFileBase64UploadRequest; 6 | import com.hkh.ai.request.MediaFileUploadRequest; 7 | 8 | import java.io.InputStream; 9 | import java.util.List; 10 | 11 | /** 12 | * @author huangkh 13 | * @description 针对表【media_file(媒体文件)】的数据库操作Service 14 | * @createDate 2024-01-11 13:57:30 15 | */ 16 | public interface MediaFileService extends IService { 17 | 18 | MediaFile upload(MediaFileUploadRequest request); 19 | 20 | MediaFile getByMfid(String mediaId); 21 | 22 | MediaFile saveFile(InputStream speech, int cid); 23 | 24 | MediaFile base64Upload(MediaFileBase64UploadRequest request); 25 | 26 | List listByMfids(List mediaIds); 27 | 28 | void updateWithCid(List mediaIds, int questionCid); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/SpecialNounService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.domain.SpecialNoun; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.hkh.ai.domain.SysUser; 7 | import com.hkh.ai.request.SpecialNounPageRequest; 8 | import com.hkh.ai.request.SpecialNounSaveRequest; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author huangkh 14 | * @description 针对表【special_noun(特殊名词)】的数据库操作Service 15 | * @createDate 2024-01-25 08:50:26 16 | */ 17 | public interface SpecialNounService extends IService { 18 | 19 | void saveOne(SpecialNounSaveRequest requestBody, SysUser sysUser); 20 | 21 | PageInfo pageInfo(SpecialNounPageRequest specialNounPageRequest); 22 | 23 | List listOrderBySort(); 24 | 25 | String match(String text); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/SysModelService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.SysModel; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author huangkh 8 | * @description 针对表【sys_model(系统模型)】的数据库操作Service 9 | * @createDate 2023-08-17 08:28:46 10 | */ 11 | public interface SysModelService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/SysRoleService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hkh.ai.domain.SysRole; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.hkh.ai.request.RolePageRequest; 7 | 8 | /** 9 | * @author huangkh 10 | * @description 针对表【sys_role(角色表)】的数据库操作Service 11 | * @createDate 2024-03-20 14:40:39 12 | */ 13 | public interface SysRoleService extends IService { 14 | 15 | PageInfo pageInfo(RolePageRequest request); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service; 2 | 3 | import com.hkh.ai.domain.SysUser; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import jakarta.servlet.http.HttpServletRequest; 6 | 7 | /** 8 | * @author huangkh 9 | * @description 针对表【sys_user(用户表)】的数据库操作Service 10 | * @createDate 2023-06-07 14:40:30 11 | */ 12 | public interface SysUserService extends IService { 13 | 14 | Boolean loginCheck(HttpServletRequest httpServletRequest, String username, String password); 15 | 16 | SysUser getByUsernameAndPassowrd(String username, String password); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/AccessTokenServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.hkh.ai.domain.AccessToken; 5 | import com.hkh.ai.service.AccessTokenService; 6 | import com.hkh.ai.mapper.AccessTokenMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author huangkh 11 | * @description 针对表【access_token(第三方接口访问token)】的数据库操作Service实现 12 | * @createDate 2023-11-06 20:33:39 13 | */ 14 | @Service 15 | public class AccessTokenServiceImpl extends ServiceImpl 16 | implements AccessTokenService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/AgentFieldServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.hkh.ai.domain.AgentField; 6 | import com.hkh.ai.service.AgentFieldService; 7 | import com.hkh.ai.mapper.AgentFieldMapper; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @author huangkh 12 | * @description 针对表【agent_field(代理领域)】的数据库操作Service实现 13 | * @createDate 2023-09-23 20:40:24 14 | */ 15 | @Service 16 | public class AgentFieldServiceImpl extends ServiceImpl 17 | implements AgentFieldService{ 18 | 19 | @Override 20 | public AgentField getByFid(String fid) { 21 | QueryWrapper queryWrapper = new QueryWrapper<>(); 22 | queryWrapper.eq("fid",fid); 23 | AgentField agentField = this.getOne(queryWrapper,false); 24 | return agentField; 25 | } 26 | } 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/ChatRequestLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.hkh.ai.domain.ChatRequestLog; 5 | import com.hkh.ai.service.ChatRequestLogService; 6 | import com.hkh.ai.mapper.ChatRequestLogMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author huangkh 11 | * @description 针对表【chat_request_log(对话请求日志)】的数据库操作Service实现 12 | * @createDate 2023-12-23 13:55:32 13 | */ 14 | @Service 15 | public class ChatRequestLogServiceImpl extends ServiceImpl 16 | implements ChatRequestLogService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/DemandStepServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.hkh.ai.domain.DemandStep; 5 | import com.hkh.ai.service.DemandStepService; 6 | import com.hkh.ai.mapper.DemandStepMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author huangkh 13 | * @description 针对表【demand_step(需求步骤)】的数据库操作Service实现 14 | * @createDate 2023-09-26 23:46:14 15 | */ 16 | @Service 17 | public class DemandStepServiceImpl extends ServiceImpl 18 | implements DemandStepService{ 19 | 20 | @Override 21 | public DemandStep saveDemandStep(String did, String fid, String stepName, String description, String roleName, Integer userId) { 22 | DemandStep demandStep = new DemandStep(); 23 | demandStep.setDid(did); 24 | demandStep.setFid(fid); 25 | demandStep.setStepName(stepName); 26 | demandStep.setDescription(description); 27 | demandStep.setRole(roleName); 28 | demandStep.setUserId(userId); 29 | demandStep.setCreateTime(new Date()); 30 | this.save(demandStep); 31 | return demandStep; 32 | } 33 | } 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/KnowledgeShareServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.hkh.ai.domain.KnowledgeShare; 5 | import com.hkh.ai.service.KnowledgeShareService; 6 | import com.hkh.ai.mapper.KnowledgeShareMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author huangkh 11 | * @description 针对表【knowledge_share(知识库分享表)】的数据库操作Service实现 12 | * @createDate 2023-08-21 11:31:38 13 | */ 14 | @Service 15 | public class KnowledgeShareServiceImpl extends ServiceImpl 16 | implements KnowledgeShareService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/SysModelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.hkh.ai.domain.SysModel; 5 | import com.hkh.ai.service.SysModelService; 6 | import com.hkh.ai.mapper.SysModelMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author huangkh 11 | * @description 针对表【sys_model(系统模型)】的数据库操作Service实现 12 | * @createDate 2023-08-17 08:28:46 13 | */ 14 | @Service 15 | public class SysModelServiceImpl extends ServiceImpl 16 | implements SysModelService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/service/impl/SysRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.github.pagehelper.PageHelper; 6 | import com.github.pagehelper.PageInfo; 7 | import com.hkh.ai.domain.SysRole; 8 | import com.hkh.ai.mapper.SysRoleMapper; 9 | import com.hkh.ai.request.RolePageRequest; 10 | import com.hkh.ai.service.SysRoleService; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | * @author huangkh 15 | * @description 针对表【sys_role(角色表)】的数据库操作Service实现 16 | * @createDate 2024-03-20 14:40:39 17 | */ 18 | @Service 19 | public class SysRoleServiceImpl extends ServiceImpl 20 | implements SysRoleService{ 21 | 22 | @Override 23 | public PageInfo pageInfo(RolePageRequest request) { 24 | QueryWrapper queryWrapper = new QueryWrapper<>(); 25 | queryWrapper.like("role_name",request.getSearchContent()); 26 | PageHelper.startPage(request.getPageNum(), request.getPageSize()); 27 | PageInfo pageInfo = new PageInfo<>(list(queryWrapper)); 28 | return pageInfo; 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/com/hkh/ai/util/FunctionReflect.java: -------------------------------------------------------------------------------- 1 | package com.hkh.ai.util; 2 | 3 | import cn.hutool.core.util.ReflectUtil; 4 | import com.alibaba.fastjson2.JSONObject; 5 | import com.hkh.ai.chain.callback.FunctionCaller; 6 | import lombok.extern.slf4j.Slf4j; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | 11 | @Slf4j 12 | public class FunctionReflect { 13 | 14 | public static Object reflect(String methodName, JSONObject jsonNode){ 15 | FunctionCaller functionCaller = new FunctionCaller(); 16 | Method method = ReflectUtil.getMethod(FunctionCaller.class, methodName, new Class[]{JSONObject.class}); 17 | try { 18 | Object invoke = method.invoke(functionCaller, jsonNode); 19 | return invoke; 20 | } catch (IllegalAccessException e) { 21 | log.error("FunctionReflect reflect occur illegal access exception,method name = {},jsonNode = {}",methodName,jsonNode,e); 22 | throw new RuntimeException(e); 23 | } catch (InvocationTargetException e) { 24 | log.error("FunctionReflect reflect occur invocation target exception,method name = {},jsonNode = {}",methodName,jsonNode,e); 25 | throw new RuntimeException(e); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | openai.token=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 | proxy.http.baseurl=http://192.168.1.100:8080/ 3 | 4 | baidu.appKey=xxxxxxxxxxxxxxxxx 5 | baidu.secretKey=xxxxxxxxxxxxxxxxxxxxxxxxx 6 | 7 | google.ai.token=xxxxxxxxxxxxxxxxxxxxxx 8 | google.search.token=xxxxxxxxxxxxxxxxxxxxxx 9 | google.search.cx=xxxxxxxxxxxxxxxxxxxxxx 10 | 11 | zhipu.ai.token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 12 | kimi.ai.token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 13 | 14 | doubao.ai.token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 15 | claude.ai.token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 16 | 17 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/ai?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useUnicode=true&useSSL=false&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true 18 | spring.datasource.username=root 19 | spring.datasource.password=123 20 | spring.datasource.type=com.zaxxer.hikari.HikariDataSource 21 | spring.datasource.hikari.connection-init-sql=SET NAMES utf8mb4 COLLATE utf8mb4_general_ci 22 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 23 | 24 | upload.path=/data/upload 25 | resource.domain=http://192.168.40.229:${server.port}/resources -------------------------------------------------------------------------------- /src/main/resources/assets/functions_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_1.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_2.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_3.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_4.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_5.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_6.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_7.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_8.png -------------------------------------------------------------------------------- /src/main/resources/assets/functions_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/functions_9.png -------------------------------------------------------------------------------- /src/main/resources/assets/langchain+chatglm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/langchain+chatglm.png -------------------------------------------------------------------------------- /src/main/resources/assets/login_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/login_app.png -------------------------------------------------------------------------------- /src/main/resources/assets/stream-chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/stream-chat.png -------------------------------------------------------------------------------- /src/main/resources/assets/use_lk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/use_lk.png -------------------------------------------------------------------------------- /src/main/resources/assets/use_lk2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/use_lk2.png -------------------------------------------------------------------------------- /src/main/resources/assets/weixin_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/weixin_02.png -------------------------------------------------------------------------------- /src/main/resources/assets/weixin_qun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/assets/weixin_qun.png -------------------------------------------------------------------------------- /src/main/resources/init-scripts/vectorstores/pgvector/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | # Qdrant vector store. 3 | pgvector: 4 | image: pgvector/pgvector:pg16 5 | restart: always 6 | environment: 7 | PGUSER: postgres 8 | # The password for the default postgres user. 9 | POSTGRES_PASSWORD: pg123456 10 | # The name of the default postgres database. 11 | POSTGRES_DB: pg 12 | # postgres data directory 13 | PGDATA: /var/lib/postgresql/data/pgdata 14 | volumes: 15 | - ./volumes/pgvector/data:/var/lib/postgresql/data 16 | # uncomment to expose db(postgresql) port to host 17 | ports: 18 | - "5433:5432" 19 | healthcheck: 20 | test: [ "CMD", "pg_isready" ] 21 | interval: 1s 22 | timeout: 3s 23 | retries: 30 -------------------------------------------------------------------------------- /src/main/resources/init-scripts/vectorstores/weaviate/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | services: 3 | weaviate: 4 | image: semitechnologies/weaviate:1.19.7 5 | # restart: on-failure:0 6 | ports: 7 | - "8080:8080" 8 | environment: 9 | QUERY_DEFAULTS_LIMIT: 20 10 | AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' 11 | PERSISTENCE_DATA_PATH: "./data" 12 | DEFAULT_VECTORIZER_MODULE: text2vec-transformers 13 | ENABLE_MODULES: text2vec-transformers 14 | TRANSFORMERS_INFERENCE_API: http://t2v-transformers:8080 15 | CLUSTER_HOSTNAME: 'node1' 16 | t2v-transformers: 17 | image: semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1 18 | environment: 19 | ENABLE_CUDA: 0 # set to 1 to enable -------------------------------------------------------------------------------- /src/main/resources/mapper/AccessTokenMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id,app,token, 18 | expired_time,create_time,create_by 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/mapper/AgentFieldMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id,fid,field_name, 19 | description,status,create_time, 20 | create_by 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ChatRequestLogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id,user_id,kid, 19 | request_time,content,create_time, 20 | create_by 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ChatSessionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id,sid,title, 19 | model_id,user_id,create_time, 20 | create_by 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ConversationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,sid,type, 20 | user_id,qa_time,content, 21 | create_time,create_by 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/mapper/DemandMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,did,fid, 20 | content,user_id,unambiguous, 21 | create_time,create_by 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/mapper/DemandStepMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | id,did,fid, 21 | step_name,description,role, 22 | user_id,unambiguous,create_time, 23 | create_by 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/mapper/KnowledgeAttachMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,kid,doc_id, 20 | doc_name,doc_type,content, 21 | create_time,create_by 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/mapper/KnowledgeFragmentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,kid,doc_id, 20 | idx,fid,content,create_time, 21 | create_by 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/mapper/KnowledgeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id,kid,kname,description, 18 | create_time,create_by 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/mapper/KnowledgeShareMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | id,kid,uid, 16 | kname 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/resources/mapper/MediaFileMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | id,cid,mfid,media_type, 24 | file_suffix,file_name,file_size, 25 | file_time,file_path,http_url, 26 | create_time,create_by 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SpecialNounMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id,pinyin,content,sort, 18 | create_time,create_by 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysModelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | id,name,describe, 24 | local,avatar,free, 25 | std_rate,role_text,temperature, 26 | top_p,create_time,create_by 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id,rid,role_name, 18 | description,create_time,create_by 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/SqlMapperConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/css/vendor/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.0 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */nav[data-toggle=toc] .nav>li>a{display:block;padding:4px 20px;font-size:15px;font-weight:500;color:#767676}nav[data-toggle=toc] .nav>li>a:focus,nav[data-toggle=toc] .nav>li>a:hover{padding-left:19px;color:#563d7c;text-decoration:none;background-color:transparent;border-left:1px solid #563d7c}nav[data-toggle=toc] .nav-link.active,nav[data-toggle=toc] .nav-link.active:focus,nav[data-toggle=toc] .nav-link.active:hover{padding-left:18px;font-weight:700;color:#563d7c;background-color:transparent;border-left:2px solid #563d7c}nav[data-toggle=toc] .nav-link+ul{display:none;padding-bottom:10px}nav[data-toggle=toc] .nav .nav>li>a{padding-top:1px;padding-bottom:1px;padding-left:30px;font-size:14px;font-weight:400}nav[data-toggle=toc] .nav .nav>li>a:focus,nav[data-toggle=toc] .nav .nav>li>a:hover{padding-left:29px}nav[data-toggle=toc] .nav .nav>li>.active,nav[data-toggle=toc] .nav .nav>li>.active:focus,nav[data-toggle=toc] .nav .nav>li>.active:hover{padding-left:28px;font-weight:500}nav[data-toggle=toc] .nav-link.active+ul{display:block} -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/10.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/5.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/7.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/9.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/avatar.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/avatar2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/avatar2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog5.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog6.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog7.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog8.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/blog9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/blog9.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/coffee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/coffee.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/dashb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/dashb.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/dashb2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/dashb2.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/screenshot.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/screenshot1.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/screenshot2.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/screenshot3.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/screenshot4.png -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/slide1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/slide1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/slide2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/slide2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/demo/slide3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/demo/slide3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/anchor/assets/img/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/img/shape.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/resources/static/anchor/assets/js/functions.js: -------------------------------------------------------------------------------- 1 | jQuery( document ).ready(function() { 2 | 3 | $(window).scroll(function(){ 4 | $('.topnav').toggleClass('bg-white navbar-light shadow-sm scrollednav py-0', $(this).scrollTop() > 50); 5 | }); 6 | 7 | $('#modal_newsletter').on('show.bs.modal', function () { 8 | $('.downloadzip')[0].click(); 9 | }); 10 | 11 | }); 12 | -------------------------------------------------------------------------------- /src/main/resources/static/css/agent.css: -------------------------------------------------------------------------------- 1 | .agentResult{ 2 | margin-top: 20px; 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | justify-content: flex-start; 7 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/classic.css: -------------------------------------------------------------------------------- 1 | .classicResult{ 2 | margin-top: 20px; 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | justify-content: flex-start; 7 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/common/topbar.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | overflow: hidden; 4 | } 5 | 6 | #topbar-content{ 7 | width: 100%; 8 | height: 64px; 9 | background-color: steelblue; 10 | display: flex; 11 | flex-direction: row; 12 | flex-wrap: nowrap; 13 | align-content: center; 14 | justify-content: flex-start; 15 | } 16 | 17 | #topbar-content .topbar-left{ 18 | width: 15%; 19 | } 20 | 21 | #topbar-content .topbar-mid{ 22 | width: 70%; 23 | } 24 | 25 | #topbar-content .topbar-right{ 26 | font-size: 20px; 27 | color: #FFFFFF; 28 | width: 15%; 29 | display: flex; 30 | flex-direction: row; 31 | flex-wrap: nowrap; 32 | align-content: center; 33 | justify-content: flex-end; 34 | align-items: center; 35 | padding: 24px; 36 | } 37 | 38 | #topbar-content .topbar-right a{ 39 | color: #fff; 40 | margin-left: 10px; 41 | } 42 | 43 | @media screen and (max-width: 980px){ 44 | #topbar-content .topbar-left{ 45 | width: 20%; 46 | } 47 | 48 | #topbar-content .topbar-mid{ 49 | width: 40%; 50 | } 51 | 52 | #topbar-content .topbar-right{ 53 | width: 40%; 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/function.css: -------------------------------------------------------------------------------- 1 | .functionResult{ 2 | margin-top: 20px; 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | justify-content: flex-start; 7 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/index.css: -------------------------------------------------------------------------------- 1 | /*html, body {*/ 2 | /* height: 100%;*/ 3 | /*}*/ 4 | 5 | /*#main-content{*/ 6 | /* !*height: calc(100% - 64px);*!*/ 7 | /* display: flex;*/ 8 | /* flex-direction: column;*/ 9 | /* flex-wrap: wrap;*/ 10 | /* align-content: center;*/ 11 | /* justify-content: flex-start;*/ 12 | /* align-items: center;*/ 13 | /*}*/ 14 | 15 | /*#main-content a{*/ 16 | /* font-size: 24px;*/ 17 | /* margin-top: 36px;*/ 18 | /*}*/ 19 | 20 | @media screen and (max-width: 980px){ 21 | .bigCard { 22 | margin-bottom: 25px; 23 | } 24 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/keyword.css: -------------------------------------------------------------------------------- 1 | .keywordResult{ 2 | margin-top: 20px; 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | justify-content: flex-start; 7 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/knowledge/attach.css: -------------------------------------------------------------------------------- 1 | .attach-container { 2 | position: fixed; 3 | width: 100%; 4 | height: 100%; 5 | left: 0px; 6 | top: 0px; 7 | background-color: #3338; 8 | z-index: 9999; 9 | } 10 | 11 | .h{ 12 | display: none; 13 | } 14 | 15 | .attach-edit-form{ 16 | width: 50%; 17 | height: 50%; 18 | margin: 10% auto; 19 | background-color: white; 20 | padding: 2%; 21 | } 22 | 23 | .col-flex-right{ 24 | display: flex; 25 | flex-direction: row; 26 | justify-content: end; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/static/css/knowledge/fragment.css: -------------------------------------------------------------------------------- 1 | .fragment-container { 2 | position: fixed; 3 | width: 100%; 4 | height: 100%; 5 | left: 0px; 6 | top: 0px; 7 | background-color: #3338; 8 | z-index: 9999; 9 | } 10 | 11 | .h{ 12 | display: none; 13 | } 14 | 15 | .fragment-edit-form{ 16 | width: 50%; 17 | height: 50%; 18 | margin: 10% auto; 19 | background-color: white; 20 | padding: 2%; 21 | } 22 | 23 | .col-flex-right{ 24 | display: flex; 25 | flex-direction: row; 26 | justify-content: end; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/static/css/knowledge/index.css: -------------------------------------------------------------------------------- 1 | .knowledge-container { 2 | position: fixed; 3 | width: 100%; 4 | height: 100%; 5 | left: 0px; 6 | top: 0px; 7 | background-color: #3338; 8 | z-index: 9999; 9 | } 10 | 11 | .h{ 12 | display: none; 13 | } 14 | 15 | .knowledge-edit-form{ 16 | width: 50%; 17 | height: 50%; 18 | margin: 10% auto; 19 | background-color: white; 20 | padding: 2%; 21 | } 22 | 23 | .col-flex-right{ 24 | display: flex; 25 | flex-direction: row; 26 | justify-content: end; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/static/css/register.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/css/register.css -------------------------------------------------------------------------------- /src/main/resources/static/css/security.css: -------------------------------------------------------------------------------- 1 | .securityResult{ 2 | margin-top: 20px; 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | justify-content: flex-start; 7 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/special/index.css: -------------------------------------------------------------------------------- 1 | .special-container { 2 | position: fixed; 3 | width: 100%; 4 | height: 100%; 5 | left: 0px; 6 | top: 0px; 7 | background-color: #3338; 8 | z-index: 9999; 9 | } 10 | 11 | .h{ 12 | display: none; 13 | } 14 | 15 | .special-edit-form{ 16 | width: 50%; 17 | height: 50%; 18 | margin: 10% auto; 19 | background-color: white; 20 | padding: 2%; 21 | } 22 | 23 | .col-flex-right{ 24 | display: flex; 25 | flex-direction: row; 26 | justify-content: end; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/static/css/summary.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | } 4 | 5 | #main-content{ 6 | height: calc(100% - 64px); 7 | display: flex; 8 | flex-direction: column; 9 | flex-wrap: wrap; 10 | align-content: center; 11 | justify-content: flex-start; 12 | align-items: center; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/static/css/translate.css: -------------------------------------------------------------------------------- 1 | .translateResult{ 2 | margin-top: 20px; 3 | font-size: 18px; 4 | } -------------------------------------------------------------------------------- /src/main/resources/static/fonts/XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHgKbaf2r4e_T5.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHgKbaf2r4e_T5.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHjabaf2r4ew.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/XRXK3I6Li01BKofIMPyPbj8d7IEAGXNi83AHjabaf2r4ew.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/XRXV3I6Li01BKofINeaBTMnFcQ.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/XRXV3I6Li01BKofINeaBTMnFcQ.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/XRXV3I6Li01BKofIO-aBTMnFcQIG.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/XRXV3I6Li01BKofIO-aBTMnFcQIG.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/XRXV3I6Li01BKofIOOaBTMnFcQIG.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/XRXV3I6Li01BKofIOOaBTMnFcQIG.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/fonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/img/illustration.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/img/illustration.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/illustration3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/img/illustration3.png -------------------------------------------------------------------------------- /src/main/resources/static/js/agent.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#agentContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#agentHelp").html(message); 8 | $("#agentResult").html(""); 9 | } 10 | 11 | function agentCheck(){ 12 | let content = $("#agentContent").val(); 13 | $("#agentBtn").attr("disabled","disabled"); 14 | $.post("/agent/demand/propose",{"content":content,"fid":'51-af7dnc8pmj2b1r9uccg529le2deil69jb3o0f2ho73l8o9h'},function (d) { 15 | console.log(d); 16 | $("#agentBtn").removeAttr("disabled"); 17 | if (d.code == '200'){ 18 | let data = d.data; 19 | $("#agentResult").html(data); 20 | } 21 | },"json"); 22 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/classic.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#classicContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#classicHelp").html(message); 8 | $("#classicResult").html(""); 9 | } 10 | 11 | function textClassic(){ 12 | let content = $("#classicContent").val(); 13 | let categoryList = $("#categoryList").val(); 14 | $("#classicBtn").attr("disabled","disabled"); 15 | $.post("/completion/classic",{"content":content,"categoryList":categoryList},function (d) { 16 | console.log(d); 17 | $("#classicBtn").removeAttr("disabled"); 18 | if (d.code == '200'){ 19 | let data = d.data; 20 | let categories = data.split(';'); 21 | let _html = ''; 22 | for (let i = 0; i < categories.length; i++) { 23 | _html += ''+ categories[i].trim() +''; 24 | } 25 | $("#classicResult").html(_html); 26 | } 27 | },"json"); 28 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/common/topbar.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/js/common/topbar.js -------------------------------------------------------------------------------- /src/main/resources/static/js/function.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#functionContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#functionHelp").html(message); 8 | $("#functionResult").html(""); 9 | } 10 | 11 | function functionCheck(){ 12 | let content = $("#functionContent").val(); 13 | $("#functionBtn").attr("disabled","disabled"); 14 | $.post("/completion/function/weather",{"content":content},function (d) { 15 | console.log(d); 16 | $("#functionBtn").removeAttr("disabled"); 17 | if (d.code == '200'){ 18 | let data = d.data; 19 | $("#functionResult").html(data); 20 | } 21 | },"json"); 22 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkh1012/langboot/03227e6b0216329d58e87ecf0de5edf649763cd1/src/main/resources/static/js/index.js -------------------------------------------------------------------------------- /src/main/resources/static/js/keyword.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#keywordContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#keywordHelp").html(message); 8 | $("#keywordResult").html(""); 9 | } 10 | 11 | function genKeywords(){ 12 | let content = $("#keywordContent").val(); 13 | let keywordArea = $("#keywordArea").val(); 14 | let keywordNum = $("#keywordNum").val(); 15 | console.log(keywordNum); 16 | if (!keywordNum){ 17 | keywordNum = 3; 18 | } 19 | $("#genKeywordsBtn").attr("disabled","disabled"); 20 | $.post("/completion/keyword",{"content":content,"keywordArea":keywordArea,"keywordNum":keywordNum},function (d) { 21 | console.log(d); 22 | $("#genKeywordsBtn").removeAttr("disabled"); 23 | if (d.code == '200'){ 24 | let data = d.data; 25 | let keywords = data.split(';'); 26 | let _html = ''; 27 | for (let i = 0; i < keywords.length; i++) { 28 | _html += ''+ keywords[i].trim() +''; 29 | } 30 | $("#keywordResult").html(_html); 31 | } 32 | },"json"); 33 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/login.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | 3 | }); -------------------------------------------------------------------------------- /src/main/resources/static/js/security.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#securityContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#securityHelp").html(message); 8 | $("#securityResult").html(""); 9 | } 10 | 11 | function securityCheck(){ 12 | let content = $("#securityContent").val(); 13 | $("#securityBtn").attr("disabled","disabled"); 14 | $.post("/completion/security",{"content":content},function (d) { 15 | console.log(d); 16 | $("#securityBtn").removeAttr("disabled"); 17 | if (d.code == '200'){ 18 | let data = d.data; 19 | let _html = ''; 20 | if (data.trim().indexOf("安全")>-1) { 21 | _html += ''+ '安全' +''; 22 | }else { 23 | _html += ''+ '危险' +''; 24 | } 25 | $("#securityResult").html(_html); 26 | } 27 | },"json"); 28 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/summary.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#summariedContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#summaryHelp").html(message); 8 | $("#summaryResult").html(""); 9 | } 10 | 11 | function genSummary(){ 12 | let content = $("#summariedContent").val(); 13 | let prompt = $("#prompt").val(); 14 | $("#genSummaryBtn").attr("disabled","disabled"); 15 | $.post("/completion/summary",{"content":content,"prompt":prompt},function (d) { 16 | console.log(d); 17 | $("#genSummaryBtn").removeAttr("disabled"); 18 | if (d.code == '200'){ 19 | $("#summaryResult").text(d.data); 20 | } 21 | },"json"); 22 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/translate.js: -------------------------------------------------------------------------------- 1 | function contentChange(){ 2 | let message = ''; 3 | let content = $("#translateContent").val(); 4 | let length = content ? content.length : 0; 5 | let max = 3000; 6 | message = '当前文本长度为' + length + ',剩余字数:' + (max - length); 7 | $("#translateHelp").html(message); 8 | $("#translateResult").html(""); 9 | } 10 | 11 | function beginTranslate(){ 12 | let content = $("#translateContent").val(); 13 | let targetLanguage = $("#targetLanguage").val(); 14 | $("#translateBtn").attr("disabled","disabled"); 15 | $.post("/completion/translate",{"content":content,"targetLanguage":targetLanguage},function (d) { 16 | console.log(d); 17 | $("#translateBtn").removeAttr("disabled"); 18 | if (d.code == '200'){ 19 | let data = d.data; 20 | $("#translateResult").html(data); 21 | } 22 | },"json"); 23 | } -------------------------------------------------------------------------------- /src/main/resources/templates/error/404.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 404 5 | 6 | 7 |
8 |

404

9 |
10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/templates/error/500.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 500 5 | 6 | 7 | 10 |
11 |

500

12 |
13 | 14 | --------------------------------------------------------------------------------