feat: build
This commit is contained in:
parent
0ad204747c
commit
8b27dda8ee
|
@ -2,26 +2,25 @@
|
||||||
|
|
||||||
from base_rag import BaseRAG
|
from base_rag import BaseRAG
|
||||||
|
|
||||||
|
|
||||||
class SimpleRAG(BaseRAG):
|
class SimpleRAG(BaseRAG):
|
||||||
def ingest(self, file_path: str):
|
def ingest(self, file_path: str):
|
||||||
documents = self.load_and_split_documents(file_path)
|
documents = self.load_and_split_documents(file_path)
|
||||||
self.add_documents_to_vector_store(documents)
|
self.add_documents_to_vector_store(documents)
|
||||||
print(f"导入 {len(documents)} 个文档")
|
print(f"导入 {len(documents)} 个文档")
|
||||||
|
|
||||||
def query(self, question: str) -> str:
|
def query(self, question: str) -> str:
|
||||||
docs = self.similarity_search(question)
|
docs = self.similarity_search(question)
|
||||||
return f"找到 {len(docs)} 个相关文档"
|
return f"找到 {len(docs)} 个相关文档"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# 本地模型配置
|
# 本地模型配置
|
||||||
config = {
|
config = {"type": "local", "model_name": "sentence-transformers/all-MiniLM-L6-v2"}
|
||||||
"type": "local",
|
|
||||||
"model_name": "sentence-transformers/all-MiniLM-L6-v2"
|
|
||||||
}
|
|
||||||
|
|
||||||
rag = SimpleRAG(embedding_config=config)
|
rag = SimpleRAG(embedding_config=config)
|
||||||
print("RAG初始化完成!")
|
print("RAG初始化完成!")
|
||||||
|
|
||||||
# rag.ingest("your_document.txt")
|
# rag.ingest("your_document.txt")
|
||||||
# result = rag.query("你的问题")
|
# result = rag.query("你的问题")
|
||||||
# print(result)
|
# print(result)
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
echo "检查并安装构建依赖..."
|
||||||
|
pip install --upgrade pip build twine
|
||||||
|
|
||||||
echo "清理..."
|
echo "清理..."
|
||||||
rm -rf build/ dist/ *.egg-info/
|
rm -rf build/ dist/ *.egg-info/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue