Skip to content

Commit

Permalink
Merge pull request #33 from thibaultyou/feat/27-prompt-composition-an…
Browse files Browse the repository at this point in the history
…d-fragments

 Implement Prompt Composition and Reusable Fragments
  • Loading branch information
thibaultyou authored Oct 10, 2024
2 parents 381dec9 + 7270119 commit 7f51b6f
Show file tree
Hide file tree
Showing 36 changed files with 1,667 additions and 396 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/update_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ jobs:
- name: Update views
run: npm run update-views

- name: Generate TOC
run: npm run toc

- name: Commit changes
run: |
git config --local user.name "github-actions[bot]"
Expand Down
220 changes: 123 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,158 +1,184 @@
# 📚 Prompt Library
# 🧠 Prompt Library

> ### 🚧 **Project Under Development** 🚧
>
> This project is evolving. You may encounter bugs or frequent changes. Your feedback and contributions are welcome!
> This project is evolving. You may encounter bugs or frequent changes. Feedback and contributions are welcome!
Welcome to the **Prompt Library**. This repository contains a collection of AI prompts categorized for easy navigation and reuse. It is designed to be easily forked and customized for your own use, allowing you to create and maintain your personalized library of prompts tailored to your specific needs and use cases.
Welcome to the **Prompt Library**, a collection of categorized AI prompts for easy navigation and reuse. Fork and customize this repository to build your own personalized prompt library tailored to your needs.

