| | |
| | | import json |
| | | |
| | | from knowledgebase import utils |
| | | from knowledgebase.doc.entity_helper import entity_helper |
| | | from knowledgebase.db.doc_db_helper import doc_dbh |
| | | from knowledgebase.log import Log |
| | | |
| | | llm = ChatOpenAI(temperature=0, |
| | |
| | | |
| | | def __init__(self, doc_type: str): |
| | | # 实体词列表 |
| | | entities = list(filter(lambda x: x.doc_type == doc_type, entity_helper.entities)) |
| | | entities = doc_dbh.get_entities_by_doc_type(doc_type) |
| | | entity_list = ','.join([entity.name for entity in entities]) + "。" |
| | | entity_rules = ";\n".join([f"- {entity.name}:{entity.prompts}" for entity in entities]) + "。" |
| | | tpl = """ |
| | |
| | | 保存缓存。 |
| | | """ |
| | | text = json.dumps(self.cache) |
| | | utils.save_to_file(text, self.cache_file) |
| | | utils.save_text_to_file(text, self.cache_file) |
| | | |
| | | def run(self, in_text: str) -> list[str]: |
| | | """ |