qwen_agent/skills/autoload/onprem/rag-retrieve/hooks/pre_prompt.py
朱潮 425f3c5bb4 chore: replace Chinese comments and log messages with English
Convert all Chinese comments, docstrings, logger/print output,
HTTPException detail messages, and API response messages to English
across the entire codebase. Functional zh/ja localized strings
(e.g. prompt templates, timezone display names, date formats) are
preserved as-is.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-30 19:45:35 +08:00

29 lines
769 B
Python

#!/usr/bin/env python3
"""
PreMemoryPrompt Hook - example user context loader.
Runs when the memory extraction prompt (FACT_RETRIEVAL_PROMPT) is loaded,
and selects whether to enable the retrieval policy that forbids using the model's own knowledge based on environment variables.
"""
import os
import sys
from pathlib import Path
def main():
enable_self_knowledge = (
os.getenv("ENABLE_SELF_KNOWLEDGE", "false").lower() == "true"
)
policy_name = (
"retrieval-policy.md"
if enable_self_knowledge
else "retrieval-policy-forbidden-self-knowledge.md"
)
prompt_file = Path(__file__).parent / policy_name
print(prompt_file.read_text(encoding="utf-8"))
return 0
if __name__ == '__main__':
sys.exit(main())