## 📚 Table of Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [🎯 Purpose](#-purpose)
- [🛠️ How It Works](#-how-it-works)
- [📂 Prompt Library Example](#-prompt-library-example)
- [🚀 Getting Started](#-getting-started)
- [🔧 Customizing Metadata Extraction](#-customizing-metadata-extraction)
- [🧩 Using Fragments](#-using-fragments)
- [📝 Contributing](#-contributing)
- [📄 License](#-license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 🎯 Purpose

The primary goal of this project is to provide a structured framework for organizing and managing AI prompts. Whether you're a developer, researcher, or AI enthusiast, this library can help you:
This project provides a structured framework for organizing and managing AI prompts, helping you to:

1. Store and categorize your prompts efficiently
2. Automatically generate metadata for your prompts
3. Easily navigate and reuse your prompt collection
4. Collaborate and share prompts with others
5. Create modular and reusable prompt components using fragments

## 🛠️ How It Works

This repository uses a combination of user input and automated processes to manage your prompt library:
User input and automated processes manage your prompt library:

1. **Adding Prompts**: You create `prompt.md` files in the `prompts` directory to add new prompts to your library.
1. **Add Prompts**: Create `prompt.md` files in the `prompts` directory.
2. **Commit Changes**: Push your changes to the repository.
3. **Automation**: GitHub Actions:
- Generate metadata using `generate_metadata.ts` and the Anthropic API.
- Update `README.md` files using `update_views.ts`.
4. **Update Repository**: Changes are automatically committed back.

2. **Version Control**: You commit and push your changes to the repository.
Monitor these processes in the "Actions" tab of your GitHub repository.

3. **Automated Processing**: Once changes are pushed, GitHub Actions are triggered automatically:
- The `generate_metadata.ts` script uses the Anthropic API to analyze your prompt and generate metadata.
- The `update_views.ts` script creates or updates the `README.md` files for each prompt and updates the main README.
## 📂 Prompt Library Example

4. **Repository Updates**: All changes generated by the scripts are automatically committed back to the repository.
> **Note:** The prompts listed here are examples to demonstrate structure and organization. Customize and maintain your own prompts as needed.
You can monitor the progress of these automated processes in the "Actions" tab of your GitHub repository. This tab shows you the status of all workflow runs, allowing you to track the progress of your changes and troubleshoot any issues that may arise.
> **Tip:** Check out the Prompt Engineering category for prompts to help you create high-quality prompts and build your own library.
<details open>
<summary><strong>Coding</strong></summary>
## 🚀 Getting Started
- [Code Refactoring Agent](prompts/code_refactoring_agent/README.md) - Analyzes, refactors, and validates code to enhance quality, readability, and performance
- [Coding Assistant Agent](prompts/coding_assistant_agent/README.md) - Assists in all aspects of software development across multiple programming languages
- [Git Branch Name Generator](prompts/git_branch_name_generator/README.md) - Generates optimal git branch names based on project context and development requirements
- [Git Commit Message Expert](prompts/git_commit_message_agent/README.md) - Generates precise git commit messages following Conventional Commits specification
- [GitHub Issue Management Agent](prompts/github_issue_management_agent/README.md) - Creates comprehensive, optimized GitHub issues based on project context and team dynamics
- [Software Development Pull Request Generator](prompts/software_dev_pr_generator/README.md) - Generates comprehensive pull requests for software projects based on given context
- [Software Specification Creator](prompts/software_spec_creator_agent/README.md) - Creates detailed software specification documents through interactive requirement analysis

</details>
<details open>
<summary><strong>Healthcare</strong></summary>

- [Health Optimization Agent](prompts/health_optimization_agent/README.md) - Generates personalized, evidence-based health optimization plans using comprehensive data analysis

</details>
<details open>
<summary><strong>Problem Solving</strong></summary>

- [Problem Solving Goal Achievement Agent](prompts/problem_solving_goal_agent/README.md) - Generates tailored expert networks and solutions for complex challenges and ambitious goals

To start building your own prompt library, follow these steps:
</details>
<details open>
<summary><strong>Prompt Engineering</strong></summary>

1. **Fork the Repository**: Click the "Fork" button at the top right of this page to create a copy of this repository in your own GitHub account.
- [AI Assistant Architect](prompts/ai_assistant_architect/README.md) - Generates innovative and practical concepts for specialized AI assistants
- [Prompt Engineering God](prompts/prompt_engineering_agent/README.md) - Crafts and refines optimized prompts for AI models using advanced techniques and guidelines

2. **Clone Your Fork**: Clone the forked repository to your local machine using:
</details>
<details open>
<summary><strong>Translation</strong></summary>

- [Universal Translator Agent](prompts/universal_translator_agent/README.md) - Translates between any languages, modes of expression, or conceptual frameworks

</details>
<details open>
<summary><strong>Writing</strong></summary>

- [Software Documentation Specialist Agent](prompts/software_documentation_agent/README.md) - Creates comprehensive software documentation across various types and industries

</details>

## 🚀 Getting Started

1. **Fork the Repository**: Click "Fork" to create a copy in your GitHub account.
2. **Clone Your Fork**:
```
git clone https://github.com/YOUR_USERNAME/REPO_NAME.git
```

3. **Set Up Anthropic API Key**:
- Go to your repository's settings on GitHub.
- Navigate to "Secrets and variables" > "Actions".
- Create a new repository secret named `ANTHROPIC_API_KEY` and paste your Anthropic API key as the value.

- In repository settings: **Secrets and variables** > **Actions**.
- Create a secret named `ANTHROPIC_API_KEY` with your API key.
4. **Install Dependencies**:
- Ensure you have Node.js installed (version 22 or later recommended).
- Run `npm install` to install the project dependencies.

5. **Add Your Own Prompts**:
- Create a new file in the `prompts` directory named `prompt.md`.
- Write your prompt content in this file.
- Commit and push your changes to GitHub:
- Ensure Node.js (v22+ recommended) is installed.
- Run `npm install`.
5. **Add Prompts**:
- Create a `prompt.md` file in the `prompts` directory.
- Write your prompt content.
- Commit and push:
```
git add .
git commit -m "Add new prompt: [Brief Description]"
git push
```
6. **Let GitHub Actions Work**: The automated processes will generate metadata and update README files.
7. **Run Locally** (Optional):
- Copy the `.env.example` file to a new file named `.env` in the root directory of your project:
6. **Automated Processes**: GitHub Actions will generate metadata and update README files.
7. **Run Locally (Optional)**:
- Copy `.env.example` to `.env`:
```
cp .env.example .env
```
- Open the `.env` file and update the environment variables:
```
ANTHROPIC_API_KEY=your_actual_api_key_here
FORCE_REGENERATE=false
LOG_LEVEL=info
```
- To generate metadata for your prompts, run:
- Update `.env` with your API key.
- Generate metadata:
```
npm run generate-metadata
```
- To update the README files, run:
- Update README files:
```
npm run update-views
```
8. **Customize as Needed**:
- Modify the templates in the `src/templates` directory to change how prompts are displayed.
- Update the scripts in `src/core` to alter the metadata generation or view update process.
## 📂 Prompt Library
> **Note:** The prompts listed here serve as examples to demonstrate the structure and organization of this library. The primary goal is for you, the user, to create and maintain your own personalized library of prompts tailored to your specific needs and use cases. Feel free to modify, remove, or add prompts as you see fit.
> **Tip:** Check out the Prompt Engineering category in this library. It contains prompts that can help you create high-quality prompts with ease and get started in building your own prompt library.
### Coding
- [Code Refactoring Agent](prompts/code_refactoring_agent/README.md) - Analyzes, refactors, and validates code to enhance quality, readability, and performance
- [Git Branch Name Generator](prompts/git_branch_name_generator/README.md) - Generates optimal git branch names based on project context and development requirements
- [Coding Assistant Agent](prompts/coding_assistant_agent/README.md) - Assists in all aspects of software development across multiple programming languages
- [Git Commit Message Expert](prompts/git_commit_message_agent/README.md) - Generates precise git commit messages following Conventional Commits specification
- [GitHub Issue Management Agent](prompts/github_issue_management_agent/README.md) - Creates comprehensive, optimized GitHub issues based on project context and team dynamics
- [Software Development Pull Request Generator](prompts/software_dev_pr_generator/README.md) - Generates comprehensive pull requests for software projects based on given context
### Healthcare
- [Health Optimization Agent](prompts/health_optimization_agent/README.md) - Generates personalized, evidence-based health optimization plans using comprehensive data analysis
### Problem Solving
- [Problem Solving Goal Achievement Agent](prompts/problem_solving_goal_agent/README.md) - Generates tailored expert networks and solutions for complex challenges and ambitious goals
### Prompt Engineering
- [AI Assistant Concept Creator](prompts/ai_assistant_concept_creator/README.md) - Generates innovative and feasible AI assistant concepts for specific topics
- [Prompt Engineering Agent](prompts/prompt_engineering_agent/README.md) - Generates optimized AI prompts tailored to specific models and user requirements
- [Software Specification Creator](prompts/software_specification_agent/README.md) - Creates detailed software specifications through interactive review of user requirements
### Translation
- [Universal Translator Agent](prompts/universal_translator_agent/README.md) - Translates between any languages, modes of expression, or conceptual frameworks
### Writing
- [Software Documentation Specialist Agent](prompts/software_documentation_agent/README.md) - Creates comprehensive software documentation across various types and industries
- Modify templates in `src/templates` to change prompt display.
- Update scripts in `src/core` to alter metadata generation or view updates.
## 🔧 Customizing Metadata Extraction
The system prompt used to extract metadata from your prompts can be customized. This prompt is located at:
The system prompt for metadata extraction is at:
[`src/system_prompts/prompt_analysis_agent/prompt.md`](src/system_prompts/prompt_analysis_agent/prompt.md)
To customize the metadata extraction process:
To customize:
1. Open `prompt.md` and modify sections like `<instructions>` or `<output>` to adjust metadata extraction.
2. Save your changes.
3. Run `npm run generate-metadata` to test.
4. Commit and push changes to trigger GitHub Actions.
1. Open the `prompt.md` file in your preferred text editor.
2. Review the existing prompt structure, which includes sections like `<system_role>`, `<task>`, `<input_parameters>`, `<instructions>`, and `<output>`.
3. Modify the content within these sections to adjust the behavior of the metadata extraction process. For example:
- Update the `<instructions>` section to change how categories are assigned.
- Modify the `<output>` section to alter the structure of the generated metadata.
- Adapt the categories in the `Top-Level Categories` list to better suit your needs.
4. Save your changes to the file.
> **Note**: Changes affect future metadata generations. Test thoroughly.
After modifying the prompt:
## 🧩 Using Fragments
- Run `npm run generate-metadata` locally to test your changes.
- Review the generated metadata files to ensure the output meets your expectations.
- If satisfied, commit and push your changes to trigger the GitHub Actions workflow.
Fragments are reusable prompt components.
This customization allows you to tailor the metadata generation process to your specific needs or to extract additional information from your prompts. Remember that changes to this file will affect all future metadata generations, so test thoroughly before committing.
To use fragments:
1. **Create a Fragment**:
- In `fragments`, create a subdirectory under the appropriate category.
- Create a new `.md` file with your fragment content.
2. **Add Fragment to a Prompt**:
- Include the fragment content in your prompt file.
3. **Update Metadata and Views**:
- Regenerate metadata:
```
FORCE_REGENERATE=true npm run generate-metadata
```
- Update views:
```
npm run update-views
```
4. **Selective Updates**:
- Manually edit metadata files if needed.
- Run `npm run update-views` to reflect changes.
> **Note**: The `generate_metadata.ts` script in `src/core/` uses this prompt file when interacting with the Anthropic API. If you make significant changes to the prompt structure, you may need to update the script as well.
> **Note**: Forcing metadata regeneration can be costly; consider running selectively.
## 📝 Contributing
Contributions to improve the templates, scripts, or overall structure of this prompt library are welcome! Please feel free to submit issues or pull requests.
Contributions to improve templates, scripts, or structure are welcome! Submit issues or pull requests.
## 📄 License
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default [
{
blankLine: 'always',
prev: '*',
next: ['if', 'try', 'class', 'function', 'export']
next: ['if', 'try', 'for', 'class', 'function', 'export']
},
{
blankLine: 'always',
Expand Down
61 changes: 61 additions & 0 deletions fragments/prompt_engineering/behavior_attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# AI Behavior Attributes

This file defines the available attributes for customizing AI behavior. Each attribute is described with its name, range or options, default value, and a brief explanation of its effect.

## Tone
- Options: Friendly, Professional, Casual, Formal, Neutral
- Default: Neutral
- Description: Sets the overall communication style of the AI.
- Friendly: Warm and approachable
- Professional: Efficient and expertise-focused
- Casual: Relaxed and conversational
- Formal: Polite and structured
- Neutral: Balanced between formality and casualness

## Verbosity
- Range: 0-5
- Default: 3
- Description: Controls how detailed or concise the AI's responses are.
- 0: Extremely concise, providing only essential information.
- 5: Highly detailed, offering comprehensive explanations and examples.

## Humor
- Range: 0-5
- Default: 2
- Description: Determines the frequency and intensity of jokes or witty remarks.
- 0: No humor, strictly factual responses.
- 5: Frequent use of humor, including jokes and playful language.

## Creativity
- Range: 0-5
- Default: 3
- Description: Influences the AI's tendency to provide novel or unconventional ideas.
- 0: Strictly conventional and established ideas.
- 5: Highly creative and original concepts.

## Assertiveness
- Range: 0-5
- Default: 2
- Description: Controls how strongly the AI expresses opinions or recommendations.
- 0: Very passive, mostly providing information without strong opinions.
- 5: Highly assertive, confidently expressing opinions and recommendations.

## Empathy
- Range: 0-5
- Default: 3
- Description: Adjusts how much the AI tries to understand and respond to emotions.
- 0: Purely logical, without consideration for emotional context.
- 5: Highly empathetic, actively acknowledging and responding to emotional cues.

Note: The Tone setting serves as an overarching guide for the AI's communication style, while the other attributes allow for fine-tuning specific aspects of its personality. These attributes work together to create a nuanced and customizable AI personality.

Default Configuration:
If no custom values are specified, the AI will use the following default configuration:
- Tone: Neutral
- Verbosity: 3
- Humor: 2
- Creativity: 3
- Assertiveness: 2
- Empathy: 3

This default configuration aims to provide a balanced and adaptable starting point for the AI's behavior, suitable for a wide range of interactions while allowing for easy customization as needed.
File renamed without changes.
Loading

0 comments on commit 7f51b6f

Please sign in to comment.