需求1.输入_004_langgraph_more_nodes\agent_state.py 状态中# 输入input: str ,
输出是# 是否跟中医有关系 状态为:is_zhongyi_intent: bool
判断是否和中医意图相关
完成第一个节点,代码写在nodes/zhongyi_intent_node.py 中


需求2. 从用户输入中抽取相应的实体,并更新状态
输入:state["input"]
输出:    # 用户输入的实体抽取
    user_input_effects: List[str]
    user_input_diseases: List[str]
    user_input_symptoms: List[str]
    user_input_formulas: List[str]
    user_input_herbs: List[str]
    user_input_sources: List[str]

我们要用户抽取的实体类型包括:
    1. Symptom（症状），如咳嗽、腹痛等
    2. Disease（疾病），如感冒、肺炎、肾虚等
    3. Formula（方剂），如四君子汤、桂枝汤等
    4. Herb（药材），如人参、黄芪、丁香等
    5. Effect（功效），如补气、活血、祛湿、止痛等
    6. Source（出处），如《本草纲目》《伤寒论》等

我们的节点名称是:extract_entity_from_user_input_node.py


#需求3. 从用户输入的实体匹配到 neo4j中的标准实体(neo4j中的标准实体在faiss中存着)
节点名称是:match_entity_from_neo4j_node.py
输入:
    # 用户输入的实体抽取
    user_input_effects: List[str]
    user_input_diseases: List[str]
    user_input_symptoms: List[str]
    user_input_formulas: List[str]
    user_input_herbs: List[str]
    user_input_sources: List[str]
输出:
    # 匹配的实体
    matched_effects: List[str]
    matched_diseases: List[str]
    matched_symptoms: List[str]
    matched_formulas: List[str]
    matched_herbs: List[str]
    matched_sources: List[str]
faiss的数据在:
D:\heima_creazy_05\04_code\chinese_medical_project_all_project_for_heima_crazy_05\_003_create_neo4j_database
nero4j_embedding_faiss.index
nero4j_embedding_faiss_id2text.pkl

你可以使用D:\heima_creazy_05\04_code\chinese_medical_project_all_project_for_heima_crazy_05\common\embedding_model.py
的embedding模型来 实现我的这个节点
 ,要求取top 5的数据, 相似度阈值大于70%

 #需求  NL2SQL:==text2SQL  自然语言生成sql语句

 text2cypher   NL2cypher
 根据用户的提问, 匹配到的实体 以及neo4j中的元数据生成cypher语句 ,节点名称是:generate_neo4j_cypher_node.py
 输入:
     #1. 输入
    input: str
    # 匹配的实体,为了where 条件能匹配到内容
    matched_effects: List[str]
    matched_diseases: List[str]
    matched_symptoms: List[str]
    matched_formulas: List[str]
    matched_herbs: List[str]
    matched_sources: List[str]
    #neo4j的元数据 config中的
    self.EMBEDDING_MODEL_PATH = os.getenv("EMBEDDING_MODEL_PATH")
 输出:
     # cypher查询语句
    cypher_query: List[str]


 需求 cypher语句检查节点: 判断cypher_query 中的cypher语句是否都合法,然后更新is_all_validate_cypher 状态
 如果都合法is_all_validate_cypher为True ,否则为False
 输入:    cypher_query: List[str]
 输出:   is_all_validate_cypher: bool
代码写在:_004_langgraph_more_nodes/nodes
 节点名叫 check_cypher_node.py  ,
 用EXPLAIN来执行检查cypher语句,是没有幻觉的,对就是对,错就是错,便宜

run_cypher_node.py
需求: 执行cypher 语句 ,更新状态 节点名称为:run_cypher_node
入参:cypher_query: List[str] 就是要执行的cypher语句
出参:cypher_results: List[List[Dict[str, Any]]] 这个就是执行完cypher语句返回的结果
利用:neo4j_manager.py 中的def run_cypher(self, query, parameters=None): 方法来执行cypher语句


需求:根据用户输入,和cypher查询结果 调用大模型进行回答 节点名称
入参: user_input = state["input"]
入参:cypher_results = state.get("cypher_results", [])
出参: neo4j_answer: str
    # 输出
    output: str


需求: 根据用户的输入input状态进行回答问题,并更新  direct_out\ output ,节点名为llm_direct_out_node.py
输入:入参: user_input = state["input"]
 # 存入 state
    state["direct_out"] = model_answer
    state["output"] = model_answer


需求:
根据D:\heima_creazy_05\04_code\chinese_medical_project_all_project_for_heima_crazy_05\_004_langgraph_more_nodes
中创建 节点和状态
以及我给你提供的图:D:\heima_creazy_05\03_笔记\day05\langgraph图.png
帮我实现一个脚本名字为:langgraph_more_nodes.py ,将这些节点和状态串起来,构建出来langgraph的图,并给出测试用例

cypher检查节点 如果检查失败了,需要生成cypher, 重试上线是3次, 另外每个节点开始的时候,打印一下, xxx节点执行开始了