{"record":{"id":"0a600a018811ad64","repo":"iflytek/astron-agent","slug":"iflyauditapi-know-ref-is-not-implemented-yet","errorCode":null,"errorMessage":"IFlyAuditAPI.know_ref is not implemented yet","messagePattern":"IFlyAuditAPI\\.know_ref is not implemented yet","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py","lineNumber":462,"sourceCode":"        :param text: Text content to be processed\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/outputMedia\"\n        # TODO: To be implemented\n        raise NotImplementedError(\"IFlyAuditAPI.output_media is not implemented yet\")\n\n    async def know_ref(self, text: str, **kwargs: Any) -> None:\n        \"\"\"\n        In LLM content security scenarios, filter, detect and identify websites, knowledge bases\n        and other data referenced during LLM responses, and process and respond accordingly based on security policies.\n        :param text: Text content to be processed\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/knowRef\"\n        # TODO: To be implemented\n        raise NotImplementedError(\"IFlyAuditAPI.know_ref is not implemented yet\")\n","sourceCodeStart":444,"sourceCodeEnd":463,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py#L444-L463","documentation":"IFlyAuditAPI.know_ref is a placeholder for the iFlytek 'knowRef' audit endpoint (/audit/v3/aichat/knowRef), which is meant to screen websites/knowledge bases referenced during LLM responses. The body only contains the commented-out path and a TODO, so calling it always raises NotImplementedError. It exists to satisfy the audit API interface contract, not to provide behavior.","triggerScenarios":"Any invocation of IFlyAuditAPI.know_ref(...) while the iFlytek audit backend is active — arguments are irrelevant — typically when the audit pipeline processes knowledge-base/RAG references in LLM output.","commonSituations":"A RAG-enabled workflow configured with the iFlytek audit provider reaches the knowledge-reference moderation step; developers enable reference auditing in config without knowing the iFlytek backend lacks this capability; interface-conformance tests call every abstract method and hit the stub.","solutions":["Disable/skip the knowledge-reference audit stage in the pipeline configuration when using the iFlytek backend.","Implement know_ref in ifly_audit_api.py calling POST /audit/v3/aichat/knowRef and raising CustomException(CodeEnum.AUDIT_*) when data.action != ActionEnum.NONE, mirroring output_text.","Gate the call behind a capability check (e.g. hasattr/isinstance or a supports_know_ref flag) so unsupported backends degrade gracefully.","File/track the TODO so the stub is implemented before enabling reference auditing in production."],"exampleFix":"# before\nasync def know_ref(self, text: str, **kwargs: Any) -> None:\n    # path = f\"/audit/v3/aichat/knowRef\"\n    # TODO: To be implemented\n    raise NotImplementedError(\"IFlyAuditAPI.know_ref is not implemented yet\")\n\n# after\nasync def know_ref(self, text: str, **kwargs: Any) -> None:\n    payload = {\"intention\": \"dialog\", \"content\": text, **kwargs}\n    resp = await self._post(\"/audit/v3/aichat/knowRef\", payload, kwargs.get(\"chat_app_id\", \"\"), kwargs.get(\"uid\", \"\"))\n    if resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n        raise CustomException(CodeEnum.AUDIT_OUTPUT_ERROR, cause_error=f\"Audit result abnormal: {resp}\")","handlingStrategy":"fallback","validationCode":"if not audit_config.get(\"enable_know_ref_audit\") or audit_backend == \"iflytek\":\n    logger.info(\"know_ref audit disabled: unsupported by iFlytek backend\")\n    return","typeGuard":"def implements_know_ref(api) -> bool:\n    import inspect\n    src = inspect.getsource(type(api).know_ref)\n    return \"raise NotImplementedError\" not in src","tryCatchPattern":"try:\n    await audit_api.know_ref(reference_text)\nexcept NotImplementedError:\n    logger.warning(\"know_ref audit not implemented; skipping reference screening\")\nexcept CustomException as e:\n    handle_audit_rejection(e)","preventionTips":["Keep a capability matrix of audit backends vs supported endpoints and drive config from it","Skip knowledge-reference auditing for backends that lack the knowRef endpoint","Raise at configuration-load time if an enabled feature maps to a stub method","Cover all interface methods in CI so unimplemented stubs surface in tests, not production"],"tags":["python","audit","not-implemented","iflytek","rag"],"backgroundTag":"method-not-implemented","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}