|
|
@ -1,17 +1,27 @@
|
|
|
|
# qa_operations.py
|
|
|
|
# qa_operations.py
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
from sentence_transformers import CrossEncoder
|
|
|
|
from sentence_transformers import CrossEncoder
|
|
|
|
from faiss_kb_service import FaissKBService
|
|
|
|
from faiss_kb_service import FaissKBService
|
|
|
|
from langchain.docstore.document import Document
|
|
|
|
from langchain.docstore.document import Document
|
|
|
|
from base_kb import KnowledgeFile
|
|
|
|
from base_kb import KnowledgeFile
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Read the configuration file
|
|
|
|
|
|
|
|
with open('config/config.yaml', 'r') as config_file:
|
|
|
|
|
|
|
|
config = yaml.safe_load(config_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Access the 'bge-large-zh-v1.5' configuration
|
|
|
|
|
|
|
|
bge_large_zh_v1_5_config = config.get('bge_large_zh_v1_5', {})
|
|
|
|
|
|
|
|
embed_model_path = bge_large_zh_v1_5_config.get('embed_model_path', 'default_path_if_not_provided')
|
|
|
|
|
|
|
|
|
|
|
|
class QAService():
|
|
|
|
class QAService():
|
|
|
|
def __init__(self, kb_name, device=None) -> None:
|
|
|
|
def __init__(self, kb_name, device=None) -> None:
|
|
|
|
self.kb_name = kb_name
|
|
|
|
self.kb_name = kb_name
|
|
|
|
self.device = device
|
|
|
|
self.device = device
|
|
|
|
self.fkbs = FaissKBService(kb_name, embed_model_path='bge-large-zh-v1.5', device=device)
|
|
|
|
self.fkbs = FaissKBService(kb_name, embed_model_path=embed_model_path, device=device)
|
|
|
|
self.fkbs.do_create_kb()
|
|
|
|
self.fkbs.do_create_kb()
|
|
|
|
|
|
|
|
|
|
|
|
def update_qa_doc(self, qa_file_id, doc_list, id_list):
|
|
|
|
def update_qa_doc(self, qa_file_id, doc_list, id_list):
|
|
|
|