diff --git a/python/knext/knext/component/builder/extractor.py b/python/knext/knext/component/builder/extractor.py index cc8838d5..594da124 100644 --- a/python/knext/knext/component/builder/extractor.py +++ b/python/knext/knext/component/builder/extractor.py @@ -66,7 +66,7 @@ class LLMBasedExtractor(SPGExtractor): def to_rest(self): """Transforms `LLMBasedExtractor` to REST model `ExtractNodeConfig`.""" params = dict() - params["model_config"] = json.dumps(self.llm._nn_config) + params["model_config"] = json.dumps(self.llm.init_args) params["prompt_config"] = json.dumps( [OperatorClient().serialize(op.to_rest()) for op in self.prompt_ops] ) diff --git a/python/knext/knext/operator/builtin/auto_prompt.py b/python/knext/knext/operator/builtin/auto_prompt.py index 51ebfd92..db0ef0d4 100644 --- a/python/knext/knext/operator/builtin/auto_prompt.py +++ b/python/knext/knext/operator/builtin/auto_prompt.py @@ -68,87 +68,6 @@ input:${input} return self.template.replace("${input}", variables.get("input")) def parse_response(self, response: str) -> List[SPGRecord]: - response = """ - { - "spo": [ - { - "subject": "甲状腺结节", - "predicate": "并发症", - "object": "甲状腺癌" - }, - { - "subject": "甲状腺结节", - "predicate": "常见症状", - "object": "颈部疼痛" - }, - { - "subject": "甲状腺结节", - "predicate": "常见症状", - "object": "咽喉部异物感" - }, - { - "subject": "甲状腺结节", - "predicate": "常见症状", - "object": "压迫感" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "放射性碘治疗" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "复方碘口服液(Lugol液)" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "丙基硫氧嘧啶(PTU)" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "甲基硫氧嘧啶(MTU)" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "甲硫咪唑" - }, - { - "subject": "甲状腺结节", - "predicate": "适用药品", - "object": "卡比马唑" - }, - { - "subject": "甲状腺结节", - "predicate": "就诊科室", - "object": "普外科" - }, - { - "subject": "甲状腺结节", - "predicate": "就诊科室", - "object": "甲状腺外科" - }, - { - "subject": "甲状腺结节", - "predicate": "异常指征", - "object": "血压上升" - }, - { - "subject": "甲状腺结节", - "predicate": "就诊科室", - "object": "头颈外科" - }, - { - "subject": "甲状腺结节", - "predicate": "发病部位", - "object": "甲状腺" - } - ] -} - """ if isinstance(response, list) and len(response) > 0: response = response[0] re_obj = json.loads(response) diff --git a/python/knext/knext/operator/op.py b/python/knext/knext/operator/op.py index 8ea7d867..82c6f494 100644 --- a/python/knext/knext/operator/op.py +++ b/python/knext/knext/operator/op.py @@ -165,7 +165,7 @@ class PromptOp(BaseOp, ABC): ) -> List[Dict[str, str]]: if isinstance(response, list) and len(response) > 0: response = response[0] - variables.update({f"{self.name}": response}) + variables.update({f"{self.__class__.__name__}": response}) return [variables]