qwen_agent/skills/developing/user-context-loader/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

36 lines
952 B
Python

#!/usr/bin/env python3
"""
PrePrompt Hook - User context loader example
Executed when system_prompt is loaded; can dynamically inject user-related
information into the prompt.
"""
import os
import sys
def main():
"""Read parameters from environment variables and output injected content."""
user_identifier = os.environ.get('USER_IDENTIFIER', '')
bot_id = os.environ.get('ASSISTANT_ID', '')
# Example: query user context based on user_identifier
# This is just a demo; in production, data should come from a database or other service
if user_identifier:
context_info = f"""## User Context
用户标识: {user_identifier}
Bot ID: {bot_id}
> 此内容由 user-context-loader skill 的 PrePrompt hook 注入。
> 实际使用时,可以在这里查询用户的位置、偏好、历史记录等信息。
"""
print(context_info)
return 0
return 0
if __name__ == '__main__':
sys.exit(main())