/* * Copyright 2024 KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ #ifndef SERVICES_ASSISTANT_FILE_INFERENCE_H #define SERVICES_ASSISTANT_FILE_INFERENCE_H #include #include #include #include "assistant/rag/ragserverproxy.h" #include "fileinferenceinterface.h" namespace assistant::session { struct DialogueSession; } class FileInference : public FileInferenceInterface { public: ~FileInference() override = default; std::future ragSearchText(const std::string& knowledgeBaseName, const std::string& text, bool useDefault) override; DialogueData::CallSuccessIdentifier fileContent(const std::string& knowledgeBaseName, const std::string& filePath) override; std::future createFileKnowledgeBase() override; void deleteFileKnowledgeBase(const std::string& knowledgeBaseName) override; DialogueData::FileSearchIdentifier updateFileKnowledgeBase(const std::string& knowledgeBaseName, const std::string& docFilePath) override; private: RagServerProxy::SimilaritySearchResults searchFileContent(const std::string& question, const std::string& knowledgeBaseName, RagErrorInfo& error); private: RagServerProxy& ragServerProxy_{RagServerProxy::instance()}; }; // 文本向量化接口 class TextVectorizationInference : public TextEmbeddingInterface { public: ~TextVectorizationInference() override = default; void initEmbeddingEngine( const std::shared_ptr& textEmbeddingEngine) { textEmbeddingEngine_ = textEmbeddingEngine; } // 实现文本向量化调用 DialogueCallback::TextEmbeddingResult textVectorization(const std::string& textStr); protected: std::shared_ptr textEmbeddingEngine_{nullptr}; }; #endif // SERVICES_ASSISTANT_FILE_INFERENCE_H