MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / process_single_description

Function process_single_description

CommonKG/create_kg.py:122–144  ·  view source on GitHub ↗

处理单个三元组的描述抽取

(triple, llm_processor)

Source from the content-addressed store, hash-verified

120
121
122def process_single_description(triple, llm_processor) -> str:
123 """
124 处理单个三元组的描述抽取
125 """
126 try:
127 # 构造prompt
128 text = triple["text"]
129 triple_str = triple["triple"]
130 prompt = llm_processor.extract_description_prompt(text, triple_str)
131
132 # 调用LLM
133 response = llm_processor.infer(prompt, output_json=True)
134
135 result = Triple.parse_description_plustype_response(triple_str, response)
136
137 triple["triple"] = result
138
139 return triple
140
141 except Exception as e:
142 logger.error(f"Description generation failed: {str(e)}")
143
144 return triple
145
146
147def process_single_file(corpus_path, task_conf, llm_processer, output_dir="output"):

Callers

nothing calls this directly

Calls 3

inferMethod · 0.80

Tested by

no test coverage detected