This commit is contained in:
parent
2b4836ba70
commit
3fd5370049
|
|
@ -2,10 +2,10 @@
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Debug ingest_semantic (as module)",
|
"name": "Debug rag_pipeline (as module)",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "src.ingest.ingest_semantic", // chạy theo module
|
"module": "src.chatbot.rag_pipeline", // chạy theo module
|
||||||
"cwd": "${workspaceFolder}", // thư mục gốc project
|
"cwd": "${workspaceFolder}", // thư mục gốc project
|
||||||
"envFile": "${workspaceFolder}/.env", // load biến môi trường
|
"envFile": "${workspaceFolder}/.env", // load biến môi trường
|
||||||
"env": { "PYTHONPATH": "${workspaceFolder}" }, // đảm bảo 'src' là package gốc
|
"env": { "PYTHONPATH": "${workspaceFolder}" }, // đảm bảo 'src' là package gốc
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -22,7 +22,13 @@ class RAGPipeline:
|
||||||
self.llm = LLMClient()
|
self.llm = LLMClient()
|
||||||
|
|
||||||
def run(self, user_query: str) -> str:
|
def run(self, user_query: str) -> str:
|
||||||
docs = self.retriever.retrieve(user_query)
|
docs = self.retriever.search(user_query)
|
||||||
prompt = self.prompt_builder.build(user_query, docs)
|
prompt = self.prompt_builder.build_prompt(user_query, docs)
|
||||||
answer = self.llm.generate(prompt)
|
answer = self.llm.generate(prompt)
|
||||||
return answer
|
return answer
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pipeline = RAGPipeline()
|
||||||
|
query = "Bạn biết Mahola là ai không?"
|
||||||
|
response = pipeline.run(query)
|
||||||
|
print("Câu hỏi:", query)
|
||||||
|
print("Trả lời:", response)
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Retriever: Tìm kiếm các đoạn văn bản liên quan trong Qdrant.
|
||||||
|
"""
|
||||||
|
|
||||||
from typing import List, Dict, Any
|
from typing import List, Dict, Any
|
||||||
from sentence_transformers import SentenceTransformer
|
from sentence_transformers import SentenceTransformer
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -46,6 +46,8 @@ load_dotenv()
|
||||||
# ==== Đường dẫn dữ liệu ====
|
# ==== Đường dẫn dữ liệu ====
|
||||||
# Thư mục chứa các file .txt nguồn
|
# Thư mục chứa các file .txt nguồn
|
||||||
DATA_RAW = Path(os.getenv("DATA_RAW", "./data/data_raw10k")).resolve()
|
DATA_RAW = Path(os.getenv("DATA_RAW", "./data/data_raw10k")).resolve()
|
||||||
|
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "")
|
||||||
|
GEMINI_MODEL = os.getenv("GEMINI_MODEL", "models/gemini-2.0-flash-001")
|
||||||
|
|
||||||
# ==== Embedding model (SentenceTransformers) ====
|
# ==== Embedding model (SentenceTransformers) ====
|
||||||
EMBED_MODEL = os.getenv("EMBED_MODEL", "Alibaba-NLP/gte-multilingual-base")
|
EMBED_MODEL = os.getenv("EMBED_MODEL", "Alibaba-NLP/gte-multilingual-base")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue