Skip to content

Commit

Permalink
♻️ refactor: Restructure prompt categories and improve metadata gener…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
thibaultyou committed Sep 30, 2024
1 parent 3a649cf commit 595764f
Show file tree
Hide file tree
Showing 29 changed files with 430 additions and 191 deletions.
71 changes: 57 additions & 14 deletions .github/prompts/ai_prompt_analyzer_and_output_generator/prompt.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
You are an AI assistant tasked with analyzing an AI prompt and producing specific outputs related to it. The prompt will be provided to you, and you should generate the following:

1. A directory name for storing the prompt
2. A category in snake_case format
3. A list of tags
4. A one-line concise description
5. A quick description
6. A markdown link for referencing the prompt
7. A list of variables that require user input
2. A primary category from the predefined list
3. Optional subcategories (up to 2)
4. A list of tags
5. A one-line concise description
6. A quick description
7. A markdown link for referencing the prompt
8. A list of variables that require user input

Here's the list of predefined top-level categories:

TOP_LEVEL_CATEGORIES = [
"api_development",
"artificial_intelligence",
"backend_development",
"cloud_computing",
"code_analysis_and_review",
"code_generation_and_optimization",
"containerization_and_orchestration",
"data_management_and_analytics",
"database_design",
"debugging_and_error_handling",
"design_patterns",
"devops",
"documentation",
"frontend_development",
"full_stack_development",
"ide_and_development_tools",
"machine_learning",
"mobile_development",
"network_programming",
"performance_tuning",
"project_management",
"prompt_engineering",
"refactoring",
"scalability_and_system_design",
"security",
"software_architecture",
"testing_and_quality_assurance",
"user_experience_design",
"version_control",
"web_development",
"workflow_automation"
]

Here's the AI prompt you need to analyze:

Expand All @@ -24,10 +61,13 @@ Generate a directory name for the prompt using the following convention:
- Remove any special characters
- The directory name should be concise but descriptive, ideally not exceeding 50 characters

2. Category:
Determine a simple and clear category for the prompt, formatted in snake_case.
2. Primary Category:
Select the most appropriate primary category from the predefined list of top-level categories, formatted in snake_case.

3. Tags:
3. Subcategories:
Determine up to two subcategories that further specify the prompt's focus. These should be more specific than the primary category and can be custom-created, formatted in snake_case.

4. Tags:
Create a list of 3-5 relevant tags for the prompt. These tags should:

- Be single words or short phrases
Expand All @@ -36,36 +76,39 @@ Create a list of 3-5 relevant tags for the prompt. These tags should:
- Accurately represent the main themes or applications of the prompt
- Be useful for categorizing and searching for the prompt

4. One-line description:
5. One-line description:
Write a concise, one-line description of the prompt that:

- Captures the main purpose or function of the prompt
- Is no longer than 100 characters
- Starts with a verb in the present tense (e.g., "Creates," "Generates," "Analyzes")

5. Quick description:
6. Quick description:
Provide a brief description of the prompt that:

- Expands on the one-line description
- Explains the key features or capabilities of the prompt
- Is 2-3 sentences long
- Gives the reader a clear understanding of what the prompt does

6. Markdown link:
7. Markdown link:
Create a markdown link that can be used to reference the prompt:

- Use the one-line description as the link text
- Use the directory name as the link URL
- Format it as: [One-line description](directory_name)

7. User input variables:
8. User input variables:
List all variables in the prompt that require user input or replacement. These should be in the format {{VARIABLE_NAME}} and listed one per line.

Present your final output in the following format:

<output>
title: [Prompt's main topic or purpose]
category: [Your determined category in snake_case]
primary_category: [Your selected primary category]
subcategories:
- [Subcategory 1]
- [Subcategory 2]
directory: [Your generated directory name]
tags:
- [Tag 1]
Expand Down
12 changes: 9 additions & 3 deletions .github/scripts/generate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def generate_metadata(prompt_content):
logger.info("Sending request to Anthropic API")
message = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1000,
max_tokens=2500,
messages=[
{
"role": "user",
Expand Down Expand Up @@ -76,7 +76,13 @@ def generate_metadata(prompt_content):
return metadata

def should_update_metadata(prompt_file, metadata_file):
"""Check if metadata should be updated based on content hash."""
"""Check if metadata should be updated based on content hash or force flag."""
force_regenerate = os.environ.get('FORCE_REGENERATE', 'false').lower() == 'true'

if force_regenerate:
logger.info("Forcing metadata regeneration due to system prompt changes.")
return True, None

# Generate hash of the prompt file content
with open(prompt_file, 'rb') as f:
prompt_content = f.read()
Expand Down Expand Up @@ -200,7 +206,7 @@ def update_prompt_metadata():
shutil.rmtree(item_path)
else:
os.rename(item_path, new_dir_path)
item_path = new_dir_path # Update item_path for the new location
item_path = new_dir_path

# Save updated metadata
metadata_path = os.path.join(item_path, 'metadata.yml')
Expand Down
18 changes: 11 additions & 7 deletions .github/scripts/update_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,27 @@ def update_views():
logger.info(f"Wrote view content to {view_path}")

# Organize prompts by category for the README
category = format_category(metadata.get('category', 'Uncategorized'))
if category not in categories:
categories[category] = []
primary_category = metadata.get('primary_category', 'uncategorized')
if primary_category not in categories:
categories[primary_category] = []

categories[category].append({
categories[primary_category].append({
'title': metadata.get('title', 'Untitled'),
'description': metadata.get('one_line_description', 'No description'),
'path': f'prompts/{prompt_dir}/view.md'
'path': f'prompts/{prompt_dir}/view.md',
'subcategories': metadata.get('subcategories', [])
})
logger.info(f"Added prompt to category: {category}")
logger.info(f"Added prompt to category: {primary_category}")

# Remove empty categories
categories = {k: v for k, v in categories.items() if v}

# Sort categories alphabetically
sorted_categories = dict(sorted(categories.items()))

# Generate README content using the template and write to file
logger.info("Generating README content")
readme_content = readme_template.render(categories=sorted_categories)
readme_content = readme_template.render(categories=sorted_categories, format_category=format_category)
readme_path = 'README.md'
with open(readme_path, 'w') as f:
f.write(readme_content)
Expand Down
2 changes: 1 addition & 1 deletion .github/templates/readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Welcome to the **Prompt Library**. This repository contains a collection of AI p

{% for category, prompts in categories.items() %}

### {{ category }}
### {{ format_category(category) }}

{% for prompt in prompts %}

Expand Down
12 changes: 12 additions & 0 deletions .github/templates/view_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@

- {{ tag }}
{% endfor %}

### 📚 Category

Primary Category: {{ metadata.primary_category }}

{% if metadata.subcategories %}
Subcategories:
{% for subcategory in metadata.subcategories %}

- {{ subcategory }}
{% endfor %}
{% endif %}
17 changes: 17 additions & 0 deletions .github/workflows/update_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,39 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.6"
cache: "pip"
cache-dependency-path: ".github/scripts/requirements.txt"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/scripts/requirements.txt
- name: Check for system prompt changes
id: check_changes
run: |
if git diff --name-only HEAD^ HEAD | grep -q ".github/prompts/ai_prompt_analyzer_and_output_generator/"; then
echo "FORCE_REGENERATE=true" >> $GITHUB_ENV
else
echo "FORCE_REGENERATE=false" >> $GITHUB_ENV
fi
- name: Generate metadata
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
FORCE_REGENERATE: ${{ env.FORCE_REGENERATE }}
run: python .github/scripts/generate_metadata.py

- name: Update views
run: python .github/scripts/update_views.py

- name: Commit changes
run: |
git config --local user.name "github-actions[bot]"
Expand Down
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,65 @@ Welcome to the **Prompt Library**. This repository contains a collection of AI p



### Code Documentation



- [AI Code Repository Documentation Generator](prompts/ai_code_repository_documentation_generator/view.md) - Analyzes code repositories and generates comprehensive documentation autonomously
### Artificial Intelligence



- [God Tier Assistant Generator](prompts/god_tier_assistant_generator/view.md) - Generates innovative ideas for specialized AI assistants based on given topics

### Code Improvement

- [AI Topic Idea Generator](prompts/ai_topic_idea_generator/view.md) - Generates diverse and innovative AI application ideas for specific domains and constraints


- [Code Refactoring AI Assistant](prompts/code_refactoring_ai_assistant/view.md) - Analyzes, refactors, and tests code to improve quality, readability, and performance


### Documentation


### Idea Generation

- [AI-Powered Code Repository Documentation Generator](prompts/ai_code_repository_documentation_generator/view.md) - Analyzes code repositories and generates comprehensive documentation autonomously


- [God Tier Assistant Generator](prompts/god_tier_assistant_generator/view.md) - Generates innovative ideas for specialized AI assistants based on given topics


- [AI Topic Idea Generator](prompts/ai_topic_idea_generator/view.md) - Generates innovative AI application ideas for specific domains and constraints
### Full Stack Development



- [Advanced Software Development AI Assistant](prompts/advanced_software_development_ai_assistant/view.md) - Provides expert guidance and support throughout the software development lifecycle

### Issue Management



- [GitHub Issue Creator](prompts/github_issue_creator_from_user_input/view.md) - Creates well-structured GitHub Issues from user input and project context
### Project Management



- [Software Specification Generator](prompts/software_specification_generator/view.md) - Creates comprehensive software specifications based on user requirements

### Product Management

- [GitHub Issue Creation Assistant](prompts/github_issue_creation_assistant/view.md) - Creates well-structured GitHub Issues from various inputs


- [Software Specification Generator](prompts/software_specification_generator/view.md) - Creates comprehensive software specifications based on user requirements and interactive review


### Refactoring


### Software Development

- [Code Refactoring AI Assistant](prompts/code_refactoring_ai_assistant/view.md) - Analyzes, refactors, and tests code to improve quality, readability, and performance


- [AI Software Development Assistant](prompts/ai_software_development_assistant/view.md) - Provides expert guidance and support throughout the software development lifecycle


- [GitHub Pull Request Generator](prompts/github_pull_request_generator/view.md) - Generates comprehensive and well-structured GitHub pull requests based on change details and project context


### Version Control


### Version Control

- [Git Commit Message Writer](prompts/git_commit_message_writer/view.md) - Generates concise, informative git commit messages following Conventional Commits with emojis


- [Git Commit Message Writer](prompts/git_commit_message_writer/view.md) - Generates concise, informative git commit messages with emojis following Conventional Commits
- [GitHub Pull Request Generator](prompts/github_pull_request_generator/view.md) - Generates comprehensive and well-structured GitHub pull requests



Expand Down
22 changes: 22 additions & 0 deletions prompts/advanced_software_development_ai_assistant/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
title: Advanced Software Development AI Assistant
primary_category: full_stack_development
subcategories:
- ai_assisted_development
- software_lifecycle_support
directory: advanced_software_development_ai_assistant
tags:
- software_development
- ai_assistant
- code_generation
- debugging
- best_practices
one_line_description: Provides expert guidance and support throughout the software
development lifecycle
description: This AI assistant specializes in full-stack software development, offering
expert guidance, code suggestions, and workflow optimization. It supports developers
from ideation to deployment and maintenance, covering various programming languages,
frameworks, and development practices.
variables:
- '{{USER_REQUEST}}'
- '{{CONTEXT}}'
content_hash: None
Loading

0 comments on commit 595764f

Please sign in to comment.