-
Notifications
You must be signed in to change notification settings - Fork 48
refactor: extract prompts.py into subpackage with .md templates #11
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
Closed
shenxiangzhuang
wants to merge
4
commits into
zjunlp:main
from
shenxiangzhuang:refactor/prompts-subpackage
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
285e76b
refactor: extract prompts into subpackage with .md templates
shenxiangzhuang 863f988
chore: clean up redundant comments, remove test files, revert pytest dep
shenxiangzhuang f9e62ac
chore: strip leading blank lines from prompt template .md files
shenxiangzhuang c1ae28f
fix: include .md templates as package data for distribution
shenxiangzhuang 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
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from pathlib import Path | ||
|
|
||
| _TEMPLATE_DIR = Path(__file__).parent / "templates" | ||
|
|
||
|
|
||
| def _load_template(filename: str) -> str: | ||
| return (_TEMPLATE_DIR / filename).read_text(encoding="utf-8") | ||
|
|
||
|
|
||
| CANDIDATE_METADATA_SYSTEM_PROMPT = "You are a helpful assistant." | ||
|
|
||
| SKILL_CONTENT_SYSTEM_PROMPT = "You are an expert Technical Writer specializing in creating SKILL for AI agents." | ||
|
|
||
| RELATIONSHIP_ANALYSIS_SYSTEM_PROMPT = """ | ||
| You are the SkillNet Architect. | ||
| """ | ||
|
|
||
| CANDIDATE_METADATA_USER_PROMPT_TEMPLATE = _load_template("candidate_metadata_user.md") | ||
|
|
||
| SKILL_CONTENT_USER_PROMPT_TEMPLATE = _load_template("skill_content_user.md") | ||
|
|
||
| SKILL_EVALUATION_PROMPT = _load_template("skill_evaluation.md") | ||
|
|
||
| GITHUB_SKILL_SYSTEM_PROMPT = _load_template("github_skill_system.md") | ||
|
|
||
| GITHUB_SKILL_USER_PROMPT_TEMPLATE = _load_template("github_skill_user.md") | ||
|
|
||
| OFFICE_SKILL_SYSTEM_PROMPT = _load_template("office_skill_system.md") | ||
|
|
||
| OFFICE_SKILL_USER_PROMPT_TEMPLATE = _load_template("office_skill_user.md") | ||
|
|
||
| PROMPT_SKILL_SYSTEM_PROMPT = _load_template("prompt_skill_system.md") | ||
|
|
||
| PROMPT_SKILL_USER_PROMPT_TEMPLATE = _load_template("prompt_skill_user.md") | ||
|
|
||
| RELATIONSHIP_ANALYSIS_USER_PROMPT_TEMPLATE = _load_template("relationship_analysis_user.md") | ||
|
|
||
| __all__ = [ | ||
| "CANDIDATE_METADATA_SYSTEM_PROMPT", | ||
| "CANDIDATE_METADATA_USER_PROMPT_TEMPLATE", | ||
| "SKILL_CONTENT_SYSTEM_PROMPT", | ||
| "SKILL_CONTENT_USER_PROMPT_TEMPLATE", | ||
| "SKILL_EVALUATION_PROMPT", | ||
| "GITHUB_SKILL_SYSTEM_PROMPT", | ||
| "GITHUB_SKILL_USER_PROMPT_TEMPLATE", | ||
| "OFFICE_SKILL_SYSTEM_PROMPT", | ||
| "OFFICE_SKILL_USER_PROMPT_TEMPLATE", | ||
| "PROMPT_SKILL_SYSTEM_PROMPT", | ||
| "PROMPT_SKILL_USER_PROMPT_TEMPLATE", | ||
| "RELATIONSHIP_ANALYSIS_SYSTEM_PROMPT", | ||
| "RELATIONSHIP_ANALYSIS_USER_PROMPT_TEMPLATE", | ||
| ] |
47 changes: 47 additions & 0 deletions
47
skillnet-ai/src/skillnet_ai/prompts/templates/candidate_metadata_user.md
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| Your goal is to analyze an interaction trajectory and extract **reusable Skills**. | ||
|
|
||
| A "Skill" is a modular, self-contained package that extends the agent's capabilities (e.g., "PDF Processor", "Market Analyzer", "Code Reviewer"). | ||
|
|
||
| # Core Objective | ||
| 1. Analyze the trajectory to identify distinct **capabilities** or **workflows**. | ||
| 2. For EACH distinct capability, extract exactly ONE corresponding **Skill Metadata** entry. | ||
|
|
||
| *Note: Avoid over-fragmentation. If the trajectory is a coherent workflow (e.g., "analyze PDF and summarize"), create ONE skill for the whole process rather than splitting it into tiny steps, unless the steps are distinct independent domains.* | ||
|
|
||
| # Input Data | ||
| **Execution Trajectory:** | ||
| {trajectory} | ||
|
|
||
| # Step 1: Skill Identification | ||
| Identify skills that are: | ||
| - **Reusable**: Useful for future, similar requests. | ||
| - **Modular**: Self-contained with clear inputs and outputs. | ||
| - **Domain Specific**: Provides specialized knowledge or workflow logic. | ||
|
|
||
| # Step 2: Metadata Extraction Rules | ||
| For EACH identified skill, generate metadata with: | ||
|
|
||
| ### `name` requirements: | ||
| - **kebab-case** (e.g., `financial-report-generator`, `code-refactor-tool`). | ||
| - Concise but descriptive. | ||
|
|
||
| ### `description` requirements (CRITICAL): | ||
| This description acts as the **Trigger** for the AI to know WHEN to use this skill. | ||
| It must be a **When-To-Use** statement containing: | ||
| 1. **Context**: The specific situation or user intent (e.g., "When the user asks to analyze a PDF..."). | ||
| 2. **Capabilities**: What the skill provides (e.g., "...extracts text and summarizes financial metrics"). | ||
| 3. **Triggers**: Specific keywords or file types associated with this skill. | ||
|
|
||
| # Output Format: | ||
| [ | ||
| {{ | ||
| "name": "example-skill-name", | ||
| "description": "Comprehensive trigger description explaining precisely WHEN and WHY to load this skill." | ||
| }}, | ||
| ... | ||
| ] | ||
|
|
||
| Keep your output in the format below: | ||
| <Skill_Candidate_Metadata> | ||
| your generated candidate metadata list in JSON format here | ||
| </Skill_Candidate_Metadata> | ||
26 changes: 26 additions & 0 deletions
26
skillnet-ai/src/skillnet_ai/prompts/templates/github_skill_system.md
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| You are an expert Technical Writer specializing in creating Skills for AI agents. | ||
| Your task is to analyze a GitHub repository and generate a comprehensive skill package that captures the repository's functionality and usage patterns. | ||
|
|
||
| CRITICAL REQUIREMENTS: | ||
| 1. Generate COMPLETE content - do not truncate or abbreviate sections | ||
| 2. Include ALL installation steps with actual commands from README | ||
| 3. Extract CONCRETE code examples from README - copy them exactly, don't invent new ones | ||
| 4. List specific models, APIs, or tools mentioned in the repository | ||
| 5. For scripts/: Generate REAL, RUNNABLE Python code that demonstrates library usage | ||
| 6. For references/: Generate DETAILED API documentation with actual function signatures | ||
| 7. Follow the SkillNet skill structure standard exactly | ||
| 8. Output files in parseable format with ## FILE: markers | ||
|
|
||
| SCRIPT QUALITY REQUIREMENTS: | ||
| - Scripts must be self-contained and runnable (no os.system('conda activate')) | ||
| - Scripts should demonstrate actual library API usage, not shell command wrappers | ||
| - Include proper imports, error handling, and docstrings | ||
| - If the library requires specific data, use placeholder paths with clear comments | ||
|
|
||
| REFERENCE QUALITY REQUIREMENTS: | ||
| - API references must include actual function signatures from code analysis | ||
| - Include parameter types, return types, and brief descriptions | ||
| - Organize by module/class hierarchy | ||
| - Reference the source file locations | ||
|
|
||
| Your output will be parsed by a script, so maintain strict formatting. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Take this block for example, the markdown render result is worser than the python string. So if we want to use markdown as the prompt file, some modifications to adress these format issues should be done firstly.