# 知识图谱 ## 概述 知识图谱模块用于构建和管理品牌相关的实体关系图谱,支持语义搜索和智能推理。 ## 核心功能 ### 实体管理 - 品牌实体 - 产品实体 - 竞品实体 - 行业概念实体 ### 关系构建 - 品牌-产品关系 - 品牌-竞品关系 - 产品-行业关系 - 概念上下位关系 ## API接口 知识图谱API位于 `backend/app/api/knowledge_graph.py` ### 主要端点 | 方法 | 路径 | 说明 | |------|------|------| | GET | /api/v1/knowledge-graph/entities | 获取实体列表 | | POST | /api/v1/knowledge-graph/entities | 创建实体 | | GET | /api/v1/knowledge-graph/relations | 获取关系列表 | | POST | /api/v1/knowledge-graph/relations | 创建关系 | | GET | /api/v1/knowledge-graph/search | 语义搜索 | ## 数据模型 ### Entity (实体) ```python class Entity: id: str name: str type: str # brand/product/competitor/concept properties: dict ``` ### Relation (关系) ```python class Relation: id: str source_id: str target_id: str relation_type: str # produces/competes_with/belongs_to properties: dict ```