- Added new configuration for knowledge base root directory in `.env.example` and `settings.py`. - Implemented `find_products` method in `CoreReadOnlyRepository` for fuzzy product search based on user queries. - Introduced `search_cs_knowledge` function in `rag_service.py` to facilitate semantic search across new `fin_*` collections. - Updated document parsing to support Markdown and YAML front-matter for knowledge base entries. - Created multiple new FAQ and policy documents in the `data/kb_collections` directory to enrich the knowledge base. This update significantly improves the knowledge retrieval capabilities for customer service interactions, ensuring more relevant and accurate responses.
23 lines
593 B
Python
23 lines
593 B
Python
"""向量化:Ollama bge-m3,1024 维(客服 KB 灌库 / fin_* 检索用)。
|
||
|
||
薄封装 `app.service.embedding`,与 T-21 共用同一 Ollama 配置。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from app.service import embedding
|
||
|
||
|
||
class Embedder:
|
||
"""批量/单条 embedding(build_collections / test_search 调用面)。"""
|
||
|
||
def embed(self, text: str) -> list[float]:
|
||
return embedding.embed_text(text)
|
||
|
||
def embed_batch(self, texts: list[str]) -> list[list[float]]:
|
||
return embedding.embed_texts(texts)
|
||
|
||
|
||
def get_embedder() -> Embedder:
|
||
return Embedder()
|