Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricehong committed Oct 16, 2024
0 parents commit 7dfad2b
Show file tree
Hide file tree
Showing 30 changed files with 6,143 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/

main.js
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
# main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v21.2.0
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Fabrice HONG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

# PromptCrafter for Obsidian
<a href="https://buymeacoffee.com/fabricehong" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 150px !important;" ></a>

Writing effective prompts for language models can be challenging, especially when your prompts include data that is reusable, like project details or key facts. For example, you might have a note with a project's key specifications that can be easily pulled into different prompts without rewriting. This helps structure your prompts in a more meaningful and consistent way.

To address this need, PromptCrafter allows you to create modular, reusable prompts directly within your Obsidian notes, making it easy to repurpose your knowledge for multiple scenarios without starting from scratch. By connecting different pieces of your knowledge base, you can easily generate prompts that draw on existing information, making your workflow more efficient and your knowledge more organized.

This turns your Obsidian vault into a powerful tool for managing and creating high-quality prompts for LLMs.

# How it works
1. Create a prompt using a ```pc``` code block and parameterize it with ```{{mustache placeholders}}```.
2. Define the value of the placeholders in your frontmatter section. These can be either static values or links within your Obsidian vault.
3. Copy the resolved ```pc``` block and paste it into ChatGPT or another LLM.

## Obsidian links content resolution
- If you put an \[\[Obsidian link\]\] as value of the variables in frontmatter section, the content of the linked note will be resolved.
- You can target a specific section in your file by using ```#```. Example: \[\[my file#header1\]\].
- If the resolved content is another ```pc``` block, this new ```pc``` block is resolved again using the frontmatter of the host note.

## Video
![PromptCrafter Obsidian plugin demo](https://i.imgur.com/BSJpGv3.gif)

## Examples
**Step 1:**

\-\-\-

audio-transcript: \[\[project-x/my-whisper-transcript\]\]

\-\-\-

```pc
# Context
I'm trying to define the essence of my project. I did it by recording a 15 min audio of myself.
# Your task
Transform my AudioTranscript into a structured documentation and produce a markdown document using the following structure: context, problematic, solution, main features.
# AudioTranscript
{{audio-transcript}}
```
Then enrich your Obsidian Vault with the new documentation ```project description.md```.

**Step 2:**

\-\-\-

project-description: \[\[project-x/project description\]\]
cool-names: \[\[project-x/brainstormings#best names\]\]

\-\-\-

```pc
# Context
I'm looking for a name for my project.
## Project description
{{project-description}}
# Your task
Your brainstorm 5 project name proposition, I give you quick feedback for your next propositions, we reiterate in an infinite loop. Inspire your propositions on the ProjectNameIdeas that I've liked so far.
# ProjectNameIdas
{{cool-names}}
```
Then enrich your "best-names.md" files in order to refine your brainstorming for later use.

Continue iterating on your project for:
- **Communications** based on ```project description```
- metaphor research
- linkedin posts
- pitches
- **Specifications** based on ```project description```
- feature descriptions / stories
- use cases brainstorming
- **Programming** based on ```project description``` and ```feature descriptions```
- generate code for a specific feature
- discuss solution designs

# PromptCrafter's approach to LLM usage
- **Avoid repeating yourself when prompting**: Same project, same LLM resources. Keep your LLM assets in a versionable project repository and share them with your team.
- **Future-Proof Knowledge**: Adopt an approach to using LLMs that emphasizes creating structured knowledge and prompts for your projects. Importantly, store this information in an open, sustainable format that will be compatible with any future AI systems.
- **Simplify prompt design**: Utilize placeholders to make the structure of your prompts clutter-free, readable, and reusable.
- **Controlled Context for Better Performance**: Gain precise control over the information you introduce into your LLM context to optimize performance. Automatic methods like Retrieval-Augmented Generation don’t offer the necessary control to fully harness your LLM’s potential.
48 changes: 48 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";

const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === "production");

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
Loading

0 comments on commit 7dfad2b

Please sign in to comment.