feat: add AI学习助手 agent (KG+RAG ideal) and renshenguo feishu bot

- Add AI学习助手 agent creation script with all 39 tools, 3-layer KG+RAG memory
- Add renshenguo (人参果) feishu bot integration (app_service + ws_handler)
- Register renshenguo WS client in main.py startup
- Add RENSHENGUO_APP_ID / RENSHENGUO_APP_SECRET / RENSHENGUO_AGENT_ID config
- Reorganize docs from root into docs/ subdirectories
- Move startup scripts to scripts/startup/
- Various backend optimizations and tool improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
renjianbo
2026-05-06 01:37:13 +08:00
parent f33bc461ff
commit eabf90c496
171 changed files with 4906 additions and 445 deletions

View File

@@ -68,3 +68,43 @@ class GlobalKnowledge(Base):
def __repr__(self):
return f"<GlobalKnowledge(id={self.id}, source_agent={self.source_agent_id})>"
class KnowledgeEntity(Base):
"""知识图谱实体表 — 学习知识点、概念、术语"""
__tablename__ = "knowledge_entities"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="实体ID")
name = Column(String(200), nullable=False, comment="实体名称")
entity_type = Column(String(50), nullable=False, default="concept", comment="实体类型: concept/formula/fact/term/task/skill")
description = Column(Text, comment="实体描述")
embedding = Column(Text, nullable=True, comment="实体名称+描述的 embeddingJSON 序列化)")
metadata_ = Column("metadata", JSON, nullable=True, comment="扩展元数据")
source = Column(String(50), default="extracted", comment="来源: extracted/manual/imported")
confidence = Column(String(20), default="medium", comment="置信度: low/medium/high")
scope_kind = Column(String(50), default="agent", comment="作用域类型")
scope_id = Column(String(100), default="", comment="作用域 ID")
user_id = Column(CHAR(36), ForeignKey("users.id"), nullable=True, comment="创建者ID")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
def __repr__(self):
return f"<KnowledgeEntity(id={self.id}, name={self.name}, type={self.entity_type})>"
class KnowledgeRelation(Base):
"""知识图谱关系表 — 实体之间的语义关系"""
__tablename__ = "knowledge_relations"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="关系ID")
source_entity_id = Column(CHAR(36), nullable=False, index=True, comment="源实体ID")
target_entity_id = Column(CHAR(36), nullable=False, index=True, comment="目标实体ID")
relation_type = Column(String(50), nullable=False, comment="关系类型: prerequisite/extends/contains/related_to/example_of/applies_to")
description = Column(Text, comment="关系描述")
weight = Column(String(20), default="1.0", comment="关系权重")
scope_kind = Column(String(50), default="agent", comment="作用域类型")
scope_id = Column(String(100), default="", comment="作用域 ID")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
def __repr__(self):
return f"<KnowledgeRelation({self.source_entity_id}) -[{self.relation_type}]-> ({self.target_entity_id})>"