- 
                Notifications
    
You must be signed in to change notification settings  - Fork 865
 
release note supports system prompt #2943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 3 commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -66,6 +66,38 @@ jobs: | |
| "https://github.com/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/releases/tag/${RELEASE_VERSION}" \ | ||
| -o release_page.html | ||
| 
     | 
||
| # Extract system prompt content from HTML | ||
| echo "Extracting system prompt content..." | ||
| SYSTEM_PROMPT="" | ||
| 
     | 
||
| # Find the line number where system prompt starts | ||
| system_prompt_start=$(grep -n "<h2>system prompt</h2>" release_page.html | cut -d: -f1) | ||
| 
     | 
||
| if [ -n "$system_prompt_start" ]; then | ||
| # Find the next h2 tag after system prompt | ||
| next_h2_line=$(tail -n +$((system_prompt_start + 1)) release_page.html | grep -n "<h2>" | head -1 | cut -d: -f1) | ||
| 
     | 
||
| if [ -n "$next_h2_line" ]; then | ||
| # Calculate actual line number and extract content between the two h2 tags | ||
| system_prompt_end=$((system_prompt_start + next_h2_line)) | ||
| system_prompt_raw=$(sed -n "${system_prompt_start},$((system_prompt_end - 1))p" release_page.html) | ||
| else | ||
| # If no next h2 found, extract till end of file | ||
| system_prompt_raw=$(tail -n +${system_prompt_start} release_page.html) | ||
| fi | ||
| 
     | 
||
| # Clean up HTML tags and decode entities, store in variable | ||
| SYSTEM_PROMPT=$(echo "$system_prompt_raw" | \ | ||
| sed 's/</</g; s/>/>/g; s/&/\&/g; s/"/"/g; s/'/'"'"'/g' | \ | ||
| sed '/^$/d' | \ | ||
| sed '1d') # Remove the first line (system prompt header) | ||
| 
     | 
||
| echo "System Prompt Content:" | ||
| echo "$SYSTEM_PROMPT" | ||
| else | ||
| echo "No system prompt found in the release page." | ||
| fi | ||
| 
     | 
||
| echo "Extracting PR numbers from ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME} release notes..." | ||
| PR_NUMS=$(cat release_page.html | grep -o "/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/pull/[0-9]*" | grep -o "[0-9]*$" | sort -n | uniq | tr '\n' ',') | ||
| PR_NUMS=${PR_NUMS%,} | ||
| 
        
          
        
         | 
    @@ -88,11 +120,24 @@ jobs: | |
| cd higress-report-agent | ||
| pip install uv | ||
| uv sync | ||
| 
     | 
||
| # Build command | ||
| CMD_ARGS="--mode 2 --choice 2 --pr_nums ${PR_NUMS}" | ||
| if [ -n "${IMPORTANT_PR_NUMS}" ]; then | ||
| uv run report_main.py --mode 2 --choice 2 --pr_nums ${PR_NUMS} --important_prs ${IMPORTANT_PR_NUMS} | ||
| else | ||
| uv run report_main.py --mode 2 --choice 2 --pr_nums ${PR_NUMS} | ||
| CMD_ARGS="${CMD_ARGS} --important_prs ${IMPORTANT_PR_NUMS}" | ||
| fi | ||
| if [ -n "${SYSTEM_PROMPT}" ]; then | ||
| echo "${SYSTEM_PROMPT}" > temp_system_prompt.txt | ||
| CMD_ARGS="${CMD_ARGS} --sys_prompt_file temp_system_prompt.txt" | ||
| fi | ||
| 
     | 
||
| uv run report_main.py ${CMD_ARGS} | ||
| 
     | 
||
| # Clean up temporary file | ||
| if [ -f "temp_system_prompt.txt" ]; then | ||
| rm temp_system_prompt.txt | ||
| fi | ||
| 
         
      Comment on lines
    
      +138
     to 
      +141
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 应确保在所有退出路径上都清理临时文件,以防止残留文件占用磁盘空间。 
 📋 问题详情目前只在脚本正常执行完毕后清理临时文件 💡 解决方案使用trap命令在脚本退出时自动清理临时文件。 -          # Clean up temporary file
-          if [ -f "temp_system_prompt.txt" ]; then
-              rm temp_system_prompt.txt
-          fi
+          # Set trap to clean up temporary file on exit
+          trap 'if [ -f "temp_system_prompt.txt" ]; then rm temp_system_prompt.txt; fi' EXIT
<!-- Suggestion code flag -->
---
> 您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)
  [有用意见👍](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=helpful) | [无用意见👎](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=neutral) | [错误意见❌](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=misleading)
<!-- This is an auto-generated comment by LingmaAgent --> | 
||
| 
     | 
||
| cp report.md ../ | ||
| cp report.EN.md ../ | ||
| cd .. | ||
| 
          
            
          
           | 
    ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应使用更健壮的方法来解析HTML内容,而不是依赖grep和sed。
📋 问题详情
当前使用grep和sed来提取HTML中的内容容易出错且难以维护。如果HTML结构稍有变化,或者标签属性发生变化,这种硬编码的解析方式将失效。此外,使用shell命令处理HTML内容也不够安全,容易受到注入攻击。建议使用专门的HTML解析工具或库来处理HTML内容,以提高代码的健壮性和安全性。
💡 解决方案
考虑使用Python脚本配合BeautifulSoup库来解析HTML内容,这样可以更准确地定位和提取所需信息。例如: