处理单个三元组的描述抽取
(triple, llm_processor)
| 120 | |
| 121 | |
| 122 | def 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 | |
| 147 | def process_single_file(corpus_path, task_conf, llm_processer, output_dir="output"): |
nothing calls this directly
no test coverage detected