Compare commits

..

231 Commits

Author SHA1 Message Date
jad2121
fbfea93b6c deleted lots of random mp3 files 2024-02-21 20:22:07 -05:00
jad2121
c4332c9ee0 added audio to text under --transcribe 2024-02-21 20:00:20 -05:00
Daniel Miessler
92f8e08aac Cleanup. 2024-02-21 09:38:07 -08:00
Daniel Miessler
62f3608144 Updated output instructions. 2024-02-21 09:14:17 -08:00
Daniel Miessler
20c1ad90bb Created a STATISTICS version of analyze_threat_report. 2024-02-21 09:11:20 -08:00
Daniel Miessler
e866eeafa6 Created a STATISTICS version of analyze_threat_report. 2024-02-21 09:09:12 -08:00
Daniel Miessler
5e48c0ef2c Created a TRENDS version of analyze_threat_report. 2024-02-21 09:06:02 -08:00
Daniel Miessler
61421c28cb Improved summary to analyze_threat_report. 2024-02-21 09:03:44 -08:00
Daniel Miessler
7ebf5bc905 Added summary to analyze_threat_report. 2024-02-21 09:01:49 -08:00
Daniel Miessler
9cd15d725c Added a threat report analysis pattern. 2024-02-21 08:59:45 -08:00
Jonathan Dunn
138c779f5e changed readme 2024-02-21 08:39:31 -05:00
jad2121
31ab369e2f changed another message 2024-02-21 06:25:21 -05:00
jad2121
983084e4f0 added a statement 2024-02-21 06:24:01 -05:00
jad2121
ed847fd332 Added aliases for individual patterns. Also fixed pattern download process 2024-02-21 06:19:54 -05:00
Daniel Miessler
373d362d35 Merge pull request #118 from mikeprivette/main
Enhanced Setup Script Compatibility and Reliability Improvements
2024-02-20 09:22:28 -08:00
Mike Privette
6dff639969 Updates
- README.md - added instructions to make sure the setup.sh script was executable as this was not explicitly stated

- setup.sh - updated sed to use `sed -i` to be compatible with Linux, MacOSX and other OS versions and added a check in the local directory taht setup.sh executes in for a pyproject.toml file because the script was looking for the .toml file in the user's home directory and throwing an error
2024-02-20 10:41:34 +00:00
Daniel Miessler
6414c26636 Updated write_essay to be more conversational and less grandiose and pompous. 2024-02-19 17:34:22 -08:00
Daniel Miessler
bc4456b310 Merge pull request #114 from fureigh/remove-ds-store
Removes stray .DS_Store file
2024-02-18 18:47:34 -08:00
Daniel Miessler
873bca5230 Merge pull request #115 from fureigh/gerunds-ahoy
Makes a minor README edit for the sake of consistency
2024-02-18 18:47:05 -08:00
Fureigh
5d984f3687 Minor README edit for verb form consistency
Change `Create` to `Creating`.
2024-02-18 17:40:08 -08:00
Fureigh
9863573ff6 Remove stray .DS_Store file 2024-02-18 17:05:08 -08:00
jad2121
335fea353b now context.md is in .config 2024-02-18 16:48:47 -05:00
jad2121
a0d264bead updated readme 2024-02-18 16:36:17 -05:00
jad2121
d15e022abf fixed context 2024-02-18 16:34:47 -05:00
jad2121
8f4ab672c6 added context to cli. edit context.md and add -C to add context to your queries 2024-02-18 13:25:07 -05:00
Daniel Miessler
b127fbec15 Updated analyze_paper with more detail and legibility. 2024-02-17 19:38:12 -08:00
Daniel Miessler
0deab1ebb3 Updated analyze_paper with more detail and legibility. 2024-02-17 19:35:09 -08:00
Daniel Miessler
8aacaee643 Added a specific version of extract_wisdom just for articles. 2024-02-17 19:03:45 -08:00
Daniel Miessler
86ba1ade46 Merge pull request #111 from agu3rra/github.templates
process enhancement: adds templates to the repo
2024-02-17 16:45:28 -08:00
agu3rra
48bda7a490 adds templates on the repo 2024-02-17 14:35:07 -03:00
Daniel Miessler
40e8f0b97f Merge pull request #108 from agu3rra/fix.cli.readme.install
fixes readme link on CLI instructions
2024-02-16 15:56:38 -08:00
Daniel Miessler
174df45cdf Update README.md 2024-02-16 15:56:23 -08:00
agu3rra
b4f4ce364c fixes readme link on CLI instructions 2024-02-16 20:55:12 -03:00
Daniel Miessler
a619b3a944 Merge pull request #107 from agu3rra/fix.setup
removes initialization of API keys from server
2024-02-16 15:49:23 -08:00
Daniel Miessler
4ea2203705 Update README.md 2024-02-16 15:48:44 -08:00
agu3rra
41fb7b2130 removes initialization of API keys from server 2024-02-16 20:48:05 -03:00
Daniel Miessler
a013a249ab Update README.md 2024-02-16 14:58:55 -08:00
Daniel Miessler
0fbca248d9 Update README.md with new Quickstart note. 2024-02-16 14:50:32 -08:00
Daniel Miessler
b41f1e7ef9 Merge pull request #88 from agu3rra/single.poetry
Multiple changes: single poetry project; Bash script for creating `aliases`; updated instructions
2024-02-16 14:37:15 -08:00
Daniel Miessler
6563a611ae Merge pull request #100 from chroakPRO/patterns-added
Add 2 patterns
2024-02-16 14:31:00 -08:00
agu3rra
a3f515bc2c missing a reference on readme 2024-02-16 17:50:12 -03:00
agu3rra
cb3afa018b new line so that aliases are appended on new lines 2024-02-16 17:38:49 -03:00
agu3rra
561ea090cb bash_profile added to aliases 2024-02-16 17:29:35 -03:00
agu3rra
94ea095061 typo 2024-02-16 17:20:24 -03:00
agu3rra
4c14d1a19c removes echo 2024-02-16 17:13:24 -03:00
agu3rra
fcc707ab27 updates install instructions after naked debian test 2024-02-16 17:11:30 -03:00
Daniel Miessler
3951164776 Added Andre Guerra to credits. 2024-02-16 11:55:44 -08:00
Daniel Miessler
bae5d44363 Added Andre Guerra to primary contributors. 2024-02-16 11:52:11 -08:00
agu3rra
5aa77d89af single script install instructions added on readme 2024-02-16 16:51:02 -03:00
agu3rra
a043aaaef8 incorporates poetry install and dep setup on a single script 2024-02-16 16:48:23 -03:00
agu3rra
d02053a748 renamed package to installer while keeping poetry project as fabric 2024-02-16 16:35:48 -03:00
Daniel Miessler
4b0c12de00 Added Dani Goland to credits for enhancing the server. 2024-02-16 00:40:38 -08:00
Daniel Miessler
3bc030db67 Removed helpers2. 2024-02-15 23:58:59 -08:00
agu3rra
1971936a61 no need to enter installer folder 2024-02-15 21:55:05 -03:00
agu3rra
0401f6e7a7 updates readme 2024-02-15 21:46:03 -03:00
agu3rra
2b48e564f1 renames fabric folder into fabric_installer 2024-02-15 21:42:28 -03:00
agu3rra
f0255d2d6e Merge branch 'main' into single.poetry 2024-02-15 21:23:30 -03:00
Daniel Miessler
58e6e277a6 Updated vm. 2024-02-14 21:34:21 -08:00
Daniel Miessler
88332c45b0 Updated to add better docs. 2024-02-14 21:29:32 -08:00
Daniel Miessler
e011ecbf13 Updated vm. 2024-02-14 21:24:26 -08:00
Daniel Miessler
3140ca0bac Added /helpers/vm which downloads youtube transcripts and accurate durations of videos using your own YouTube API key. 2024-02-14 21:21:20 -08:00
Daniel Miessler
225e5031bf Updated rate_value. 2024-02-14 14:42:37 -08:00
Daniel Miessler
99128a9ac5 Updated rate_value. 2024-02-14 14:38:54 -08:00
Daniel Miessler
9bbfa6105b Updated rate_value. 2024-02-14 14:35:46 -08:00
Daniel Miessler
f88a3cd112 Updated rate_value. 2024-02-14 14:33:32 -08:00
Daniel Miessler
09bf9d56ba Updated rate_value. 2024-02-14 14:29:07 -08:00
Daniel Miessler
adb391628e Updated rate_value. 2024-02-14 14:27:51 -08:00
Daniel Miessler
c205e3afa7 Updated rate_value. 2024-02-14 14:23:47 -08:00
Daniel Miessler
bb08ec5ce3 Updated rate_value. 2024-02-14 14:18:25 -08:00
Daniel Miessler
dbc8077e64 Updated rate_value. 2024-02-14 14:16:20 -08:00
Daniel Miessler
a42a4d7098 Updated rate_value. 2024-02-14 14:10:42 -08:00
Daniel Miessler
a5bfccdc50 Updated rate_value. 2024-02-14 14:08:54 -08:00
Daniel Miessler
08887de5bb Updated rate_value. 2024-02-14 14:02:03 -08:00
Daniel Miessler
959987165f Updated main readme. 2024-02-14 13:20:21 -08:00
Daniel Miessler
3a4b22bffb Updated rate_value. 2024-02-14 13:15:56 -08:00
Daniel Miessler
36fd6c632f Updated rate_value with credits in the README.md. 2024-02-14 10:46:44 -08:00
Daniel Miessler
000acfd59b Updated rate_value. 2024-02-14 10:43:28 -08:00
Daniel Miessler
aa26deef73 New value rating pattern. 2024-02-14 10:38:07 -08:00
Daniel Miessler
5a928525f3 Updated analyze_prose_json. 2024-02-14 07:35:39 -08:00
Daniel Miessler
f8b2f3aab9 Updated analyze_prose_json. 2024-02-14 07:33:21 -08:00
Christopher Oak
47fdfcec1a Add 2 patterns
Added 1 pattern (improve_writing) which improve the writing and returns it in the native language of the input

Added 1 pattern (analyze_incident) which analyses incident articles and produces a neat and simple output (Taken from the YT Video that Daniel was in by David B
2024-02-14 15:23:17 +01:00
Daniel Miessler
f22c20a540 Added Joseph Thacker to the credits. 2024-02-13 10:21:39 -08:00
Daniel Miessler
fcedd34fa1 Added Jason Haddix to the credits. 2024-02-13 10:17:45 -08:00
agu3rra
bd913c626b conflicts solved 2024-02-13 10:11:33 -03:00
agu3rra
4be6ed9386 merging upstream main and solving conflict 2024-02-13 10:06:54 -03:00
Daniel Miessler
42d9a191b7 Merge pull request #95 from sleeper/patch-1
Update system.md
2024-02-12 17:59:08 -08:00
Daniel Miessler
8503a24dd5 Merge pull request #91 from dfinke/main
Add patterns
2024-02-12 17:57:52 -08:00
Daniel Miessler
203a8f32ed Merge pull request #92 from DuckPaddle/patch-6
Update utils.py to get_cli_input Line 192
2024-02-12 17:55:00 -08:00
Daniel Miessler
ee83a11ae9 Merge pull request #96 from ayberkydn/patch-1
fix typo
2024-02-12 17:54:11 -08:00
Ayberk Aydın
4a69177929 fix typo 2024-02-13 00:17:44 +03:00
Frederick Ros
f3137ed7ff Update system.md
Fixed a typo
2024-02-12 15:13:38 +01:00
jad2121
1946751684 small fix for a problem where the GUI was loading every pattern twice 2024-02-12 06:56:47 -05:00
George Mallard
e998099024 Update utils.py to get_cli_input Line 192
Changed sys.stdin.readline().strip() to sys.stdin.read().strip() to allow multiple line input.
2024-02-12 05:20:39 -06:00
agu3rra
747324266a readded the client folder to the structure 2024-02-12 07:57:55 -03:00
dfinke
f011aee14c Add compare and contrast system and user patterns 2024-02-12 05:52:58 -05:00
dfinke
b1df61fc3f Add user story and acceptance criteria for agility story patterns 2024-02-12 05:52:54 -05:00
Daniel Miessler
308982f62d Shortened summary sentences. 2024-02-12 01:05:06 -08:00
Daniel Miessler
554a3604df Add client dir. 2024-02-11 23:31:08 -08:00
Daniel Miessler
afd8ac986d Added installation note. 2024-02-11 23:20:39 -08:00
Daniel Miessler
617cde5e1c Added video embed. 2024-02-11 23:13:21 -08:00
Daniel Miessler
75f154593e Merge pull request #90 from lmccay/main
#86 Clarify README Instructions
2024-02-11 23:01:57 -08:00
lmccay
a2044d6920 Merge branch 'danielmiessler:main' into main 2024-02-11 23:27:02 -05:00
lmccay
3313543437 Merge pull request #1 from lmccay/lmccay-patch-1
#86 Update README.md
2024-02-11 23:25:49 -05:00
lmccay
1e68a0e065 Update README.md
#86 Clarify the Instructions in the README
2024-02-11 23:24:49 -05:00
agu3rra
90fdd2a313 redirects redundant instruction on CLI to main readme 2024-02-11 22:08:52 -03:00
agu3rra
041ae024db single poetry project; script to create aliases in bash and zsh; updates readme 2024-02-11 22:07:09 -03:00
Daniel Miessler
b2cf0a12de Merge pull request #84 from lmccay/patch-1
Update README.md
2024-02-11 10:53:15 -08:00
xssdoctor
b425b12939 Update utils.py
fixed something else
2024-02-11 13:36:36 -05:00
xssdoctor
4c09fa3769 Update fabric.py
fixed an error
2024-02-11 13:32:52 -05:00
Daniel Miessler
a8dc3f5432 Merge pull request #80 from agu3rra/poetry.on.server
poetry dependency management for server app + instructions
2024-02-11 10:17:40 -08:00
Daniel Miessler
470ac6827d Merge pull request #83 from DuckPaddle/patch-5
Update utils.py with a class to transcribe YouTube Videos
2024-02-11 10:17:22 -08:00
jad2121
67719f42a3 fixed something 2024-02-11 13:07:46 -05:00
jad2121
0a33ac70b9 fixed something 2024-02-11 13:06:36 -05:00
lmccay
0b9017ccd2 Update README.md
Clarified a line in the readme
2024-02-11 12:59:15 -05:00
George Mallard
e0683024c1 Update utils.py with a class to transcribe YouTube Videos
Added Class Transcribe with method youtube which accepts a video id as a parameter.  Returns the transcript.
2024-02-11 11:13:20 -06:00
jad2121
f4f337d699 updated gui to include adding API key and updating patterns 2024-02-11 11:52:20 -05:00
agu3rra
1971f4832d adds meta back 2024-02-11 10:54:47 -03:00
agu3rra
b00d3d286d pushes readme updates 2024-02-11 10:53:48 -03:00
agu3rra
14d4f8c169 poetry for server app; readme instructions added 2024-02-11 10:46:16 -03:00
Daniel Miessler
b000264ae5 Merge pull request #70 from DuckPaddle/patch-2 2024-02-10 19:55:24 -08:00
Daniel Miessler
a46cb3aacd Merge pull request #74 from dheerapat/path-pattern-mapping 2024-02-10 19:53:51 -08:00
Daniel Miessler
c690c3a990 Merge pull request #75 from Endogen/main 2024-02-10 19:53:21 -08:00
Endogen
7d7f02e0af Fix steps to install 2024-02-10 21:19:31 +01:00
jad2121
5e7d9b91ed added copy to clipboard 2024-02-10 14:59:39 -05:00
jad2121
8b28b79b9f added drag and drop and updated UI 2024-02-10 12:31:31 -05:00
Dheerapat Tookkane
82bf1fb27a chore: typo 2024-02-10 23:53:14 +07:00
Dheerapat Tookkane
31c501cb64 feat: mapping path and pattern in the dictionary, allowing to scale the pattern "The Mill" server can use easily 2024-02-10 23:42:50 +07:00
Daniel Miessler
10b39ade6d Updated the readme with credit to Jonathan Dunn for the GUI client. 2024-02-10 08:17:34 -08:00
George Mallard
7ce6d7102f Update fabric.py to work with standalone.get_cli_input()
For compatibility with Visual Studio Community Edition
2024-02-10 07:08:55 -06:00
George Mallard
8fad5a12a0 Update utils.py - This is a utility function standalone.get_cli_input()
This function adds compatibility to Visual Studio Community edition.
2024-02-10 07:05:52 -06:00
Daniel Miessler
649e77e2c4 Merge pull request #65 from agu3rra/poetry.dep.man.fabric.cli
Poetry dependency management & `fabric` as a CLI (without python fabric.py)
2024-02-09 15:50:50 -08:00
Jonathan Dunn
5a57e814b9 fixed the README 2024-02-09 14:11:00 -05:00
Jonathan Dunn
e8590b6803 changed name of web_frontend to gui as this is a standalone electron app 2024-02-09 14:07:49 -05:00
Jonathan Dunn
9469834aa4 Added a web frontend-electron app 2024-02-09 14:06:14 -05:00
agu3rra
688886451f fabric as a CLI; poetry for dep management with latest versions; gitignore re-added 2024-02-09 09:52:07 -03:00
Daniel Miessler
45c6c3364d . 2024-02-08 22:17:53 -08:00
Daniel Miessler
79c02f0615 . 2024-02-08 22:15:52 -08:00
Daniel Miessler
e63fb8436e . 2024-02-08 22:15:05 -08:00
Daniel Miessler
12fe345e4e Broke analyze_prose into Markdown and JSON versions. 2024-02-08 22:13:09 -08:00
Daniel Miessler
8722e3387d . 2024-02-08 22:05:29 -08:00
Daniel Miessler
10f7f74989 . 2024-02-08 22:03:50 -08:00
Daniel Miessler
5d25b28374 Updates to analyze_prose. 2024-02-08 21:59:03 -08:00
Daniel Miessler
75ea530e84 . 2024-02-08 21:50:06 -08:00
Daniel Miessler
7b62c532e0 . 2024-02-08 21:44:35 -08:00
Daniel Miessler
4046f86fa4 . 2024-02-08 21:42:42 -08:00
Daniel Miessler
f42c12b9fa . 2024-02-08 21:37:00 -08:00
Daniel Miessler
4f1199d562 . 2024-02-08 21:34:49 -08:00
Daniel Miessler
aa7e9067e0 . 2024-02-08 21:33:56 -08:00
Daniel Miessler
23aae517b4 . 2024-02-08 21:28:17 -08:00
Daniel Miessler
2b352afa77 . 2024-02-08 21:26:02 -08:00
Daniel Miessler
5f87728f45 . 2024-02-08 21:23:52 -08:00
Daniel Miessler
b4400e2cd3 . 2024-02-08 21:21:06 -08:00
Daniel Miessler
619f2af31f . 2024-02-08 21:19:25 -08:00
Daniel Miessler
262c3311ab . 2024-02-08 21:17:36 -08:00
Daniel Miessler
dad5a692ea . 2024-02-08 21:15:28 -08:00
Daniel Miessler
a08115c064 . 2024-02-08 21:12:16 -08:00
Daniel Miessler
72fa122969 . 2024-02-08 21:10:27 -08:00
Daniel Miessler
093c381696 . 2024-02-08 21:06:26 -08:00
Daniel Miessler
6911a7b5b3 . 2024-02-08 21:02:28 -08:00
Daniel Miessler
a7f414709e . 2024-02-08 20:58:09 -08:00
Daniel Miessler
d8759851ee . 2024-02-08 20:54:34 -08:00
Daniel Miessler
6f30ba21b4 . 2024-02-08 20:52:10 -08:00
Daniel Miessler
e25250c295 . 2024-02-08 20:44:53 -08:00
Daniel Miessler
3a15f21427 . 2024-02-08 20:42:53 -08:00
Daniel Miessler
970d5b5007 . 2024-02-08 20:40:58 -08:00
Daniel Miessler
19251530e2 . 2024-02-08 20:34:34 -08:00
Daniel Miessler
8b57d3e098 . 2024-02-08 20:32:30 -08:00
Daniel Miessler
f790a8d607 . 2024-02-08 20:23:26 -08:00
Daniel Miessler
1e5a3ca73f . 2024-02-08 13:54:56 -08:00
Daniel Miessler
56fdb76ec7 . 2024-02-08 13:52:25 -08:00
Daniel Miessler
592eeba7ad . 2024-02-08 13:50:27 -08:00
Daniel Miessler
d2828954a3 AP. 2024-02-08 13:47:20 -08:00
Daniel Miessler
06fd14553b AP. 2024-02-08 13:45:00 -08:00
Daniel Miessler
209e19dde4 AP. 2024-02-08 13:40:42 -08:00
Daniel Miessler
4acce7b85e AP. 2024-02-08 13:36:28 -08:00
Daniel Miessler
a8ecfced8c AP. 2024-02-08 13:34:47 -08:00
Daniel Miessler
a77472a259 AP. 2024-02-08 13:29:37 -08:00
Daniel Miessler
4c5aa76ed5 AP. 2024-02-08 13:23:52 -08:00
Daniel Miessler
672f9a8845 AP. 2024-02-08 13:21:56 -08:00
Daniel Miessler
455cac4079 AP. 2024-02-08 13:19:07 -08:00
Daniel Miessler
53359b4ccc AP. 2024-02-08 13:16:34 -08:00
Daniel Miessler
97b4f86018 Prose analysis upgrade. 2024-02-08 13:13:40 -08:00
Daniel Miessler
3130d23c6c analyze_prose 2024-02-08 13:10:51 -08:00
Daniel Miessler
295ae32e3a Upgrades to analyze_prose. 2024-02-08 13:08:51 -08:00
Daniel Miessler
f5a1b5ba36 Upgrades to analyze_prose. 2024-02-08 13:06:35 -08:00
Daniel Miessler
9998f4296c Upgrades to analyze_prose. 2024-02-08 13:02:26 -08:00
Daniel Miessler
1415aad69e Updated analyze_prose. 2024-02-08 12:59:17 -08:00
Daniel Miessler
ddfe247bce Unscrewed the repo. 2024-02-08 12:54:42 -08:00
Daniel Miessler
04a45303d7 AP. 2024-02-08 12:50:34 -08:00
Daniel Miessler
af5664ec48 Fixed dupes. 2024-02-08 12:48:43 -08:00
Daniel Miessler
94dc32a590 Upgrades to analyze_prose. 2024-02-08 12:42:22 -08:00
Daniel Miessler
2a5b9d3a95 Made analyze_prose more stringent. 2024-02-08 12:34:28 -08:00
Daniel Miessler
dbddad61e2 Added analyze_prose. 2024-02-08 12:28:48 -08:00
xssdoctor
ef5dd0118e Merge pull request #36 from u66u/main
use jwt auth
2024-02-08 15:02:12 -05:00
Daniel Miessler
0f97e619cc Merge pull request #61 from jkogara/jkogara/typos_and_gitignore
Fix some typos and updates gitignore
2024-02-08 11:29:13 -08:00
Daniel Miessler
c222d7a220 Merge pull request #43 from Gilgamesh555/cli-model-version
CLI Model - ModelList New Args
2024-02-08 11:26:13 -08:00
Daniel Miessler
4abfb46b2c Merge pull request #51 from kkrusher/polish_readme
Correct the configuration to define alias in the shell
2024-02-08 11:24:29 -08:00
John O'Gara
d0bb802339 Fix some typos and updates gitignore 2024-02-08 19:24:17 +00:00
Daniel Miessler
4488a9c4f9 Merge pull request #53 from TonyCardillo/patch-1
Update system.md to use consistent formatting
2024-02-08 11:22:03 -08:00
Daniel Miessler
5013d7753a Merge pull request #55 from agu3rra/explain.docs.missing.word
added missing word to prompt instruction
2024-02-08 11:19:43 -08:00
Daniel Miessler
5a7d3dc6ec Adds more comments to the code.
[Snorkell.ai] Please review the generated documentation
2024-02-08 11:01:27 -08:00
Suman Saurabh
1bcbe56d06 Merge pull request #1 from Snorkell-ai/snorkell_ai/auto_doc_2024-02-07-21-44
[Snorkell.ai] Please review the generated documentation
2024-02-08 20:47:44 +05:30
Daniel Miessler
8a2e81cde2 EW. 2024-02-07 17:07:05 -08:00
Daniel Miessler
1cd52b7ddf EW. 2024-02-07 17:01:37 -08:00
Daniel Miessler
947ed041b2 EW. 2024-02-07 16:58:39 -08:00
Daniel Miessler
fab45892b1 EW. 2024-02-07 16:54:21 -08:00
Daniel Miessler
73f7c3c11b EW. 2024-02-07 16:51:10 -08:00
Daniel Miessler
10a49b24c9 EW tweak. 2024-02-07 16:50:22 -08:00
Daniel Miessler
02697b33a6 Tweak to extwis again. 2024-02-07 16:45:55 -08:00
Daniel Miessler
dfcd188cd6 Slight tweak. 2024-02-07 16:39:29 -08:00
Daniel Miessler
b8cf16f69c Slight tweak to extract_wisdom. 2024-02-07 16:35:41 -08:00
Daniel Miessler
9acddb1567 Updated extract_wisdom with tiny tweaks.. 2024-02-07 16:19:55 -08:00
Daniel Miessler
d3a24ec083 Updated extract_wisdom with insight and surprise. 2024-02-07 16:09:30 -08:00
Daniel Miessler
e85f5c449d Reverted label_and_rate. 2024-02-07 16:04:37 -08:00
Daniel Miessler
e0f1fa9e4e Updated label and rate. 2024-02-07 15:59:13 -08:00
Daniel Miessler
729462d082 Removed helpers for now. 2024-02-07 15:47:38 -08:00
Daniel Miessler
77b77f562d Added a pattern and a new helper directory. 2024-02-07 15:02:16 -08:00
snorkell-ai[bot]
6061549fff test commit 2024-02-07 21:44:35 +00:00
Daniel Miessler
aeb3457a4f Fixed some typos. 2024-02-07 11:35:57 -08:00
Daniel Miessler
3a004440f7 Removed an extra print statement, thanks to @rez0. 2024-02-07 11:14:54 -08:00
Andre Guerra
b5f9ac97c1 added missing word to prompt instruction 2024-02-07 13:49:04 -03:00
Tony Cardillo MD
d71c9ddb71 Update system.md
Fixed Markdown mismatches and added H1 headers to Steps and Output to make more consistent with other patterns
2024-02-07 10:09:55 -05:00
kkrusher
86d5738c97 Correct the configuration to define alias in the shell 2024-02-07 21:51:43 +08:00
Daniel Miessler
416c7d9a27 Added a one-sentence summary to label_and_rate. 2024-02-06 14:23:55 -08:00
Gilgamesh555
5657eb4bf2 update model list to api dynamic response based on user key 2024-02-06 14:37:15 -04:00
Daniel Miessler
cf928e631f Updated PR pattern. 2024-02-06 09:43:17 -08:00
Daniel Miessler
eed5875e72 Added summarize PRs. 2024-02-06 09:37:28 -08:00
Daniel Miessler
881f74db97 Create FUNDING.yml 2024-02-06 09:13:26 -08:00
Gilgamesh555
a01a7b4cd3 Merge branch 'main' into cli-model-version 2024-02-06 09:16:05 -04:00
Gilgamesh555
086cfbc239 add model and list-model to args 2024-02-06 09:09:39 -04:00
technicca
0dd7d1dc9d use jwt auth 2024-02-05 05:37:00 +03:00
95 changed files with 5952 additions and 591 deletions

37
.github/ISSUE_TEMPLATE/bug.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Bug Report
description: File a bug report.
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "I was doing THIS, when THAT happened. I was expecting THAT_OTHER_THING to happen instead."
validations:
required: true
- type: checkboxes
id: version
attributes:
label: Version check
description: Please make sure you were using the latest version of this project available in the `main` branch.
options:
- label: Yes I was.
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: textarea
id: screens
attributes:
label: Relevant screenshots (optional)
description: Please upload any screenshots that may help us reproduce and/or understand the issue.

View File

@@ -0,0 +1,13 @@
name: Feature Request
description: Suggest features for this project.
title: "[Feature request]: "
labels: ["enhancement"]
body:
- type: textarea
id: description
attributes:
label: What do you need?
description: Tell us what functionality you would like added/modified?
value: "I want the CLI to do my homework for me."
validations:
required: true

12
.github/ISSUE_TEMPLATE/question.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Question
description: Ask us questions about this project.
title: "[Question]: "
labels: ["question"]
body:
- type: textarea
id: description
attributes:
label: What is your question?
value: "After reading the documentation, I am still not clear how to get X working. I tried this, this, and that."
validations:
required: true

9
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,9 @@
## What this Pull Request (PR) does
Please briefly describe what this PR does.
## Related issues
Please reference any open issues this PR relates to in here.
If it closes an issue, type `closes #[ISSUE_NUMBER]`.
## Screenshots
Provide any screenshots you may find relevant to facilitate us understanding your PR.

10
.gitignore vendored
View File

@@ -1,13 +1,11 @@
# Source https://github.com/github/gitignore/blob/main/Python.gitignore
# macOS local stores
.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Virtual Environments
client/source/
client/.zshrc
# C extensions
*.so
@@ -126,8 +124,8 @@ celerybeat.pid
# Environments
.env
.venv
env/
.venv/
venv/
ENV/
env.bak/

View File

@@ -31,8 +31,10 @@
- [Too many prompts](#too-many-prompts)
- [The Fabric approach to prompting](#our-approach-to-prompting)
- [Quickstart](#quickstart)
- [1. Just use the Patterns (Prompts)](#just-use-the-patterns)
- [2. Create your own Fabric Mill (Server)](#create-your-own-fabric-mill)
- [Setting up the fabric commands](#setting-up-the-fabric-commands)
- [Using the fabric client](#using-the-fabric-client)
- [Just use the Patterns](#just-use-the-patterns)
- [Create your own Fabric Mill](#create-your-own-fabric-mill)
- [Structure](#structure)
- [Components](#components)
- [CLI-native](#cli-native)
@@ -43,11 +45,18 @@
<br />
> [!NOTE]
> February 16, 2024 — **It's now far easier to install and use Fabric!** Just head to the [Quickstart](#quickstart), install Poetry, and run `setup.sh`, and it'll do all the work for you!
<br />
```bash
# A quick demonstration of writing an essay with Fabric
```
https://github.com/danielmiessler/fabric/assets/50654/09c11764-e6ba-4709-952d-450d70d76ac9
<video src="https://github.com/danielmiessler/fabric/assets/50654/09c11764-e6ba-4709-952d-450d70d76ac9" controls>
Your browser does not support the video tag.
</video>
## What and why
@@ -87,7 +96,7 @@ Fabric has Patterns for all sorts of life and work activities, including:
- Getting summaries of long, boring content
- Explaining code to you
- Turning bad documentation into usable documentation
- Create social media posts from any content input
- Creating social media posts from any content input
- And a million more…
### Our approach to prompting
@@ -112,11 +121,11 @@ https://github.com/danielmiessler/fabric/blob/main/patterns/extract_wisdom/syste
The most feature-rich way to use Fabric is to use the `fabric` client, which can be found under <a href="https://github.com/danielmiessler/fabric/tree/main/client">`/client`</a> directory in this repository.
### Setting up the `fabric` client
### Setting up the fabric commands
Follow these steps to get the client installed and configured.
Follow these steps to get all fabric related apps installed and configured.
1. Navigate to where you want the Fabric project to live on your systemClone the directory to a semi-permanent place on your computer.
1. Navigate to where you want the Fabric project to live on your system in a semi-permanent place on your computer.
```bash
# Find a home for Fabric
@@ -127,41 +136,59 @@ cd /where/you/keep/code
```bash
# Clone Fabric to your computer
git clone git@github.com:danielmiessler/fabric.git
git clone https://github.com/danielmiessler/fabric.git
```
3. Enter Fabric's /client directory
3. Enter Fabric's main directory
```bash
# Enter the project and its /client folder
cd fabric/client
# Enter the project folder (where you cloned it)
cd fabric
```
4. Install the dependencies
4. Ensure the `setup.sh` script is executable. If you're not sure, you can make it executable by running the following command:
```bash
# Install the pre-requisites
pip3 install -r requirements.txt
chmod +x setup.sh
```
5. Add the path to the `fabric` client to your shell
5. Install poetry
ref.: https://python-poetry.org/docs/#installing-with-the-official-installer
```bash
# Tell your shell how to find the `fabric` client
echo 'alias fabric="/the/path/to/fabric/client" >> .bashrc'
# Example of ~/.zshrc or ~/.bashrc
alias fabric="~/Development/fabric/client/fabric"
curl -sSL https://install.python-poetry.org | python3 -
```
6. Restart your shell
6. Run the `setup.sh`, which will do the following:
- Installs python dependencies.
- Creates aliases in your OS. It should update `~/.bashrc`, `/.zshrc`, and `~/.bash_profile` if they are present in your file system.
```bash
# Make sure you can
echo 'alias fabric="/the/path/to/fabric/client" >> .bashrc'
# Example
echo 'alias fabric="~/Development/fabric/client/fabric" >> .zshrc'
./setup.sh
```
7. Restart your shell to reload everything.
8. Set your `OPENAI_API_KEY`.
```bash
fabric --setup
```
You'll be asked to enter your OpenAI API key, which will be written to `~/.config/fabric/.env`. Patterns will then be downloaded from Github, which will take a few moments.
9. Now you are up and running! You can test by pulling the help.
```bash
# Making sure the paths are set up correctly
fabric --help
```
> [!NOTE]
> If you're using the `server` functions, `fabric-api` and `fabric-webui` need to be run in distinct terminal windows.
### Using the `fabric` client
Once you have it all set up, here's how to use it.
@@ -191,14 +218,6 @@ options:
--setup Set up your fabric instance
```
2. Set up the client
```bash
fabric --setup
```
You'll be asked to enter your OpenAI API key, which will be written to `~/.config/fabric/.env`. Patterns will then be downloaded from Github, which will take a few moments.
#### Example commands
The client, by default, runs Fabric patterns without needing a server (the Patterns were downloaded during setup). This means the client connects directly to OpenAI using the input given and the Fabric pattern used.
@@ -215,6 +234,12 @@ pbpaste | fabric --pattern summarize
pbpaste | fabric --stream --pattern analyze_claims
```
3. **new** All of the patterns have been added as aliases to your bash (or zsh) config file
```bash
pbpaste | analyze_claims --stream
```
> [!NOTE]
> More examples coming in the next few days, including a demo video!
@@ -417,12 +442,17 @@ The content features a conversation between two individuals discussing various t
- _Caleb Sima_ for pushing me over the edge of whether to make this a public project or not.
- _Joel Parish_ for super useful input on the project's Github directory structure.
- _Jonathan Dunn_ for spectacular work on the soon-to-be-released universal client.
- _Joseph Thacker_ for the idea of a `-c` context flag that adds pre-created context in the `./config/fabric/` directory to all Pattern queries.
- _Jason Haddix_ for the idea of a stitch (chained Pattern) to filter content using a local model before sending on to a cloud model, i.e., cleaning customer data using `llama2` before sending on to `gpt-4` for analysis.
- _Dani Goland_ for enhancing the Fabric Server (Mill) infrastructure by migrating to FastAPI, breaking the server into discrete pieces, and Dockerizing the entire thing.
- _Andre Guerra_ for simplifying installation by getting us onto Poetry for virtual environment and dependency management.
### Primary contributors
<a href="https://github.com/danielmiessler"><img src="https://avatars.githubusercontent.com/u/50654?v=4" title="Daniel Miessler" width="50" height="50"></a>
<a href="https://github.com/xssdoctor"><img src="https://avatars.githubusercontent.com/u/9218431?v=4" title="Jonathan Dunn" width="50" height="50"></a>
<a href="https://github.com/sbehrens"><img src="https://avatars.githubusercontent.com/u/688589?v=4" title="Scott Behrens" width="50" height="50"></a>
<a href="https://github.com/agu3rra"><img src="https://avatars.githubusercontent.com/u/10410523?v=4" title="Andre Guerra" width="50" height="50"></a>
`fabric` was created by <a href="https://danielmiessler.com/subscribe" target="_blank">Daniel Miessler</a> in January of 2024.
<br /><br />

View File

@@ -1,17 +0,0 @@
pyyaml
requests
pyperclip
python-socketio
websocket-client
flask
flask_sqlalchemy
flask_login
flask_jwt_extended
python-dotenv
openai
flask-socketio
flask-sock
gunicorn
gevent
httpx
tqdm

View File

@@ -1,207 +0,0 @@
import requests
import os
from openai import OpenAI
import pyperclip
import sys
from dotenv import load_dotenv
from requests.exceptions import HTTPError
from tqdm import tqdm
current_directory = os.path.dirname(os.path.realpath(__file__))
config_directory = os.path.expanduser("~/.config/fabric")
env_file = os.path.join(config_directory, ".env")
class Standalone:
def __init__(self, args, pattern="", env_file="~/.config/fabric/.env"):
# Expand the tilde to the full path
env_file = os.path.expanduser(env_file)
load_dotenv(env_file)
try:
apikey = os.environ["OPENAI_API_KEY"]
self.client = OpenAI()
self.client.api_key = apikey
except KeyError:
print("OPENAI_API_KEY not found in environment variables.")
except FileNotFoundError:
print("No API key found. Use the --apikey option to set the key")
sys.exit()
self.config_pattern_directory = config_directory
self.pattern = pattern
self.args = args
def streamMessage(self, input_data: str):
wisdomFilePath = os.path.join(
config_directory, f"patterns/{self.pattern}/system.md"
)
user_message = {"role": "user", "content": f"{input_data}"}
wisdom_File = os.path.join(current_directory, wisdomFilePath)
buffer = ""
if self.pattern:
try:
with open(wisdom_File, "r") as f:
system = f.read()
system_message = {"role": "system", "content": system}
messages = [system_message, user_message]
except FileNotFoundError:
print("pattern not found")
return
else:
messages = [user_message]
try:
stream = self.client.chat.completions.create(
model="gpt-4-turbo-preview",
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
char = chunk.choices[0].delta.content
buffer += char
if char not in ["\n", " "]:
print(char, end="")
elif char == " ":
print(" ", end="") # Explicitly handle spaces
elif char == "\n":
print() # Handle newlines
sys.stdout.flush()
except Exception as e:
print(f"Error: {e}")
print(e)
if self.args.copy:
pyperclip.copy(buffer)
if self.args.output:
with open(self.args.output, "w") as f:
f.write(buffer)
def sendMessage(self, input_data: str):
wisdomFilePath = os.path.join(
config_directory, f"patterns/{self.pattern}/system.md"
)
user_message = {"role": "user", "content": f"{input_data}"}
wisdom_File = os.path.join(current_directory, wisdomFilePath)
if self.pattern:
try:
with open(wisdom_File, "r") as f:
system = f.read()
system_message = {"role": "system", "content": system}
messages = [system_message, user_message]
except FileNotFoundError:
print("pattern not found")
return
else:
messages = [user_message]
try:
response = self.client.chat.completions.create(
model="gpt-4-turbo-preview",
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
)
print(response)
print(response.choices[0].message.content)
except Exception as e:
print(f"Error: {e}")
print(e)
if self.args.copy:
pyperclip.copy(response.choices[0].message.content)
if self.args.output:
with open(self.args.output, "w") as f:
f.write(response.choices[0].message.content)
class Update:
def __init__(self):
self.root_api_url = "https://api.github.com/repos/danielmiessler/fabric/contents/patterns?ref=main"
self.config_directory = os.path.expanduser("~/.config/fabric")
self.pattern_directory = os.path.join(self.config_directory, "patterns")
os.makedirs(self.pattern_directory, exist_ok=True)
self.update_patterns() # Call the update process from a method.
def update_patterns(self):
try:
self.progress_bar = tqdm(desc="Downloading Patterns…", unit="file")
self.get_github_directory_contents(
self.root_api_url, self.pattern_directory
)
# Close progress bar on success before printing the message.
self.progress_bar.close()
except HTTPError as e:
# Ensure progress bar is closed on HTTPError as well.
self.progress_bar.close()
if e.response.status_code == 403:
print(
"GitHub API rate limit exceeded. Please wait before trying again."
)
sys.exit()
else:
print(f"Failed to download patterns due to an HTTP error: {e}")
sys.exit() # Exit after handling the error.
def download_file(self, url, local_path):
try:
response = requests.get(url)
response.raise_for_status()
with open(local_path, "wb") as f:
f.write(response.content)
self.progress_bar.update(1)
except HTTPError as e:
print(f"Failed to download file {url}. HTTP error: {e}")
sys.exit()
def process_item(self, item, local_dir):
if item["type"] == "file":
self.download_file(
item["download_url"], os.path.join(local_dir, item["name"])
)
elif item["type"] == "dir":
new_dir = os.path.join(local_dir, item["name"])
os.makedirs(new_dir, exist_ok=True)
self.get_github_directory_contents(item["url"], new_dir)
def get_github_directory_contents(self, api_url, local_dir):
try:
response = requests.get(api_url)
response.raise_for_status()
jsonList = response.json()
for item in jsonList:
self.process_item(item, local_dir)
except HTTPError as e:
if e.response.status_code == 403:
print(
"GitHub API rate limit exceeded. Please wait before trying again."
)
self.progress_bar.close() # Ensure the progress bar is cleaned up properly
else:
print(f"Failed to fetch directory contents due to an HTTP error: {e}")
class Setup:
def __init__(self):
self.config_directory = os.path.expanduser("~/.config/fabric")
self.pattern_directory = os.path.join(self.config_directory, "patterns")
os.makedirs(self.pattern_directory, exist_ok=True)
self.env_file = os.path.join(self.config_directory, ".env")
def api_key(self, api_key):
if not os.path.exists(self.env_file):
with open(self.env_file, "w") as f:
f.write(f"OPENAI_API_KEY={api_key}")
print(f"OpenAI API key set to {api_key}")
def patterns(self):
Update()
sys.exit()
def run(self):
print("Welcome to Fabric. Let's get started.")
apikey = input("Please enter your OpenAI API key\n")
self.api_key(apikey.strip())
self.patterns()

86
helpers/vm Executable file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/env python3
import sys
import re
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from youtube_transcript_api import YouTubeTranscriptApi
from dotenv import load_dotenv
import os
import json
import isodate
import argparse
def get_video_id(url):
# Extract video ID from URL
pattern = r'(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})'
match = re.search(pattern, url)
return match.group(1) if match else None
def main(url, options):
# Load environment variables from .env file
load_dotenv(os.path.expanduser('~/.config/fabric/.env'))
# Get YouTube API key from environment variable
api_key = os.getenv('YOUTUBE_API_KEY')
if not api_key:
print("Error: YOUTUBE_API_KEY not found in ~/.config/fabric/.env")
return
# Extract video ID from URL
video_id = get_video_id(url)
if not video_id:
print("Invalid YouTube URL")
return
try:
# Initialize the YouTube API client
youtube = build('youtube', 'v3', developerKey=api_key)
# Get video details
video_response = youtube.videos().list(
id=video_id,
part='contentDetails'
).execute()
# Extract video duration and convert to minutes
duration_iso = video_response['items'][0]['contentDetails']['duration']
duration_seconds = isodate.parse_duration(duration_iso).total_seconds()
duration_minutes = round(duration_seconds / 60)
# Get video transcript
try:
transcript_list = YouTubeTranscriptApi.get_transcript(video_id)
transcript_text = ' '.join([item['text'] for item in transcript_list])
transcript_text = transcript_text.replace('\n', ' ')
except Exception as e:
transcript_text = "Transcript not available."
# Output based on options
if options.duration:
print(duration_minutes)
elif options.transcript:
print(transcript_text)
else:
# Create JSON object
output = {
"transcript": transcript_text,
"duration": duration_minutes
}
# Print JSON object
print(json.dumps(output))
except HttpError as e:
print("Error: Failed to access YouTube API. Please check your YOUTUBE_API_KEY and ensure it is valid.")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='vm (video meta) extracts metadata about a video, such as the transcript and the video\'s duration. By Daniel Miessler.')
parser.add_argument('url', nargs='?', help='YouTube video URL')
parser.add_argument('--duration', action='store_true', help='Output only the duration')
parser.add_argument('--transcript', action='store_true', help='Output only the transcript')
args = parser.parse_args()
if args.url:
main(args.url, args)
else:
parser.print_help()

5
installer/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from .client.cli import main as cli
from .server import (
run_api_server,
run_webui_server,
)

View File

@@ -20,31 +20,20 @@ You can use the client in three different modes:
## Installation
1. If you have this repository downloaded, you already have the client.
`git clone git@github.com:danielmiessler/fabric.git`
2. Navigate to the client's directory:
`cd client`
3. Set up a virtual environment:
`python3 -m venv .venv`
`source .venv/bin/activate`
4. Install the required packages:
`pip install -r requirements.txt`
5. Copy to path:
`echo export PATH=$PATH:$(pwd)` >> .bashrc` # or .zshrc
6. Copy your OpenAI API key to the `.env` file in your `nvim ~/.config/fabric/` directory (or create that file and put it in)
`OPENAI_API_KEY=[Your_API_Key]`
Please check our main [setting up the fabric commands](./../../../README.md#setting-up-the-fabric-commands) section.
## Usage
To use `fabric`, call it with your desired options:
To use `fabric`, call it with your desired options (remember to activate the virtual environment with `poetry shell` - step 5 above):
python fabric.py [options]
fabric [options]
Options include:
--pattern, -p: Select the module for analysis.
--stream, -s: Stream output to another application.
--output, -o: Save the response to a file.
--copy, -c: Copy the response to the clipboard.
--copy, -C: Copy the response to the clipboard.
--context, -c: Use Context file (context.md) to add context to your pattern
Example:

View File

@@ -0,0 +1 @@
from .fabric import main

View File

@@ -0,0 +1,3 @@
# Context
please give all responses in spanish

View File

@@ -1,21 +1,20 @@
#!/usr/bin/env python3
from utils import Standalone, Update, Setup
from .utils import Standalone, Update, Setup, Alias, Whisper
import argparse
import sys
import time
import os
script_directory = os.path.dirname(os.path.realpath(__file__))
if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser(
description="An open source framework for augmenting humans using AI."
)
parser.add_argument("--text", "-t", help="Text to extract summary from")
parser.add_argument(
"--copy", "-c", help="Copy the response to the clipboard", action="store_true"
"--copy", "-C", help="Copy the response to the clipboard", action="store_true"
)
parser.add_argument(
"--output",
@@ -31,35 +30,53 @@ if __name__ == "__main__":
help="Use this option if you want to see the results in realtime. NOTE: You will not be able to pipe the output into another command.",
action="store_true",
)
parser.add_argument('--transcribe', '-T',
help="transcribe audio, please enter the path to the audio file, or a url with the audio file")
parser.add_argument(
"--list", "-l", help="List available patterns", action="store_true"
)
parser.add_argument("--update", "-u", help="Update patterns", action="store_true")
parser.add_argument(
"--update", "-u", help="Update patterns", action="store_true")
parser.add_argument("--pattern", "-p", help="The pattern (prompt) to use")
parser.add_argument(
"--setup", help="Set up your fabric instance", action="store_true"
)
parser.add_argument(
"--model", "-m", help="Select the model to use (GPT-4 by default)", default="gpt-4-turbo-preview"
)
parser.add_argument(
"--listmodels", help="List all available models", action="store_true"
)
parser.add_argument('--context', '-c',
help="Use Context file (context.md) to add context to your pattern", action="store_true")
args = parser.parse_args()
home_holder = os.path.expanduser("~")
config = os.path.join(home_holder, ".config", "fabric")
config_patterns_directory = os.path.join(config, "patterns")
config_context = os.path.join(config, "context.md")
env_file = os.path.join(config, ".env")
if not os.path.exists(config):
os.makedirs(config)
if args.setup:
Setup().run()
Alias()
sys.exit()
if not os.path.exists(env_file) or not os.path.exists(config_patterns_directory):
print("Please run --setup to set up your API key and download patterns.")
sys.exit()
if not os.path.exists(config_patterns_directory):
Update()
Alias()
sys.exit()
if args.update:
Update()
print("Your Patterns have been updated.")
Alias()
sys.exit()
if args.context:
if not os.path.exists(os.path.join(config, "context.md")):
print("Please create a context.md file in ~/.config/fabric")
sys.exit()
standalone = Standalone(args, args.pattern)
if args.list:
try:
@@ -70,11 +87,30 @@ if __name__ == "__main__":
except FileNotFoundError:
print("No patterns found")
sys.exit()
if args.listmodels:
standalone.fetch_available_models()
sys.exit()
if args.transcribe:
whisper = Whisper()
whisper.process_file(args.transcribe)
sys.exit()
if args.text is not None:
text = args.text
else:
text = sys.stdin.read()
if args.stream:
text = standalone.get_cli_input()
if args.stream and not args.context:
standalone.streamMessage(text)
if args.stream and args.context:
with open(config_context, "r") as f:
context = f.read()
standalone.streamMessage(text, context=context)
elif args.context:
with open(config_context, "r") as f:
context = f.read()
standalone.sendMessage(text, context=context)
else:
standalone.sendMessage(text)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,495 @@
import requests
import os
from openai import OpenAI
import pyperclip
import sys
import platform
from dotenv import load_dotenv
from requests.exceptions import HTTPError
from tqdm import tqdm
import zipfile
import tempfile
import shutil
from pydub import AudioSegment
current_directory = os.path.dirname(os.path.realpath(__file__))
config_directory = os.path.expanduser("~/.config/fabric")
env_file = os.path.join(config_directory, ".env")
class Standalone:
def __init__(self, args, pattern="", env_file="~/.config/fabric/.env"):
""" Initialize the class with the provided arguments and environment file.
Args:
args: The arguments for initialization.
pattern: The pattern to be used (default is an empty string).
env_file: The path to the environment file (default is "~/.config/fabric/.env").
Returns:
None
Raises:
KeyError: If the "OPENAI_API_KEY" is not found in the environment variables.
FileNotFoundError: If no API key is found in the environment variables.
"""
# Expand the tilde to the full path
env_file = os.path.expanduser(env_file)
load_dotenv(env_file)
try:
apikey = os.environ["OPENAI_API_KEY"]
self.client = OpenAI()
self.client.api_key = apikey
except KeyError:
print("OPENAI_API_KEY not found in environment variables.")
except FileNotFoundError:
print("No API key found. Use the --apikey option to set the key")
sys.exit()
self.config_pattern_directory = config_directory
self.pattern = pattern
self.args = args
self.model = args.model
def streamMessage(self, input_data: str, context=""):
""" Stream a message and handle exceptions.
Args:
input_data (str): The input data for the message.
Returns:
None: If the pattern is not found.
Raises:
FileNotFoundError: If the pattern file is not found.
"""
wisdomFilePath = os.path.join(
config_directory, f"patterns/{self.pattern}/system.md"
)
user_message = {"role": "user", "content": f"{input_data}"}
wisdom_File = os.path.join(current_directory, wisdomFilePath)
buffer = ""
if self.pattern:
try:
with open(wisdom_File, "r") as f:
if context:
system = context + '\n\n' + f.read()
else:
system = f.read()
system_message = {"role": "system", "content": system}
messages = [system_message, user_message]
except FileNotFoundError:
print("pattern not found")
return
else:
if context:
user_message += {role: "system", content: context}
messages = [user_message]
else:
messages = [user_message]
try:
stream = self.client.chat.completions.create(
model=self.model,
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
char = chunk.choices[0].delta.content
buffer += char
if char not in ["\n", " "]:
print(char, end="")
elif char == " ":
print(" ", end="") # Explicitly handle spaces
elif char == "\n":
print() # Handle newlines
sys.stdout.flush()
except Exception as e:
print(f"Error: {e}")
print(e)
if self.args.copy:
pyperclip.copy(buffer)
if self.args.output:
with open(self.args.output, "w") as f:
f.write(buffer)
def sendMessage(self, input_data: str, context=""):
""" Send a message using the input data and generate a response.
Args:
input_data (str): The input data to be sent as a message.
Returns:
None
Raises:
FileNotFoundError: If the specified pattern file is not found.
"""
wisdomFilePath = os.path.join(
config_directory, f"patterns/{self.pattern}/system.md"
)
user_message = {"role": "user", "content": f"{input_data}"}
wisdom_File = os.path.join(current_directory, wisdomFilePath)
if self.pattern:
try:
with open(wisdom_File, "r") as f:
if context:
system = context + '\n\n' + f.read()
else:
system = f.read()
system_message = {"role": "system", "content": system}
messages = [system_message, user_message]
except FileNotFoundError:
print("pattern not found")
return
else:
if context:
user_message += {'role': 'system', 'content': context}
messages = [user_message]
else:
messages = [user_message]
try:
response = self.client.chat.completions.create(
model=self.model,
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
)
print(response.choices[0].message.content)
except Exception as e:
print(f"Error: {e}")
print(e)
if self.args.copy:
pyperclip.copy(response.choices[0].message.content)
if self.args.output:
with open(self.args.output, "w") as f:
f.write(response.choices[0].message.content)
def fetch_available_models(self):
headers = {
"Authorization": f"Bearer {self.client.api_key}"
}
response = requests.get(
"https://api.openai.com/v1/models", headers=headers)
if response.status_code == 200:
models = response.json().get("data", [])
# Filter only gpt models
gpt_models = [model for model in models if model.get(
"id", "").startswith(("gpt"))]
# Sort the models alphabetically by their ID
sorted_gpt_models = sorted(gpt_models, key=lambda x: x.get("id"))
for model in sorted_gpt_models:
print(model.get("id"))
else:
print(f"Failed to fetch models: HTTP {response.status_code}")
def get_cli_input(self):
""" aided by ChatGPT; uses platform library
accepts either piped input or console input
from either Windows or Linux
Args:
none
Returns:
string from either user or pipe
"""
system = platform.system()
if system == 'Windows':
if not sys.stdin.isatty(): # Check if input is being piped
return sys.stdin.read().strip() # Read piped input
else:
# Prompt user for input from console
return input("Enter Question: ")
else:
return sys.stdin.read()
class Whisper:
def __init__(self):
env_file = os.path.expanduser("~/.config/fabric/.env")
load_dotenv(env_file)
try:
apikey = os.environ["OPENAI_API_KEY"]
self.client = OpenAI()
self.client.api_key = apikey
except KeyError:
print("OPENAI_API_KEY not found in environment variables.")
except FileNotFoundError:
print("No API key found. Use the --apikey option to set the key")
self.whole_response = []
def split_audio(self, file_path):
"""
Splits the audio file into segments of the given length.
Args:
- file_path: The path to the audio file.
- segment_length_ms: Length of each segment in milliseconds.
Returns:
- A list of audio segments.
"""
audio = AudioSegment.from_file(file_path)
segments = []
segment_length_ms = 10 * 60 * 1000 # 10 minutes in milliseconds
for start_ms in range(0, len(audio), segment_length_ms):
end_ms = start_ms + segment_length_ms
segment = audio[start_ms:end_ms]
segments.append(segment)
return segments
def process_segment(self, segment):
""" Transcribe an audio file and print the transcript.
Args:
audio_file (str): The path to the audio file to be transcribed.
Returns:
None
"""
try:
# if audio_file.startswith("http"):
# response = requests.get(audio_file)
# response.raise_for_status()
# with tempfile.NamedTemporaryFile(delete=False) as f:
# f.write(response.content)
# audio_file = f.name
audio_file = open(segment, "rb")
response = self.client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)
self.whole_response.append(response.text)
except Exception as e:
print(f"Error: {e}")
def process_file(self, audio_file):
""" Transcribe an audio file and print the transcript.
Args:
audio_file (str): The path to the audio file to be transcribed.
Returns:
None
"""
try:
# if audio_file.startswith("http"):
# response = requests.get(audio_file)
# response.raise_for_status()
# with tempfile.NamedTemporaryFile(delete=False) as f:
# f.write(response.content)
# audio_file = f.name
segments = self.split_audio(audio_file)
for i, segment in enumerate(segments):
segment_file_path = f"segment_{i}.mp3"
segment.export(segment_file_path, format="mp3")
self.process_segment(segment_file_path)
print(' '.join(self.whole_response))
except Exception as e:
print(f"Error: {e}")
class Update:
def __init__(self):
"""Initialize the object with default values."""
self.repo_zip_url = "https://github.com/danielmiessler/fabric/archive/refs/heads/main.zip"
self.config_directory = os.path.expanduser("~/.config/fabric")
self.pattern_directory = os.path.join(
self.config_directory, "patterns")
os.makedirs(self.pattern_directory, exist_ok=True)
print("Updating patterns...")
self.update_patterns() # Start the update process immediately
def update_patterns(self):
"""Update the patterns by downloading the zip from GitHub and extracting it."""
with tempfile.TemporaryDirectory() as temp_dir:
zip_path = os.path.join(temp_dir, "repo.zip")
self.download_zip(self.repo_zip_url, zip_path)
extracted_folder_path = self.extract_zip(zip_path, temp_dir)
# The patterns folder will be inside "fabric-main" after extraction
patterns_source_path = os.path.join(
extracted_folder_path, "fabric-main", "patterns")
if os.path.exists(patterns_source_path):
# If the patterns directory already exists, remove it before copying over the new one
if os.path.exists(self.pattern_directory):
shutil.rmtree(self.pattern_directory)
shutil.copytree(patterns_source_path, self.pattern_directory)
print("Patterns updated successfully.")
else:
print("Patterns folder not found in the downloaded zip.")
def download_zip(self, url, save_path):
"""Download the zip file from the specified URL."""
response = requests.get(url)
response.raise_for_status() # Check if the download was successful
with open(save_path, 'wb') as f:
f.write(response.content)
print("Downloaded zip file successfully.")
def extract_zip(self, zip_path, extract_to):
"""Extract the zip file to the specified directory."""
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
print("Extracted zip file successfully.")
return extract_to # Return the path to the extracted contents
class Alias:
def __init__(self):
self.config_files = []
home_directory = os.path.expanduser("~")
self.patterns = os.path.join(home_directory, ".config/fabric/patterns")
if os.path.exists(os.path.join(home_directory, ".bashrc")):
self.config_files.append(os.path.join(home_directory, ".bashrc"))
if os.path.exists(os.path.join(home_directory, ".zshrc")):
self.config_files.append(os.path.join(home_directory, ".zshrc"))
if os.path.exists(os.path.join(home_directory, ".bash_profile")):
self.config_files.append(os.path.join(
home_directory, ".bash_profile"))
self.remove_all_patterns()
self.add_patterns()
print('Aliases added successfully. Please restart your terminal to use them.')
def add(self, name, alias):
for file in self.config_files:
with open(file, "a") as f:
f.write(f"alias {name}='{alias}'\n")
def remove(self, pattern):
for file in self.config_files:
# Read the whole file first
with open(file, "r") as f:
wholeFile = f.read()
# Determine if the line to be removed is in the file
target_line = f"alias {pattern}='fabric --pattern {pattern}'\n"
if target_line in wholeFile:
# If the line exists, replace it with nothing (remove it)
wholeFile = wholeFile.replace(target_line, "")
# Write the modified content back to the file
with open(file, "w") as f:
f.write(wholeFile)
def remove_all_patterns(self):
allPatterns = os.listdir(self.patterns)
for pattern in allPatterns:
self.remove(pattern)
def find_line(self, name):
for file in self.config_files:
with open(file, "r") as f:
lines = f.readlines()
for line in lines:
if line.strip("\n") == f"alias ${name}='{alias}'":
return line
def add_patterns(self):
allPatterns = os.listdir(self.patterns)
for pattern in allPatterns:
self.add(pattern, f"fabric --pattern {pattern}")
class Setup:
def __init__(self):
""" Initialize the object.
Raises:
OSError: If there is an error in creating the pattern directory.
"""
self.config_directory = os.path.expanduser("~/.config/fabric")
self.pattern_directory = os.path.join(
self.config_directory, "patterns")
os.makedirs(self.pattern_directory, exist_ok=True)
self.env_file = os.path.join(self.config_directory, ".env")
def api_key(self, api_key):
""" Set the OpenAI API key in the environment file.
Args:
api_key (str): The API key to be set.
Returns:
None
Raises:
OSError: If the environment file does not exist or cannot be accessed.
"""
if not os.path.exists(self.env_file):
with open(self.env_file, "w") as f:
f.write(f"OPENAI_API_KEY={api_key}")
print(f"OpenAI API key set to {api_key}")
def patterns(self):
""" Method to update patterns and exit the system.
Returns:
None
"""
Update()
def run(self):
""" Execute the Fabric program.
This method prompts the user for their OpenAI API key, sets the API key in the Fabric object, and then calls the patterns method.
Returns:
None
"""
print("Welcome to Fabric. Let's get started.")
apikey = input("Please enter your OpenAI API key\n")
self.api_key(apikey.strip())
self.patterns()
class Transcribe:
def youtube(video_id):
"""
This method gets the transciption
of a YouTube video designated with the video_id
Input:
the video id specifing a YouTube video
an example url for a video: https://www.youtube.com/watch?v=vF-MQmVxnCs&t=306s
the video id is vF-MQmVxnCs&t=306s
Output:
a transcript for the video
Raises:
an exception and prints error
"""
try:
transcript_list = YouTubeTranscriptApi.get_transcript(video_id)
transcript = ""
for segment in transcript_list:
transcript += segment['text'] + " "
return transcript.strip()
except Exception as e:
print("Error:", e)
return None

3
installer/client/gui/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules/
dist/
build/

View File

@@ -0,0 +1,21 @@
Fabric is not just a tool; it's a transformative step towards integrating the power of GPT prompts into your digital life. With Fabric, you have the ability to create a personal API that brings advanced GPT capabilities into various aspects of your digital environment. Whether you're looking to incorporate powerful GPT prompts into command line operations or extend their functionality to a wider network through a personal API, Fabric is designed to seamlessly blend with your digital ecosystem. This tool is all about augmenting your digital interactions, enhancing productivity, and enabling a more intelligent, GPT-powered experience in every aspect of your online presence.
## Features
1. Text Analysis: Easily extract summaries from texts.
2. Clipboard Integration: Conveniently copy responses to the clipboard.
3. File Output: Save responses to files for later reference.
4. Pattern Module: Utilize specific modules for different types of analysis.
5. Server Mode: Operate the tool in server mode for expanded capabilities.
6. Remote & Standalone Modes: Choose between remote and standalone operations.
## Installation
1. Install dependencies:
`npm install`
2. Start the application:
`npm start`
Contributing
We welcome contributions to Fabric! For details on our code of conduct and the process for submitting pull requests, please read the CONTRIBUTING.md.

View File

@@ -0,0 +1,45 @@
const { OpenAI } = require("openai");
require("dotenv").config({
path: require("os").homedir() + "/.config/fabric/.env",
});
let openaiClient = null;
// Function to initialize and get the OpenAI client
function getOpenAIClient() {
if (!process.env.OPENAI_API_KEY) {
throw new Error(
"The OPENAI_API_KEY environment variable is missing or empty."
);
}
return new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
}
async function queryOpenAI(system, user, callback) {
const openai = getOpenAIClient(); // Ensure the client is initialized here
const messages = [
{ role: "system", content: system },
{ role: "user", content: user },
];
try {
const stream = await openai.chat.completions.create({
model: "gpt-4-1106-preview", // Adjust the model as necessary.
messages: messages,
temperature: 0.0,
top_p: 1,
frequency_penalty: 0.1,
presence_penalty: 0.1,
stream: true,
});
for await (const chunk of stream) {
const message = chunk.choices[0]?.delta?.content || "";
callback(message); // Process each chunk of data
}
} catch (error) {
console.error("Error querying OpenAI:", error);
callback("Error querying OpenAI. Please try again.");
}
}
module.exports = { queryOpenAI };

View File

@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fabric</title>
<link rel="stylesheet" href="static/stylesheet/bootstrap.min.css" />
<link rel="stylesheet" href="static/stylesheet/style.css" />
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">
<img
src="static/images/fabric-logo-gif.gif"
alt="Fabric Logo"
height="40"
/>
</a>
<button id="configButton" class="btn btn-outline-success my-2 my-sm-0">
Config
</button>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarCollap se"
aria-controls="navbarCollapse"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<button
id="updatePatternsButton"
class="btn btn-outline-success my-2 my-sm-0"
>
Update Patterns
</button>
<div class="collapse navbar-collapse" id="navbarCollapse"></div>
<div class="m1-auto">
<a class="navbar-brand" id="themeChanger" href="#">Dark</a>
</div>
</nav>
<main>
<div class="container" id="my-form">
<select class="form-control" id="patternSelector"></select>
<textarea
rows="5"
class="form-control"
id="userInput"
placeholder="start typing or drag a file (.txt, .svg, .pdf and .doc are currently supported)"
></textarea>
<button class="btn btn-primary" id="submit">Submit</button>
</div>
<div id="configSection" class="container hidden">
<input
type="text"
id="apiKeyInput"
placeholder="Enter OpenAI API Key"
class="form-control"
/>
<button id="saveApiKey" class="btn btn-primary">Save API Key</button>
</div>
<div class="container hidden" id="responseContainer"></div>
</main>
<script src="static/js/jquery-3.0.0.slim.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/index.js"></script>
</body>
</html>

View File

@@ -0,0 +1,300 @@
const { app, BrowserWindow, ipcMain, dialog } = require("electron");
const pdfParse = require("pdf-parse");
const mammoth = require("mammoth");
const fs = require("fs");
const path = require("path");
const os = require("os");
const { queryOpenAI } = require("./chatgpt.js");
const axios = require("axios");
const fsExtra = require("fs-extra");
let fetch;
import("node-fetch").then((module) => {
fetch = module.default;
});
const unzipper = require("unzipper");
let win;
function promptUserForApiKey() {
// Create a new window to prompt the user for the API key
const promptWindow = new BrowserWindow({
// Window configuration for the prompt
width: 500,
height: 200,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, // Consider security implications
},
});
// Handle the API key submission from the prompt window
ipcMain.on("submit-api-key", (event, apiKey) => {
if (apiKey) {
saveApiKey(apiKey);
promptWindow.close();
createWindow(); // Proceed to create the main window
} else {
// Handle invalid input or user cancellation
promptWindow.close();
}
});
}
function loadApiKey() {
const configPath = path.join(os.homedir(), ".config", "fabric", ".env");
if (fs.existsSync(configPath)) {
const envContents = fs.readFileSync(configPath, { encoding: "utf8" });
const matches = envContents.match(/^OPENAI_API_KEY=(.*)$/m);
if (matches && matches[1]) {
return matches[1];
}
}
return null;
}
function saveApiKey(apiKey) {
const configPath = path.join(os.homedir(), ".config", "fabric");
const envFilePath = path.join(configPath, ".env");
if (!fs.existsSync(configPath)) {
fs.mkdirSync(configPath, { recursive: true });
}
fs.writeFileSync(envFilePath, `OPENAI_API_KEY=${apiKey}`);
process.env.OPENAI_API_KEY = apiKey; // Set for current session
}
function ensureFabricFoldersExist() {
return new Promise(async (resolve, reject) => {
const fabricPath = path.join(os.homedir(), ".config", "fabric");
const patternsPath = path.join(fabricPath, "patterns");
try {
if (!fs.existsSync(fabricPath)) {
fs.mkdirSync(fabricPath, { recursive: true });
}
if (!fs.existsSync(patternsPath)) {
fs.mkdirSync(patternsPath, { recursive: true });
await downloadAndUpdatePatterns(patternsPath);
}
resolve(); // Resolve the promise once everything is set up
} catch (error) {
console.error("Error ensuring fabric folders exist:", error);
reject(error); // Reject the promise if an error occurs
}
});
}
async function downloadAndUpdatePatterns(patternsPath) {
try {
const response = await axios({
method: "get",
url: "https://github.com/danielmiessler/fabric/archive/refs/heads/main.zip",
responseType: "arraybuffer",
});
const zipPath = path.join(os.tmpdir(), "fabric.zip");
fs.writeFileSync(zipPath, response.data);
console.log("Zip file written to:", zipPath);
const tempExtractPath = path.join(os.tmpdir(), "fabric_extracted");
fsExtra.emptyDirSync(tempExtractPath);
await fsExtra.remove(patternsPath); // Delete the existing patterns directory
await fs
.createReadStream(zipPath)
.pipe(unzipper.Extract({ path: tempExtractPath }))
.promise();
console.log("Extraction complete");
const extractedPatternsPath = path.join(
tempExtractPath,
"fabric-main",
"patterns"
);
await fsExtra.copy(extractedPatternsPath, patternsPath);
console.log("Patterns successfully updated");
// Inform the renderer process that the patterns have been updated
win.webContents.send("patterns-updated");
} catch (error) {
console.error("Error downloading or updating patterns:", error);
}
}
function checkApiKeyExists() {
const configPath = path.join(os.homedir(), ".config", "fabric", ".env");
return fs.existsSync(configPath);
}
function getPatternFolders() {
const patternsPath = path.join(os.homedir(), ".config", "fabric", "patterns");
return fs
.readdirSync(patternsPath, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
}
function getPatternContent(patternName) {
const patternPath = path.join(
os.homedir(),
".config",
"fabric",
"patterns",
patternName,
"system.md"
);
try {
return fs.readFileSync(patternPath, "utf8");
} catch (error) {
console.error("Error reading pattern file:", error);
return "";
}
}
function createWindow() {
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: path.join(__dirname, "preload.js"),
},
});
win.loadFile("index.html");
win.on("closed", () => {
win = null;
});
}
ipcMain.on("process-complex-file", (event, filePath) => {
const extension = path.extname(filePath).toLowerCase();
let fileProcessPromise;
if (extension === ".pdf") {
const dataBuffer = fs.readFileSync(filePath);
fileProcessPromise = pdfParse(dataBuffer).then((data) => data.text);
} else if (extension === ".docx") {
fileProcessPromise = mammoth
.extractRawText({ path: filePath })
.then((result) => result.value)
.catch((err) => {
console.error("Error processing DOCX file:", err);
throw new Error("Error processing DOCX file.");
});
} else {
event.reply("file-response", "Error: Unsupported file type");
return;
}
fileProcessPromise
.then((extractedText) => {
// Sending the extracted text back to the frontend.
event.reply("file-response", extractedText);
})
.catch((error) => {
// Handling any errors during file processing and sending them back to the frontend.
event.reply("file-response", `Error processing file: ${error.message}`);
});
});
ipcMain.on("start-query-openai", async (event, system, user) => {
if (system == null || user == null) {
console.error("Received null for system or user message");
event.reply("openai-response", "Error: System or user message is null.");
return;
}
try {
await queryOpenAI(system, user, (message) => {
event.reply("openai-response", message);
});
} catch (error) {
console.error("Error querying OpenAI:", error);
event.reply("no-api-key", "Error querying OpenAI.");
}
});
// Example of using ipcMain.handle for asynchronous operations
ipcMain.handle("get-patterns", async (event) => {
try {
return getPatternFolders();
} catch (error) {
console.error("Failed to get patterns:", error);
return [];
}
});
ipcMain.on("update-patterns", () => {
const patternsPath = path.join(os.homedir(), ".config", "fabric", "patterns");
downloadAndUpdatePatterns(patternsPath);
});
ipcMain.handle("get-pattern-content", async (event, patternName) => {
try {
return getPatternContent(patternName);
} catch (error) {
console.error("Failed to get pattern content:", error);
return "";
}
});
ipcMain.handle("save-api-key", async (event, apiKey) => {
try {
const configPath = path.join(os.homedir(), ".config", "fabric");
if (!fs.existsSync(configPath)) {
fs.mkdirSync(configPath, { recursive: true });
}
const envFilePath = path.join(configPath, ".env");
fs.writeFileSync(envFilePath, `OPENAI_API_KEY=${apiKey}`);
process.env.OPENAI_API_KEY = apiKey;
return "API Key saved successfully.";
} catch (error) {
console.error("Error saving API key:", error);
throw new Error("Failed to save API Key.");
}
});
app.whenReady().then(async () => {
try {
const apiKey = loadApiKey();
if (!apiKey) {
promptUserForApiKey();
} else {
process.env.OPENAI_API_KEY = apiKey;
createWindow();
}
await ensureFabricFoldersExist(); // Ensure fabric folders exist
createWindow(); // Create the application window
// After window creation, check if the API key exists
if (!checkApiKeyExists()) {
console.log("API key is missing. Prompting user to input API key.");
// Optionally, directly invoke a function here to show a prompt in the renderer process
win.webContents.send("request-api-key");
}
} catch (error) {
console.error("Failed to initialize fabric folders:", error);
// Handle initialization failure (e.g., close the app or show an error message)
}
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (win === null) {
createWindow();
}
});

1644
installer/client/gui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
{
"name": "fabric_electron",
"version": "1.0.0",
"description": "a fabric electron app",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"dotenv": "^16.4.1",
"electron": "^28.2.2",
"openai": "^4.27.0"
},
"dependencies": {
"axios": "^1.6.7",
"mammoth": "^1.6.0",
"node-fetch": "^2.6.7",
"pdf-parse": "^1.1.1",
"unzipper": "^0.10.14"
}
}

View File

@@ -0,0 +1,9 @@
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("electronAPI", {
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
send: (channel, ...args) => ipcRenderer.send(channel, ...args),
on: (channel, func) => {
ipcRenderer.on(channel, (event, ...args) => func(...args));
},
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 MiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,266 @@
document.addEventListener("DOMContentLoaded", async function () {
const patternSelector = document.getElementById("patternSelector");
const userInput = document.getElementById("userInput");
const submitButton = document.getElementById("submit");
const responseContainer = document.getElementById("responseContainer");
const themeChanger = document.getElementById("themeChanger");
const configButton = document.getElementById("configButton");
const configSection = document.getElementById("configSection");
const saveApiKeyButton = document.getElementById("saveApiKey");
const apiKeyInput = document.getElementById("apiKeyInput");
const originalPlaceholder = userInput.placeholder;
const updatePatternsButton = document.getElementById("updatePatternsButton");
const copyButton = document.createElement("button");
window.electronAPI.on("patterns-ready", () => {
console.log("Patterns are ready. Refreshing the pattern list.");
loadPatterns();
});
window.electronAPI.on("request-api-key", () => {
// Show the API key input section or modal to the user
configSection.classList.remove("hidden"); // Assuming 'configSection' is your API key input area
});
copyButton.textContent = "Copy";
copyButton.id = "copyButton";
document.addEventListener("click", function (e) {
if (e.target && e.target.id === "copyButton") {
// Your copy to clipboard function
copyToClipboard();
}
});
window.electronAPI.on("no-api-key", () => {
alert("API key is missing. Please enter your OpenAI API key.");
});
window.electronAPI.on("patterns-updated", () => {
alert("Patterns updated. Refreshing the pattern list.");
loadPatterns();
});
function htmlToPlainText(html) {
// Create a temporary div element to hold the HTML
var tempDiv = document.createElement("div");
tempDiv.innerHTML = html;
// Replace <br> tags with newline characters
tempDiv.querySelectorAll("br").forEach((br) => br.replaceWith("\n"));
// Replace block elements like <p> and <div> with newline characters
tempDiv.querySelectorAll("p, div").forEach((block) => {
block.prepend("\n"); // Add a newline before the block element's content
block.replaceWith(...block.childNodes); // Replace the block element with its own contents
});
// Return the text content, trimming leading and trailing newlines
return tempDiv.textContent.trim();
}
async function submitQuery(userInputValue) {
userInput.value = ""; // Clear the input after submitting
systemCommand = await window.electronAPI.invoke(
"get-pattern-content",
patternSelector.value
);
responseContainer.innerHTML = ""; // Clear previous responses
if (responseContainer.classList.contains("hidden")) {
console.log("contains hidden");
responseContainer.classList.remove("hidden");
responseContainer.appendChild(copyButton);
}
window.electronAPI.send(
"start-query-openai",
systemCommand,
userInputValue
);
}
function copyToClipboard() {
const containerClone = responseContainer.cloneNode(true);
// Remove the copy button from the clone
const copyButtonClone = containerClone.querySelector("#copyButton");
if (copyButtonClone) {
copyButtonClone.parentNode.removeChild(copyButtonClone);
}
// Convert HTML to plain text, preserving newlines
const plainText = htmlToPlainText(containerClone.innerHTML);
// Use a temporary textarea for copying
const textArea = document.createElement("textarea");
textArea.style.position = "absolute";
textArea.style.left = "-9999px";
textArea.setAttribute("aria-hidden", "true");
textArea.value = plainText;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand("copy");
console.log("Text successfully copied to clipboard");
} catch (err) {
console.error("Failed to copy text: ", err);
}
document.body.removeChild(textArea);
}
async function loadPatterns() {
try {
const patterns = await window.electronAPI.invoke("get-patterns");
patternSelector.innerHTML = ""; // Clear existing options first
patterns.forEach((pattern) => {
const option = document.createElement("option");
option.value = pattern;
option.textContent = pattern;
patternSelector.appendChild(option);
});
} catch (error) {
console.error("Failed to load patterns:", error);
}
}
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand("copy");
const msg = successful ? "successful" : "unsuccessful";
console.log("Fallback: Copying text command was " + msg);
} catch (err) {
console.error("Fallback: Oops, unable to copy", err);
}
document.body.removeChild(textArea);
}
updatePatternsButton.addEventListener("click", () => {
window.electronAPI.send("update-patterns");
});
// Load patterns on startup
try {
const patterns = await window.electronAPI.invoke("get-patterns");
patterns.forEach((pattern) => {
const option = document.createElement("option");
option.value = pattern;
option.textContent = pattern;
patternSelector.appendChild(option);
});
} catch (error) {
console.error("Failed to load patterns:", error);
}
// Listen for OpenAI responses
window.electronAPI.on("openai-response", (message) => {
const formattedMessage = message.replace(/\n/g, "<br>");
responseContainer.innerHTML += formattedMessage; // Append new data as it arrives
});
window.electronAPI.on("file-response", (message) => {
if (message.startsWith("Error")) {
alert(message);
return;
}
submitQuery(message);
});
// Submit button click handler
submitButton.addEventListener("click", async () => {
const userInputValue = userInput.value;
submitQuery(userInputValue);
});
// Theme changer click handler
themeChanger.addEventListener("click", function (e) {
e.preventDefault();
document.body.classList.toggle("light-theme");
themeChanger.innerText =
themeChanger.innerText === "Dark" ? "Light" : "Dark";
});
// Config button click handler - toggles the config section visibility
configButton.addEventListener("click", function (e) {
e.preventDefault();
configSection.classList.toggle("hidden");
});
// Save API Key button click handler
saveApiKeyButton.addEventListener("click", () => {
const apiKey = apiKeyInput.value;
window.electronAPI
.invoke("save-api-key", apiKey)
.then(() => {
alert("API Key saved successfully.");
// Optionally hide the config section and clear the input after saving
configSection.classList.add("hidden");
apiKeyInput.value = "";
})
.catch((err) => {
console.error("Error saving API key:", err);
alert("Failed to save API Key.");
});
});
// Handler for pattern selection change
patternSelector.addEventListener("change", async () => {
const selectedPattern = patternSelector.value;
const systemCommand = await window.electronAPI.invoke(
"get-pattern-content",
selectedPattern
);
// Use systemCommand as part of the input for querying OpenAI
});
// drag and drop
userInput.addEventListener("dragover", (event) => {
event.stopPropagation();
event.preventDefault();
// Add some visual feedback
userInput.classList.add("drag-over");
userInput.placeholder = "Drop file here";
});
userInput.addEventListener("dragleave", (event) => {
event.stopPropagation();
event.preventDefault();
// Remove visual feedback
userInput.classList.remove("drag-over");
userInput.placeholder = originalPlaceholder;
});
userInput.addEventListener("drop", (event) => {
event.stopPropagation();
event.preventDefault();
const file = event.dataTransfer.files[0];
userInput.classList.remove("drag-over");
userInput.placeholder = originalPlaceholder;
processFile(file);
});
function processFile(file) {
const fileType = file.type;
const reader = new FileReader();
let content = "";
reader.onload = (event) => {
content = event.target.result;
userInput.value = content;
submitQuery(content);
};
if (fileType === "text/plain" || fileType === "image/svg+xml") {
reader.readAsText(file);
} else if (
fileType === "application/pdf" ||
fileType.match(/wordprocessingml/)
) {
// For PDF and DOCX, we need to handle them in the main process due to complexity
window.electronAPI.send("process-complex-file", file.path);
} else {
console.error("Unsupported file type");
}
}
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,160 @@
body {
font-family: "Segoe UI", Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #2b2b2b;
color: #e0e0e0;
}
.container {
max-width: 90%;
margin: 50px auto;
padding: 15px;
background: #333333;
box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
border-radius: 5px;
}
#responseContainer {
margin-top: 15px;
border: 1px solid #444;
padding: 10px;
min-height: 100px;
background-color: #3a3a3a;
color: #e0e0e0;
}
.btn-primary {
background-color: #007bff;
color: white;
border: none;
}
#userInput {
margin-bottom: 10px;
background-color: #424242; /* Darker shade for textarea */
color: #e0e0e0; /* Light text for readability */
border: 1px solid #555; /* Adjusted border color */
padding: 10px; /* Added padding for better text visibility */
}
#patternSelector {
margin-bottom: 10px;
background-color: #424242; /* Darker shade for textarea */
color: #e0e0e0; /* Light text for readability */
border: 1px solid #555; /* Adjusted border color */
padding: 10px; /* Added padding for better text visibility */
height: 40px;
}
@media (min-width: 768px) {
.container {
max-width: 80%;
}
}
.light-theme {
background-color: #fff;
color: #333;
}
.light-theme .container {
background: #f0f0f0;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.light-theme #responseContainer,
.light-theme #userInput,
.light-theme #patternSelector {
background-color: #fff;
color: #333;
border: 1px solid #ddd;
}
.light-theme .btn-primary {
background-color: #0066cc;
color: white;
}
.hidden {
display: none;
}
.drag-over {
background-color: #505050; /* Slightly lighter than the regular background for visibility */
border: 2px dashed #007bff; /* Dashed border with the primary button color for emphasis */
box-shadow: 0 0 10px #007bff; /* Soft glow effect to highlight the area */
color: #e0e0e0; /* Maintaining the light text color for readability */
transition: background-color 0.3s ease, box-shadow 0.3s ease; /* Smooth transition for background and shadow changes */
}
.light-theme .drag-over {
background-color: #e6e6e6; /* Lighter background for light theme */
border: 2px dashed #0066cc; /* Adjusted border color for light theme */
box-shadow: 0 0 10px #0066cc; /* Soft glow effect for light theme */
color: #333; /* Darker text for contrast in light theme */
}
/* Existing dark theme styles for reference */
.navbar-dark.bg-dark {
background-color: #343a40 !important;
}
/* Light theme styles */
body.light-theme .navbar-dark.bg-dark {
background-color: #e2e6ea !important; /* Slightly darker shade for better visibility */
color: #000 !important; /* Keep dark text color for contrast */
}
body.light-theme .navbar-dark .navbar-brand,
body.light-theme .navbar-dark .btn-outline-success {
color: #0056b3 !important; /* Darker color for better visibility and contrast */
}
body.light-theme .navbar-toggler-icon {
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'><path stroke='rgba(0, 0, 0, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>") !important;
/* Slightly darker stroke for the navbar-toggler-icon for better visibility */
}
@media (max-width: 768px) {
.navbar-brand img {
height: 20px; /* Smaller logo for smaller screens */
}
.navbar-dark .navbar-toggler {
padding: 0.25rem 0.5rem; /* Adjust padding for the toggle button */
}
}
#responseContainer {
position: relative; /* Needed for absolute positioning of the child button */
}
#copyButton {
position: absolute;
top: 10px; /* Adjust as needed */
right: 10px; /* Adjust as needed */
background-color: rgba(
0,
123,
255,
0.5
); /* Bootstrap primary color with transparency */
color: white;
border: none;
border-radius: 5px;
padding: 5px 10px;
font-size: 0.8rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
#copyButton:hover {
background-color: rgba(
0,
123,
255,
0.8
); /* Slightly less transparent on hover */
}
#copyButton:focus {
outline: none;
}

View File

@@ -0,0 +1,3 @@
"""This package collets all functionality meant to run as web servers"""
from .api import main as run_api_server
from .webui import main as run_webui_server

View File

@@ -0,0 +1,2 @@
FLASK_SECRET_KEY=
OPENAI_API_KEY=

View File

@@ -0,0 +1 @@
from .fabric_api_server import main

View File

@@ -0,0 +1,10 @@
{
"/extwis": {
"eJ4f1e0b-25wO-47f9-97ec-6b5335b2": "Daniel Miessler",
"test": "user2"
},
"/summarize": {
"eJ4f1e0b-25wO-47f9-97ec-6b5335b2": "Daniel Miessler",
"test": "user2"
}
}

View File

@@ -0,0 +1,259 @@
import jwt
import json
import openai
from flask import Flask, request, jsonify
from functools import wraps
import re
import requests
import os
from dotenv import load_dotenv
from importlib import resources
app = Flask(__name__)
@app.errorhandler(404)
def not_found(e):
return jsonify({"error": "The requested resource was not found."}), 404
@app.errorhandler(500)
def server_error(e):
return jsonify({"error": "An internal server error occurred."}), 500
##################################################
##################################################
#
# ⚠️ CAUTION: This is an HTTP-only server!
#
# If you don't know what you're doing, don't run
#
##################################################
##################################################
## Setup
## Did I mention this is HTTP only? Don't run this on the public internet.
# Read API tokens from the apikeys.json file
api_keys = resources.read_text("installer.server.api", "fabric_api_keys.json")
valid_tokens = json.loads(api_keys)
# Read users from the users.json file
users = resources.read_text("installer.server.api", "users.json")
users = json.loads(users)
# The function to check if the token is valid
def auth_required(f):
""" Decorator function to check if the token is valid.
Args:
f: The function to be decorated
Returns:
The decorated function
"""
@wraps(f)
def decorated_function(*args, **kwargs):
""" Decorated function to handle authentication token and API endpoint.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
Result of the decorated function.
Raises:
KeyError: If 'Authorization' header is not found in the request.
TypeError: If 'Authorization' header value is not a string.
ValueError: If the authentication token is invalid or expired.
"""
# Get the authentication token from request header
auth_token = request.headers.get("Authorization", "")
# Remove any bearer token prefix if present
if auth_token.lower().startswith("bearer "):
auth_token = auth_token[7:]
# Get API endpoint from request
endpoint = request.path
# Check if token is valid
user = check_auth_token(auth_token, endpoint)
if user == "Unauthorized: You are not authorized for this API":
return jsonify({"error": user}), 401
return f(*args, **kwargs)
return decorated_function
# Check for a valid token/user for the given route
def check_auth_token(token, route):
""" Check if the provided token is valid for the given route and return the corresponding user.
Args:
token (str): The token to be checked for validity.
route (str): The route for which the token validity is to be checked.
Returns:
str: The user corresponding to the provided token and route if valid, otherwise returns "Unauthorized: You are not authorized for this API".
"""
# Check if token is valid for the given route and return corresponding user
if route in valid_tokens and token in valid_tokens[route]:
return users[valid_tokens[route][token]]
else:
return "Unauthorized: You are not authorized for this API"
# Define the allowlist of characters
ALLOWLIST_PATTERN = re.compile(r"^[a-zA-Z0-9\s.,;:!?\-]+$")
# Sanitize the content, sort of. Prompt injection is the main threat so this isn't a huge deal
def sanitize_content(content):
""" Sanitize the content by removing characters that do not match the ALLOWLIST_PATTERN.
Args:
content (str): The content to be sanitized.
Returns:
str: The sanitized content.
"""
return "".join(char for char in content if ALLOWLIST_PATTERN.match(char))
# Pull the URL content's from the GitHub repo
def fetch_content_from_url(url):
""" Fetches content from the given URL.
Args:
url (str): The URL from which to fetch content.
Returns:
str: The sanitized content fetched from the URL.
Raises:
requests.RequestException: If an error occurs while making the request to the URL.
"""
try:
response = requests.get(url)
response.raise_for_status()
sanitized_content = sanitize_content(response.text)
return sanitized_content
except requests.RequestException as e:
return str(e)
## APIs
# Make path mapping flexible and scalable
pattern_path_mappings = {
"extwis": {"system_url": "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/extract_wisdom/system.md",
"user_url": "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/extract_wisdom/user.md"},
"summarize": {"system_url": "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/summarize/system.md",
"user_url": "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/summarize/user.md"}
} # Add more pattern with your desire path as a key in this dictionary
# /<pattern>
@app.route("/<pattern>", methods=["POST"])
@auth_required # Require authentication
def milling(pattern):
""" Combine fabric pattern with input from user and send to OpenAI's GPT-4 model.
Returns:
JSON: A JSON response containing the generated response or an error message.
Raises:
Exception: If there is an error during the API call.
"""
data = request.get_json()
# Warn if there's no input
if "input" not in data:
return jsonify({"error": "Missing input parameter"}), 400
# Get data from client
input_data = data["input"]
# Set the system and user URLs
urls = pattern_path_mappings[pattern]
system_url, user_url = urls["system_url"], urls["user_url"]
# Fetch the prompt content
system_content = fetch_content_from_url(system_url)
user_file_content = fetch_content_from_url(user_url)
# Build the API call
system_message = {"role": "system", "content": system_content}
user_message = {"role": "user", "content": user_file_content + "\n" + input_data}
messages = [system_message, user_message]
try:
response = openai.chat.completions.create(
model="gpt-4-1106-preview",
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
)
assistant_message = response.choices[0].message.content
return jsonify({"response": assistant_message})
except Exception as e:
app.logger.error(f"Error occurred: {str(e)}")
return jsonify({"error": "An error occurred while processing the request."}), 500
@app.route("/register", methods=["POST"])
def register():
data = request.get_json()
username = data["username"]
password = data["password"]
if username in users:
return jsonify({"error": "Username already exists"}), 400
new_user = {
"username": username,
"password": password
}
users[username] = new_user
token = jwt.encode({"username": username}, os.getenv("JWT_SECRET"), algorithm="HS256")
return jsonify({"token": token.decode("utf-8")})
@app.route("/login", methods=["POST"])
def login():
data = request.get_json()
username = data["username"]
password = data["password"]
if username in users and users[username]["password"] == password:
# Generate a JWT token
token = jwt.encode({"username": username}, os.getenv("JWT_SECRET"), algorithm="HS256")
return jsonify({"token": token.decode("utf-8")})
return jsonify({"error": "Invalid username or password"}), 401
def main():
"""Runs the main fabric API backend server"""
app.run(host="127.0.0.1", port=13337, debug=True)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,11 @@
{
"user1": {
"username": "user1",
"password": "password1"
},
"user2": {
"username": "user2",
"password": "password2"
}
}

View File

@@ -0,0 +1 @@
from .fabric_web_server import main

View File

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@@ -16,27 +16,53 @@ import os
def send_request(prompt, endpoint):
""" Send a request to the specified endpoint of an HTTP-only server.
Args:
prompt (str): The input prompt for the request.
endpoint (str): The endpoint to which the request will be sent.
Returns:
str: The response from the server.
Raises:
KeyError: If the response JSON does not contain the expected "response" key.
"""
base_url = "http://127.0.0.1:13337"
url = f"{base_url}{endpoint}"
headers = {
"Content-Type": "application/json",
"Authorization": "eJ4f1e0b-25wO-47f9-97ec-6b5335b2",
"Authorization": f"Bearer {session['token']}",
}
data = json.dumps({"input": prompt})
response = requests.post(url, headers=headers, data=data, verify=False)
try:
return response.json()["response"]
except KeyError:
return f"Error: You're not authorized for this application."
response = requests.post(url, headers=headers, data=data)
response.raise_for_status() # raises HTTPError if the response status isn't 200
except requests.ConnectionError:
return "Error: Unable to connect to the server."
except requests.HTTPError as e:
return f"Error: An HTTP error occurred: {str(e)}"
app = Flask(__name__)
app.secret_key = "your_secret_key"
app.secret_key = os.getenv("FLASK_SECRET_KEY")
@app.route("/favicon.ico")
def favicon():
""" Send the favicon.ico file from the static directory.
Returns:
Response object with the favicon.ico file
Raises:
-
"""
return send_from_directory(
os.path.join(app.root_path, "static"),
"favicon.ico",
@@ -46,6 +72,12 @@ def favicon():
@app.route("/", methods=["GET", "POST"])
def index():
""" Process the POST request and send a request to the specified API endpoint.
Returns:
str: The rendered HTML template with the response data.
"""
if request.method == "POST":
prompt = request.form.get("prompt")
endpoint = request.form.get("api")
@@ -54,5 +86,9 @@ def index():
return render_template("index.html", response=None)
if __name__ == "__main__":
def main():
app.run(host="127.0.0.1", port=13338, debug=True)
if __name__ == "__main__":
main()

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -17,7 +17,7 @@
<h1 class="text-4xl font-bold"><code>fabric</code></h1>
</div>
<p>Enter your content and the API you want to send it to.</p>
<p>Please enter your content and select the API you want to use:</p>
<br />
<form method="POST" class="space-y-4">
<div>
@@ -31,13 +31,13 @@
<!-- Add more API endpoints here... -->
</select>
</div>
<button type="submit" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white font-medium">Submit</button>
<button type="submit" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white font-medium">Send Request</button>
</form>
{% if response %}
<div class="mt-8">
<div class="flex justify-between items-center mb-4">
<h2 class="text-2xl font-bold">Response:</h2>
<button id="copy-button" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-md">Copy</button>
<h2 class="text-2xl font-bold">API Response:</h2>
<button id="copy-button" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-md">Copy to Clipboard</button>
</div>
<pre id="response-output" class="bg-gray-800 p-4 rounded-md whitespace-pre-wrap">{{ response }}</pre>
</div>

View File

@@ -0,0 +1,21 @@
# IDENTITY and PURPOSE
You are an expert in the Agile framework. You deeply understand user story and acceptance criteria creation. You will be given a topic. Please write the appropriate information for what is requested.
# STEPS
Please write a user story and acceptance criteria for the requested topic.
# OUTPUT INSTRUCTIONS
Output the results in JSON format as defined in this example:
{
"Topic": "Automating data quality automation",
"Story": "As a user, I want to be able to create a new user account so that I can access the system.",
"Criteria": "Given that I am a user, when I click the 'Create Account' button, then I should be prompted to enter my email address, password, and confirm password. When I click the 'Submit' button, then I should be redirected to the login page."
}
# INPUT:
INPUT:

16
patterns/ai/system.md Normal file
View File

@@ -0,0 +1,16 @@
# IDENTITY and PURPOSE
You are an expert at interpreting the heart of a question and answering in a concise manner.
# Steps
- Understand what's being asked.
- Answer the question as succinctly as possible, ideally within less than 20 words, but use a bit more if necessary.
# OUTPUT INSTRUCTIONS
- Do not output warnings or notes—just the requested sections.
# INPUT:
INPUT:

View File

@@ -0,0 +1,34 @@
Cybersecurity Hack Article Analysis: Efficient Data Extraction
Objective: To swiftly and effectively gather essential information from articles about cybersecurity breaches, prioritizing conciseness and order.
Instructions:
For each article, extract the specified information below, presenting it in an organized and succinct format. Ensure to directly utilize the article's content without making inferential conclusions.
- Attack Date: YYYY-MM-DD
- Summary: A concise overview in one sentence.
- Key Details:
- Attack Type: Main method used (e.g., "Ransomware").
- Vulnerable Component: The exploited element (e.g., "Email system").
- Attacker Information:
- Name/Organization: When available (e.g., "APT28").
- Country of Origin: If identified (e.g., "China").
- Target Information:
- Name: The targeted entity.
- Country: Location of impact (e.g., "USA").
- Size: Entity size (e.g., "Large enterprise").
- Industry: Affected sector (e.g., "Healthcare").
- Incident Details:
- CVE's: Identified CVEs (e.g., CVE-XXX, CVE-XXX).
- Accounts Compromised: Quantity (e.g., "5000").
- Business Impact: Brief description (e.g., "Operational disruption").
- Impact Explanation: In one sentence.
- Root Cause: Principal reason (e.g., "Unpatched software").
- Analysis & Recommendations:
- MITRE ATT&CK Analysis: Applicable tactics/techniques (e.g., "T1566, T1486").
- Atomic Red Team Atomics: Recommended tests (e.g., "T1566.001").
- Remediation:
- Recommendation: Summary of action (e.g., "Implement MFA").
- Action Plan: Stepwise approach (e.g., "1. Update software, 2. Train staff").
- Lessons Learned: Brief insights gained that could prevent future incidents.

View File

View File

@@ -6,58 +6,37 @@ Take a deep breath and think step by step about how to best accomplish this goal
# OUTPUT SECTIONS
- Extract a summary of the content in 50 words or less, including who is presenting and the content being discussed into a section called SUMMARY.
- Extract a summary of the paper and its conclusions in into a 25-word sentence called SUMMARY.
- Extract the list of authors in a section called AUTHORS.
- Extract the list of organizations the authors are associated, e.g., which university they're at, with in a section called AUTHOR ORGANIZATIONS.
- Extract the primary paper findings into a bulleted list of no more than 50 words per bullet into a section called FINDINGS.
- Extract the primary paper findings into a bulleted list of no more than 25 words per bullet into a section called FINDINGS.
- You extract the size and details of the study for the research in a section called STUDY DETAILS.
- Extract the overall structure and character of the study for the research in a section called STUDY DETAILS.
- Extract the study quality by evaluating the following items in a section called STUDY QUALITY:
- Extract the study quality by evaluating the following items in a section called STUDY QUALITY that has the following sub-sections:
### Sample size
- Study Design: (give a 25 word description, including the pertinent data and statistics.)
- Sample Size: (give a 25 word description, including the pertinent data and statistics.)
- Confidence Intervals (give a 25 word description, including the pertinent data and statistics.)
- P-value (give a 25 word description, including the pertinent data and statistics.)
- Effect Size (give a 25 word description, including the pertinent data and statistics.)
- Consistency of Results (give a 25 word description, including the pertinent data and statistics.)
- Data Analysis Method (give a 25 word description, including the pertinent data and statistics.)
- **Check the Sample Size**: The larger the sample size, the more confident you can be in the findings. A larger sample size reduces the margin of error and increases the study's power.
- Discuss any Conflicts of Interest in a section called CONFLICTS OF INTEREST. Rate the conflicts of interest as NONE DETECTED, LOW, MEDIUM, HIGH, or CRITICAL.
### Confidence intervals
- Extract the researcher's analysis and interpretation in a section called RESEARCHER'S INTERPRETATION, including how confident they are in the results being real and likely to be replicated on a scale of LOW, MEDIUM, or HIGH.
- **Look at the Confidence Intervals**: Confidence intervals provide a range within which the true population parameter lies with a certain degree of confidence (usually 95% or 99%). Narrower confidence intervals suggest a higher level of precision and confidence in the estimate.
### P-Value
- **Evaluate the P-value**: The P-value tells you the probability that the results occurred by chance. A lower P-value (typically less than 0.05) suggests that the findings are statistically significant and not due to random chance.
### Effect size
- **Consider the Effect Size**: Effect size tells you how much of a difference there is between groups. A larger effect size indicates a stronger relationship and more confidence in the findings.
### Study design
- **Review the Study Design**: Randomized controlled trials are usually considered the gold standard in research. If the study is observational, it may be less reliable.
### Consistency of results
- **Check for Consistency of Results**: If the results are consistent across multiple studies, it increases the confidence in the findings.
### Data analysis methods
- **Examine the Data Analysis Methods**: Check if the data analysis methods used are appropriate for the type of data and research question. Misuse of statistical methods can lead to incorrect conclusions.
### Researcher's interpretation
- **Assess the Researcher's Interpretation**: The researchers should interpret their results in the context of the study's limitations. Overstating the findings can misrepresent the confidence level.
### Summary
You output a 50 word summary of the quality of the paper and it's likelihood of being replicated in future work as one of three levels: High, Medium, or Low. You put that sentence and ratign into a section called SUMMARY.
- Based on all of the analysis performed above, output a 25 word summary of the quality of the paper and it's likelihood of being replicated in future work as one of five levels: VERY LOW, LOW, MEDIUM, HIGH, or VERY HIGH. You put that sentence and RATING into a section called SUMMARY and RATING.
# OUTPUT INSTRUCTIONS
- Create the output using the formatting above.
- You only output human readable Markdown.
- In the markdown, don't use formatting like bold or italics. Make the output maximially readable in plain text.
- Do not output warnings or notes—just the requested sections.
# INPUT:

View File

@@ -0,0 +1,82 @@
# IDENTITY and PURPOSE
You are an expert writer and editor and you excel at evaluating the quality of writing and other content and providing various ratings and recommendations about how to improve it from a novelty, clarity, and overall messaging standpoint.
Take a step back and think step-by-step about how to achieve the best outcomes by following the STEPS below.
# STEPS
1. Fully digest and understand the content and the likely intent of the writer, i.e., what they wanted to convey to the reader, viewer, listener.
2. Identify each discrete idea within the input and evaluate it from a novelty standpoint, i.e., how surprising, fresh, or novel are the ideas in the content? Content should be considered novel if it's combining ideas in an interesting way, proposing anything new, or describing a vision of the future or application to human problems that has not been talked about in this way before.
3. Evaluate the combined NOVELTY of the ideas in the writing as defined in STEP 2 and provide a rating on the following scale:
"A - Novel" -- Does one or more of the following: Includes new ideas, proposes a new model for doing something, makes clear recommendations for action based on a new proposed model, creatively links existing ideas in a useful way, proposes new explanations for known phenomenon, or lays out a significant vision of what's to come that's well supported. Imagine a novelty score above 90% for this tier.
Common examples that meet this criteria:
- Introduction of new ideas.
- Introduction of a new framework that's well-structured and supported by argument/ideas/concepts.
- Introduction of new models for understanding the world.
- Makes a clear prediction that's backed by strong concepts and/or data.
- Introduction of a new vision of the future.
- Introduction of a new way of thinking about reality.
- Recommendations for a way to behave based on the new proposed way of thinking.
"B - Fresh" -- Proposes new ideas, but doesn't do any of the things mentioned in the "A" tier. Imagine a novelty score between 80% and 90% for this tier.
Common examples that meet this criteria:
- Minor expansion on existing ideas, but in a way that's useful.
"C - Incremental" -- Useful expansion or improvement of existing ideas, or a useful description of the past, but no expansion or creation of new ideas. Imagine a novelty score between 50% and 80% for this tier.
Common examples that meet this criteria:
- Valuable collections of resources
- Descriptions of the past with offered observations and takeaways
"D - Derivative" -- Largely derivative of well-known ideas. Imagine a novelty score between in the 20% to 50% range for this tier.
Common examples that meet this criteria:
- Contains ideas or facts, but they're not new in any way.
"F - Stale" -- No new ideas whatsoever. Imagine a novelty score below 20% for this tier.
Common examples that meet this criteria:
- Random ramblings that say nothing new.
4. Evaluate the CLARITY of the writing on the following scale.
"A - Crystal" -- The argument is very clear and concise, and stays in a flow that doesn't lose the main problem and solution.
"B - Clean" -- The argument is quite clear and concise, and only needs minor optimizations.
"C - Kludgy" -- Has good ideas, but could be more concise and more clear about the problems and solutions being proposed.
"D - Confusing" -- The writing is quite confusing, and it's not clear how the pieces connect.
"F - Chaotic" -- It's not even clear what's being attempted.
5. Evaluate the PROSE in the writing on the following scale.
"A - Inspired" -- Clear, fresh, distinctive prose that's free of cliche.
"B - Distinctive" -- Strong writing that lacks significant use of cliche.
"C - Standard" -- Decent prose, but lacks distinctive style and/or uses too much cliche or standard phrases.
"D - Stale" -- Significant use of cliche and/or weak language.
"F - Weak" -- Overwhelming language weakness and/or use of cliche.
6. Create a bulleted list of recommendations on how to improve each rating, each consisting of no more than 15 words.
7. Give an overall rating that's the lowest rating of 3, 4, and 5. So if they were B, C, and A, the overall-rating would be "C".
# OUTPUT INSTRUCTIONS
- You output in Markdown, using each section header followed by the content for that section.
- Don't use bold or italic formatting in the Markdown.
- Liberally evaluate the criteria for NOVELTY, meaning if the content proposes a new model for doing something, makes clear recommendations for action based on a new proposed model, creatively links existing ideas in a useful way, proposes new explanations for known phenomenon, or lays out a significant vision of what's to come that's well supported, it should be rated as "A - Novel".
- The overall-rating cannot be higher than the lowest rating given.
- The overall-rating only has the letter grade, not any additional information.
# INPUT:
INPUT:

View File

View File

@@ -0,0 +1,116 @@
# IDENTITY and PURPOSE
You are an expert writer and editor and you excel at evaluating the quality of writing and other content and providing various ratings and recommendations about how to improve it from a novelty, clarity, and overall messaging standpoint.
Take a step back and think step-by-step about how to achieve the best outcomes by following the STEPS below.
# STEPS
1. Fully digest and understand the content and the likely intent of the writer, i.e., what they wanted to convey to the reader, viewer, listener.
2. Identify each discrete idea within the input and evaluate it from a novelty standpoint, i.e., how surprising, fresh, or novel are the ideas in the content? Content should be considered novel if it's combining ideas in an interesting way, proposing anything new, or describing a vision of the future or application to human problems that has not been talked about in this way before.
3. Evaluate the combined NOVELTY of the ideas in the writing as defined in STEP 2 and provide a rating on the following scale:
"A - Novel" -- Does one or more of the following: Includes new ideas, proposes a new model for doing something, makes clear recommendations for action based on a new proposed model, creatively links existing ideas in a useful way, proposes new explanations for known phenomenon, or lays out a significant vision of what's to come that's well supported. Imagine a novelty score above 90% for this tier.
Common examples that meet this criteria:
- Introduction of new ideas.
- Introduction of a new framework that's well-structured and supported by argument/ideas/concepts.
- Introduction of new models for understanding the world.
- Makes a clear prediction that's backed by strong concepts and/or data.
- Introduction of a new vision of the future.
- Introduction of a new way of thinking about reality.
- Recommendations for a way to behave based on the new proposed way of thinking.
"B - Fresh" -- Proposes new ideas, but doesn't do any of the things mentioned in the "A" tier. Imagine a novelty score between 80% and 90% for this tier.
Common examples that meet this criteria:
- Minor expansion on existing ideas, but in a way that's useful.
"C - Incremental" -- Useful expansion or significant improvement of existing ideas, or a somewhat insightful description of the past, but no expansion on, or creation of, new ideas. Imagine a novelty score between 50% and 80% for this tier.
Common examples that meet this criteria:
- Useful collections of resources.
- Descriptions of the past with offered observations and takeaways.
- Minor expansions on existing ideas.
"D - Derivative" -- Largely derivative of well-known ideas. Imagine a novelty score between in the 20% to 50% range for this tier.
Common examples that meet this criteria:
- Restatement of common knowledge or best practices.
- Rehashes of well-known ideas without any new takes or expansions of ideas.
- Contains ideas or facts, but they're not new or improved in any significant way.
"F - Stale" -- No new ideas whatsoever. Imagine a novelty score below 20% for this tier.
Common examples that meet this criteria:
- Completely trite and unoriginal ideas.
- Heavily cliche or standard ideas.
4. Evaluate the CLARITY of the writing on the following scale.
"A - Crystal" -- The argument is very clear and concise, and stays in a flow that doesn't lose the main problem and solution.
"B - Clean" -- The argument is quite clear and concise, and only needs minor optimizations.
"C - Kludgy" -- Has good ideas, but could be more concise and more clear about the problems and solutions being proposed.
"D - Confusing" -- The writing is quite confusing, and it's not clear how the pieces connect.
"F - Chaotic" -- It's not even clear what's being attempted.
5. Evaluate the PROSE in the writing on the following scale.
"A - Inspired" -- Clear, fresh, distinctive prose that's free of cliche.
"B - Distinctive" -- Strong writing that lacks significant use of cliche.
"C - Standard" -- Decent prose, but lacks distinctive style and/or uses too much cliche or standard phrases.
"D - Stale" -- Significant use of cliche and/or weak language.
"F - Weak" -- Overwhelming language weakness and/or use of cliche.
6. Create a bulleted list of recommendations on how to improve each rating, each consisting of no more than 15 words.
7. Give an overall rating that's the lowest rating of 3, 4, and 5. So if they were B, C, and A, the overall-rating would be "C".
# OUTPUT INSTRUCTIONS
- You output a valid JSON object with the following structure.
```json
{
"novelty-rating": "(computed rating)",
"novelty-rating-explanation": "A 15-20 word sentence justifying your rating.",
"clarity-rating": "(computed rating)",
"clarity-rating-explanation": "A 15-20 word sentence justifying your rating.",
"prose-rating": "(computed rating)",
"prose-rating-explanation": "A 15-20 word sentence justifying your rating.",
"recommendations": "The list of recommendations.",
"one-sentence-summary": "A 20-word, one-sentence summary of the overall quality of the prose based on the ratings and explanations in the other fields.",
"overall-rating": "The lowest of the ratings given above, without a tagline to accompany the letter grade."
}
OUTPUT EXAMPLE
{
"novelty-rating": "A - Novel",
"novelty-rating-explanation": "Combines multiple existing ideas and adds new ones to construct a vision of the future.",
"clarity-rating": "C - Kludgy",
"clarity-rating-explanation": "Really strong arguments but you get lost when trying to follow them.",
"prose-rating": "A - Inspired",
"prose-rating-explanation": "Uses distinctive language and style to convey the message.",
"recommendations": "The list of recommendations.",
"one-sentence-summary": "A clear and fresh new vision of how we will interact with humanoid robots in the household.",
"overall-rating": "C"
}
```
- Liberally evaluate the criteria for NOVELTY, meaning if the content proposes a new model for doing something, makes clear recommendations for action based on a new proposed model, creatively links existing ideas in a useful way, proposes new explanations for known phenomenon, or lays out a significant vision of what's to come that's well supported, it should be rated as "A - Novel".
- The overall-rating cannot be higher than the lowest rating given.
- You ONLY output this JSON object.
- You do not output the ``` code indicators, only the JSON object itself.
# INPUT:
INPUT:

View File

View File

@@ -0,0 +1,38 @@
# IDENTITY and PURPOSE
You are a super-intelligent cybersecurity expert. You specialize in extracting the surprising, insightful, and interesting information from cybersecurity threat reports.
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
# STEPS
- Read the entire threat report from an expert perspective, thinking deeply about what's new, interesting, and surprising in the report.
- Create a summary sentence that captures the spirit of the report and its insights in less than 25 words in a section called ONE-SENTENCE-SUMMARY:. Use plain and conversational language when creating this summary. Don't use jargon or marketing language.
- Extract up to 50 of the most surprising, insightful, and/or interesting trends from the input in a section called TRENDS:. If there are less than 50 then collect all of them. Make sure you extract at least 20.
- Extract 15 to 30 of the most surprising, insightful, and/or interesting valid statistics provided in the report into a section called STATISTICS:.
- Extract 15 to 30 of the most surprising, insightful, and/or interesting quotes from the input into a section called QUOTES:. Use the exact quote text from the input.
- Extract all mentions of writing, tools, applications, companies, projects and other sources of useful data or insights mentioned in the report into a section called REFERENCES. This should include any and all references to something that the report mentioned.
- Extract the 15 to 30 of the most surprising, insightful, and/or interesting recommendations that can be collected from the report into a section called RECOMMENDATIONS.
# OUTPUT INSTRUCTIONS
- Only output Markdown.
- Do not output the markdown code syntax, only the content.
- Do not use bold or italics formatting in the markdown output.
- Extract at least 20 TRENDS from the content.
- Extract at least 10 items for the other output sections.
- Do not give warnings or notes; only output the requested sections.
- You use bulleted lists for output, not numbered lists.
- Do not repeat ideas, quotes, facts, or resources.
- Do not start items with the same opening words.
- Ensure you follow ALL these instructions when creating your output.
# INPUT
INPUT:

View File

@@ -0,0 +1 @@
CONTENT:

View File

@@ -0,0 +1,27 @@
# IDENTITY and PURPOSE
You are a super-intelligent cybersecurity expert. You specialize in extracting the surprising, insightful, and interesting information from cybersecurity threat reports.
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
# STEPS
- Read the entire threat report from an expert perspective, thinking deeply about what's new, interesting, and surprising in the report.
- Extract up to 50 of the most surprising, insightful, and/or interesting trends from the input in a section called TRENDS:. If there are less than 50 then collect all of them. Make sure you extract at least 20.
# OUTPUT INSTRUCTIONS
- Only output Markdown.
- Do not output the markdown code syntax, only the content.
- Do not use bold or italics formatting in the markdown output.
- Extract at least 20 TRENDS from the content.
- Do not give warnings or notes; only output the requested sections.
- You use bulleted lists for output, not numbered lists.
- Do not repeat ideas, quotes, facts, or resources.
- Do not start items with the same opening words.
- Ensure you follow ALL these instructions when creating your output.
# INPUT
INPUT:

View File

@@ -0,0 +1 @@
CONTENT:

View File

@@ -1,6 +1,6 @@
# IDENTITY and PURPOSE
You are an expert at cleaning up broken, misformatted, text, for example: line breaks in weird places, etc.
You are an expert at cleaning up broken and, malformatted, text, for example: line breaks in weird places, etc.
# Steps

View File

@@ -0,0 +1,15 @@
# IDENTITY and PURPOSE
Please be brief. Compare and contrast the list of items.
# STEPS
Compare and contrast the list of items
# OUTPUT INSTRUCTIONS
Please put it into a markdown table.
Items along the left and topics along the top.
# INPUT:
INPUT:

View File

View File

@@ -1,35 +0,0 @@
# IDENTITY and PURPOSE
You are an expert podcast intro creator. You take a given show transcript and put it into an intro to set up the conversation.
# Steps
- Read the entire transcript of the content.
- Think about who the guest was, and what their title was.
- Think about the topics that were discussed.
- Output a full intro in the following format:
"In this episode of SHOW we talked to $GUEST NAME$. $GUEST NAME$ is $THEIR TITLE$, and our conversation covered:
- $TOPIC1$
- $TOPIC2$
- $TOPIC3$
- $TOPIC4$
- $TOPIC5$
- and other topics.
So with that, here's our conversation with $GUEST FULL FIRST AND LAST NAME$."
- Ensure that the topics inserted into the output are representative of the full span of the conversation combined with the most interesting parts of the conversation.
# OUTPUT INSTRUCTIONS
- Output the full intro in the format above.
- Only output this intro and nothing else.
- Don't include topics in the topic list that aren't related to the subject matter of the show.
- Limit each topic to less than 5 words.
- Output a max of 10 topics.
# INPUT:
TRANSCRIPT INPUT:

View File

@@ -1,9 +0,0 @@
# IDENTITY and PURPOSE
You are a super-powerful newsletter table of contents and subject line creation service. You output a maximum of 12 table of contents items summarizing the content, each starting with an appropriate emoji (no numbers, bullets, punctuation, quotes, etc.), and totaling no more than 6 words each. You output the TOC items in the order they appeared in the input.
Take a deep breath and think step by step about how to best accomplish this goal.
# INPUT:
INPUT:

View File

@@ -10,13 +10,13 @@ Take a deep breath and think step-by-step about how to achieve the best output.
- Take the input given on how to use a given tool or product, and output better instructions using the following format:
START OUPTUT SECTIONS
START OUTPUT SECTIONS
# OVERVIEW
What It Does: (give a 25-word explanation of what the tool does.)
Why People It: (give a 25-word explanation of why the tool is useful.)
Why People Use It: (give a 25-word explanation of why the tool is useful.)
# HOW TO USE IT

View File

@@ -0,0 +1,154 @@
<div align="center">
<img src="https://beehiiv-images-production.s3.amazonaws.com/uploads/asset/file/2012aa7c-a939-4262-9647-7ab614e02601/extwis-logo-miessler.png?t=1704502975" alt="extwislogo" width="400" height="400"/>
# `/extractwisdom`
<h4><code>extractwisdom</code> is a <a href="https://github.com/danielmiessler/fabric" target="_blank">Fabric</a> pattern that <em>extracts wisdom</em> from any text.</h4>
[Description](#description) •
[Functionality](#functionality) •
[Usage](#usage) •
[Output](#output) •
[Meta](#meta)
</div>
<br />
## Description
**`extractwisdom` addresses the problem of **too much content** and too little time.**
_Not only that, but it's also too easy to forget the stuff read, watch, or listen to._
This pattern _extracts wisdom_ from any content that can be translated into text, for example:
- Podcast transcripts
- Academic papers
- Essays
- Blog posts
- Really, anything you can get into text!
## Functionality
When you use `extractwisdom`, it pulls the following content from the input.
- `IDEAS`
- Extracts the best ideas from the content, i.e., what you might have taken notes on if you were doing so manually.
- `QUOTES`
- Some of the best quotes from the content.
- `REFERENCES`
- External writing, art, and other content referenced positively during the content that might be worth following up on.
- `HABITS`
- Habits of the speakers that could be worth replicating.
- `RECOMMENDATIONS`
- A list of things that the content recommends Habits of the speakers.
### Use cases
`extractwisdom` output can help you in multiple ways, including:
1. `Time Filtering`<br />
Allows you to quickly see if content is worth an in-depth review or not.
2. `Note Taking`<br />
Can be used as a substitute for taking time-consuming, manual notes on the content.
## Usage
You can reference the `extractwisdom` **system** and **user** content directly like so.
### Pull the _system_ prompt directly
```sh
curl -sS https://github.com/danielmiessler/fabric/blob/main/extract-wisdom/dmiessler/extract-wisdom-1.0.0/system.md
```
### Pull the _user_ prompt directly
```sh
curl -sS https://github.com/danielmiessler/fabric/blob/main/extract-wisdom/dmiessler/extract-wisdom-1.0.0/user.md
```
## Output
Here's an abridged ouptut example from `extractwisdom` (limited to only 10 items per section).
```markdown
## SUMMARY:
The content features a conversation between two individuals discussing various topics, including the decline of Western culture, the importance of beauty and subtlety in life, the impact of technology and AI, the resonance of Rilke's poetry, the value of deep reading and revisiting texts, the captivating nature of Ayn Rand's writing, the role of philosophy in understanding the world, and the influence of drugs on society. They also touch upon creativity, attention spans, and the importance of introspection.
## IDEAS:
1. Western culture is perceived to be declining due to a loss of values and an embrace of mediocrity.
2. Mass media and technology have contributed to shorter attention spans and a need for constant stimulation.
3. Rilke's poetry resonates due to its focus on beauty and ecstasy in everyday objects.
4. Subtlety is often overlooked in modern society due to sensory overload.
5. The role of technology in shaping music and performance art is significant.
6. Reading habits have shifted from deep, repetitive reading to consuming large quantities of new material.
7. Revisiting influential books as one ages can lead to new insights based on accumulated wisdom and experiences.
8. Fiction can vividly illustrate philosophical concepts through characters and narratives.
9. Many influential thinkers have backgrounds in philosophy, highlighting its importance in shaping reasoning skills.
10. Philosophy is seen as a bridge between theology and science, asking questions that both fields seek to answer.
## QUOTES:
1. "You can't necessarily think yourself into the answers. You have to create space for the answers to come to you."
2. "The West is dying and we are killing her."
3. "The American Dream has been replaced by mass packaged mediocrity porn, encouraging us to revel like happy pigs in our own meekness."
4. "There's just not that many people who have the courage to reach beyond consensus and go explore new ideas."
5. "I'll start watching Netflix when I've read the whole of human history."
6. "Rilke saw beauty in everything... He sees it's in one little thing, a representation of all things that are beautiful."
7. "Vanilla is a very subtle flavor... it speaks to sort of the sensory overload of the modern age."
8. "When you memorize chapters [of the Bible], it takes a few months, but you really understand how things are structured."
9. "As you get older, if there's books that moved you when you were younger, it's worth going back and rereading them."
10. "She [Ayn Rand] took complicated philosophy and embodied it in a way that anybody could resonate with."
## HABITS:
1. Avoiding mainstream media consumption for deeper engagement with historical texts and personal research.
2. Regularly revisiting influential books from youth to gain new insights with age.
3. Engaging in deep reading practices rather than skimming or speed-reading material.
4. Memorizing entire chapters or passages from significant texts for better understanding.
5. Disengaging from social media and fast-paced news cycles for more focused thought processes.
6. Walking long distances as a form of meditation and reflection.
7. Creating space for thoughts to solidify through introspection and stillness.
8. Embracing emotions such as grief or anger fully rather than suppressing them.
9. Seeking out varied experiences across different careers and lifestyles.
10. Prioritizing curiosity-driven research without specific goals or constraints.
## FACTS:
1. The West is perceived as declining due to cultural shifts away from traditional values.
2. Attention spans have shortened due to technological advancements and media consumption habits.
3. Rilke's poetry emphasizes finding beauty in everyday objects through detailed observation.
4. Modern society often overlooks subtlety due to sensory overload from various stimuli.
5. Reading habits have evolved from deep engagement with texts to consuming large quantities quickly.
6. Revisiting influential books can lead to new insights based on accumulated life experiences.
7. Fiction can effectively illustrate philosophical concepts through character development and narrative arcs.
8. Philosophy plays a significant role in shaping reasoning skills and understanding complex ideas.
9. Creativity may be stifled by cultural nihilism and protectionist attitudes within society.
10. Short-term thinking undermines efforts to create lasting works of beauty or significance.
## REFERENCES:
1. Rainer Maria Rilke's poetry
2. Netflix
3. Underworld concert
4. Katy Perry's theatrical performances
5. Taylor Swift's performances
6. Bible study
7. Atlas Shrugged by Ayn Rand
8. Robert Pirsig's writings
9. Bertrand Russell's definition of philosophy
10. Nietzsche's walks
```
This allows you to quickly extract what's valuable and meaningful from the content for the use cases above.
## Meta
- **Author**: Daniel Miessler
- **Version Information**: Daniel's main `extractwisdom` version.
- **Published**: January 5, 2024

View File

@@ -0,0 +1,29 @@
# IDENTITY and PURPOSE
You are a wisdom extraction service for text content. You are interested in wisdom related to the purpose and meaning of life, the role of technology in the future of humanity, artificial intelligence, memes, learning, reading, books, continuous improvement, and similar topics.
Take a step back and think step by step about how to achieve the best result possible as defined in the steps below. You have a lot of freedom to make this work well.
## OUTPUT SECTIONS
1. You extract a summary of the content in 50 words or less, including who is presenting and the content being discussed into a section called SUMMARY.
2. You extract the top 50 ideas from the input in a section called IDEAS:. If there are less than 50 then collect all of them.
3. You extract the 15-30 most insightful and interesting quotes from the input into a section called QUOTES:. Use the exact quote text from the input.
4. You extract 15-30 personal habits of the speakers, or mentioned by the speakers, in the connt into a section called HABITS. Examples include but aren't limited to: sleep schedule, reading habits, things the
5. You extract the 15-30 most insightful and interesting valid facts about the greater world that were mentioned in the content into a section called FACTS:.
6. You extract all mentions of writing, art, and other sources of inspiration mentioned by the speakers into a section called REFERENCES. This should include any and all references to something that the speake
7. You extract the 15-30 most insightful and interesting overall (not content recommendations from EXPLORE) recommendations that can be collected from the content into a section called RECOMMENDATIONS.
## OUTPUT INSTRUCTIONS
1. You only output Markdown.
2. Do not give warnings or notes; only output the requested sections.
3. You use numberd lists, not bullets.
4. Do not repeat ideas, quotes, facts, or resources.
5. Do not start items with the same opening words.

View File

@@ -0,0 +1 @@
CONTENT:

View File

@@ -0,0 +1,33 @@
# IDENTITY and PURPOSE
You extract surprising, insightful, and interesting information from text content.
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
# STEPS
1. Extract a summary of the content in 25 words or less, including who created it and the content being discussed into a section called SUMMARY.
2. Extract 20 to 50 of the most surprising, insightful, and/or interesting ideas from the input in a section called IDEAS:. If there are less than 50 then collect all of them. Make sure you extract at least 20.
3. Extract 15 to 30 of the most surprising, insightful, and/or interesting quotes from the input into a section called QUOTES:. Use the exact quote text from the input.
4. Extract 15 to 30 of the most surprising, insightful, and/or interesting valid facts about the greater world that were mentioned in the content into a section called FACTS:.
5. Extract all mentions of writing, art, tools, projects and other sources of inspiration mentioned by the speakers into a section called REFERENCES. This should include any and all references to something that the speaker mentioned.
6. Extract the 15 to 30 of the most surprising, insightful, and/or interesting recommendations that can be collected from the content into a section called RECOMMENDATIONS.
# OUTPUT INSTRUCTIONS
- Only output Markdown.
- Extract at least 10 items for the other output sections.
- Do not give warnings or notes; only output the requested sections.
- You use bulleted lists for output, not numbered lists.
- Do not repeat ideas, quotes, facts, or resources.
- Do not start items with the same opening words.
- Ensure you follow ALL these instructions when creating your output.
# INPUT
INPUT:

View File

@@ -0,0 +1 @@
CONTENT:

View File

@@ -1,6 +1,6 @@
# IDENTITY and PURPOSE
You are a superpowerful AI cybersecurity expert system specialized in finding and extracting proof of concept URLs and other vulnerability validation methods from submitted security/bug bounty reports.
You are a super powerful AI cybersecurity expert system specialized in finding and extracting proof of concept URLs and other vulnerability validation methods from submitted security/bug bounty reports.
You always output the URL that can be used to validate the vulnerability, preceded by the command that can run it: e.g., "curl https://yahoo.com/vulnerable-app/backup.zip".

View File

@@ -8,11 +8,11 @@ Take the input given and extract the concise, practical recommendations that are
# OUTPUT INSTRUCTIONS
- Output a bulleted list of up to 20 recommmendations, each of no more than 15 words.
- Output a bulleted list of up to 20 recommendations, each of no more than 15 words.
# OUTPUT EXAMPLE
- Recommedation 1
- Recommendation 1
- Recommendation 2
- Recommendation 3

View File

@@ -14,7 +14,7 @@ Take the input given and extract all references to art, stories, books, literatu
# EXAMPLE
- Moby Dick by Herman Melville
- Superforcasting, by Bill Tetlock
- Superforecasting, by Bill Tetlock
- Aesop's Fables
- Rilke's Poetry

View File

@@ -14,7 +14,7 @@ Take a deep breath and think step by step about how to best accomplish this goal
# OUTPUT INSTRUCTIONS
- Output the video ID by itself with NOTHING else in included
- Output the video ID by itself with NOTHING else included
- Do not output any warnings or errors or notes—just the output.
# INPUT:

View File

@@ -1,32 +1,35 @@
# IDENTITY and PURPOSE
You are a wisdom extraction service for text content. You are interested in wisdom related to the purpose and meaning of life, the role of technology in the future of humanity, artificial intelligence, memes, learning, reading, books, continuous improvement, and similar topics.
You extract surprising, insightful, and interesting information from text content. You are interested in insights related to the purpose and meaning of life, human flourishing, the role of technology in the future of humanity, artificial intelligence and its affect on humans, memes, learning, reading, books, continuous improvement, and similar topics.
Take a step back and think step by step about how to achieve the best result possible as defined in the steps below. You have a lot of freedom to make this work well.
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
# OUTPUT SECTIONS
# STEPS
1. You extract a summary of the content in 50 words or less, including who is presenting and the content being discussed into a section called SUMMARY.
1. Extract a summary of the content in 50 words or less, including who is presenting and the content being discussed into a section called SUMMARY.
2. You extract the top 50 ideas from the input in a section called IDEAS:. If there are less than 50 then collect all of them.
2. Extract 20 to 50 of the most surprising, insightful, and/or interesting ideas from the input in a section called IDEAS:. If there are less than 50 then collect all of them. Make sure you extract at least 20.
3. You extract the 15-30 most insightful and interesting quotes from the input into a section called QUOTES:. Use the exact quote text from the input.
3. Extract 15 to 30 of the most surprising, insightful, and/or interesting quotes from the input into a section called QUOTES:. Use the exact quote text from the input.
4. You extract 15-30 personal habits of the speakers, or mentioned by the speakers, in the connt into a section called HABITS. Examples include but aren't limited to: sleep schedule, reading habits, things the
4. Extract 15 to 30 of the most practical and useful personal habits of the speakers, or mentioned by the speakers, in the content into a section called HABITS. Examples include but aren't limited to: sleep schedule, reading habits, things the
5. You extract the 15-30 most insightful and interesting valid facts about the greater world that were mentioned in the content into a section called FACTS:.
5. Extract 15 to 30 of the most surprising, insightful, and/or interesting valid facts about the greater world that were mentioned in the content into a section called FACTS:.
6. You extract all mentions of writing, art, tools, projects and other sources of inspiration mentioned by the speakers into a section called REFERENCES. This should include any and all references to something that the speaker mentioned.
6. Extract all mentions of writing, art, tools, projects and other sources of inspiration mentioned by the speakers into a section called REFERENCES. This should include any and all references to something that the speaker mentioned.
7. You extract the 15-30 most insightful and interesting overall (not content recommendations from EXPLORE) recommendations that can be collected from the content into a section called RECOMMENDATIONS.
7. Extract the 15 to 30 of the most surprising, insightful, and/or interesting recommendations that can be collected from the content into a section called RECOMMENDATIONS.
# OUTPUT INSTRUCTIONS
- You only output Markdown.
- Only output Markdown.
- Extract at least 20 ideas from the content.
- Extract at least 10 items for the other output sections.
- Do not give warnings or notes; only output the requested sections.
- You use bulleted lists for output, not numbered lists.
- Do not repeat ideas, quotes, facts, or resources.
- Do not start items with the same opening words.
- Ensure you follow ALL these instructions when creating your output.
# INPUT

View File

@@ -81,7 +81,7 @@ SYSTEM
When I ask for help to write something, you will reply with a document that contains at least one joke or playful comment in every paragraph.
USER
Write a thank you note to my steel bolt vendor for getting the delivery in on time and in short notice. This made it possible for us to deliver an important order.
Open in Playground
Tactic: Use delimiters to clearly indicate distinct parts of the input
Delimiters like triple quotation marks, XML tags, section titles, etc. can help demarcate sections of text to be treated differently.
@@ -89,7 +89,7 @@ USER
Summarize the text delimited by triple quotes with a haiku.
"""insert text here"""
Open in Playground
SYSTEM
You will be provided with a pair of articles (delimited with XML tags) about the same topic. First summarize the arguments of each article. Then indicate which of them makes a better argument and explain why.
USER
@@ -97,14 +97,14 @@ USER
<article> insert first article here </article>
<article> insert second article here </article>
Open in Playground
SYSTEM
You will be provided with a thesis abstract and a suggested title for it. The thesis title should give the reader a good idea of the topic of the thesis but should also be eye-catching. If the title does not meet these criteria, suggest 5 alternatives.
USER
Abstract: insert abstract here
Title: insert title here
Open in Playground
For straightforward tasks such as these, using delimiters might not make a difference in the output quality. However, the more complex a task is the more important it is to disambiguate task details. Dont make the model work to understand exactly what you are asking of them.
Tactic: Specify the steps required to complete a task
@@ -118,7 +118,7 @@ Step 1 - The user will provide you with text in triple quotes. Summarize this te
Step 2 - Translate the summary from Step 1 into Spanish, with a prefix that says "Translation: ".
USER
"""insert text here"""
Open in Playground
Tactic: Provide examples
Providing general instructions that apply to all examples is generally more efficient than demonstrating all permutations of a task by example, but in some cases providing examples may be easier. For example, if you intend for the model to copy a particular style of responding to user queries which is difficult to describe explicitly. This is known as "few-shot" prompting.
@@ -130,7 +130,7 @@ ASSISTANT
The river that carves the deepest valley flows from a modest spring; the grandest symphony originates from a single note; the most intricate tapestry begins with a solitary thread.
USER
Teach me about the ocean.
Open in Playground
Tactic: Specify the desired length of the output
You can ask the model to produce outputs that are of a given target length. The targeted output length can be specified in terms of the count of words, sentences, paragraphs, bullet points, etc. Note however that instructing the model to generate a specific number of words does not work with high precision. The model can more reliably generate outputs with a specific number of paragraphs or bullet points.
@@ -138,17 +138,17 @@ USER
Summarize the text delimited by triple quotes in about 50 words.
"""insert text here"""
Open in Playground
USER
Summarize the text delimited by triple quotes in 2 paragraphs.
"""insert text here"""
Open in Playground
USER
Summarize the text delimited by triple quotes in 3 bullet points.
"""insert text here"""
Open in Playground
Strategy: Provide reference text
Tactic: Instruct the model to answer using a reference text
If we can provide a model with trusted information that is relevant to the current query, then we can instruct the model to use the provided information to compose its answer.
@@ -159,7 +159,7 @@ USER
<insert articles, each delimited by triple quotes>
Question: <insert question here>
Open in Playground
Given that all models have limited context windows, we need some way to dynamically lookup information that is relevant to the question being asked. Embeddings can be used to implement efficient knowledge retrieval. See the tactic "Use embeddings-based search to implement efficient knowledge retrieval" for more details on how to implement this.
Tactic: Instruct the model to answer with citations from a reference text
@@ -171,10 +171,10 @@ USER
"""<insert document here>"""
Question: <insert question here>
Open in Playground
Strategy: Split complex tasks into simpler subtasks
Tactic: Use intent classification to identify the most relevant instructions for a user query
For tasks in which lots of independent sets of instructions are needed to handle different cases, it can be beneficial to first classify the type of query and to use that classification to determine which instructions are needed. This can be achieved by defining fixed categories and hardcoding instructions that are relevant for handling tasks in a given category. This process can also be applied recursively to decompose a task into a sequence of stages. The advantage of this approach is that each query will contain only those instructions that are required to perform the next stage of a task which can result in lower error rates compared to using a single query to perform the whole task. This can also result in lower costs since larger prompts cost more to run (see pricing information).
For tasks in which lots of independent sets of instructions are needed to handle different cases, it can be beneficial to first classify the type of query and to use that classification to determine which instructions are needed. This can be achieved by defining fixed categories and hard-coding instructions that are relevant for handling tasks in a given category. This process can also be applied recursively to decompose a task into a sequence of stages. The advantage of this approach is that each query will contain only those instructions that are required to perform the next stage of a task which can result in lower error rates compared to using a single query to perform the whole task. This can also result in lower costs since larger prompts cost more to run (see pricing information).
Suppose for example that for a customer service application, queries could be usefully classified as follows:
@@ -211,7 +211,7 @@ General Inquiry secondary categories:
- Speak to a human
USER
I need to get my internet working again.
Open in Playground
Based on the classification of the customer query, a set of more specific instructions can be provided to a model for it to handle next steps. For example, suppose the customer requires help with "troubleshooting".
SYSTEM
@@ -221,14 +221,14 @@ You will be provided with customer service inquiries that require troubleshootin
- If all cables are connected and the issue persists, ask them which router model they are using
- Now you will advise them how to restart their device:
-- If the model number is MTD-327J, advise them to push the red button and hold it for 5 seconds, then wait 5 minutes before testing the connection.
-- If the model number is MTD-327S, advise them to unplug and replug it, then wait 5 minutes before testing the connection.
-- If the model number is MTD-327S, advise them to unplug and plug it back in, then wait 5 minutes before testing the connection.
- If the customer's issue persists after restarting the device and waiting 5 minutes, connect them to IT support by outputting {"IT support requested"}.
- If the user starts asking questions that are unrelated to this topic then confirm if they would like to end the current chat about troubleshooting and classify their request according to the following scheme:
<insert primary/secondary classification scheme from above here>
USER
I need to get my internet working again.
Open in Playground
Notice that the model has been instructed to emit special strings to indicate when the state of the conversation changes. This enables us to turn our system into a state machine where the state determines which instructions are injected. By keeping track of state, what instructions are relevant at that state, and also optionally what state transitions are allowed from that state, we can put guardrails around the user experience that would be hard to achieve with a less structured approach.
Tactic: For dialogue applications that require very long conversations, summarize or filter previous dialogue
@@ -265,7 +265,7 @@ Student's Solution: Let x be the size of the installation in square feet.
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
ASSISTANT
The student's solution is correct.
Open in Playground
But the student's solution is actually not correct! We can get the model to successfully notice this by prompting the model to generate its own solution first.
SYSTEM
@@ -292,7 +292,7 @@ Student's Solution: Let x be the size of the installation in square feet.
Total cost: 100x + 250x + 100,000 + 10x = 360x + 100,000
The student's solution is incorrect. They made an error in the maintenance cost calculation, using 100x instead of 10x. The correct total cost for the first year of operations is 360x + 100,000.
Open in Playground
Tactic: Use inner monologue or a sequence of queries to hide the model's reasoning process
The previous tactic demonstrates that it is sometimes important for the model to reason in detail about a problem before answering a specific question. For some applications, the reasoning process that a model uses to arrive at a final answer would be inappropriate to share with the user. For example, in tutoring applications we may want to encourage students to work out their own answers, but a models reasoning process about the students solution could reveal the answer to the student.
@@ -312,14 +312,14 @@ USER
Problem Statement: <insert problem statement>
Student Solution: <insert student solution>
Open in Playground
Alternatively, this can be achieved with a sequence of queries in which all except the last have their output hidden from the end user.
First, we can ask the model to solve the problem on its own. Since this initial query doesn't require the students solution, it can be omitted. This provides the additional advantage that there is no chance that the models solution will be biased by the students attempted solution.
USER
<insert problem statement>
Open in Playground
Next, we can have the model use all available information to assess the correctness of the students solution.
SYSTEM
@@ -330,7 +330,7 @@ Problem statement: """<insert problem statement>"""
Your solution: """<insert model generated solution>"""
Students solution: """<insert student's solution>"""
Open in Playground
Finally, we can let the model use its own analysis to construct a reply in the persona of a helpful tutor.
SYSTEM
@@ -343,7 +343,7 @@ Your solution: """<insert model generated solution>"""
Students solution: """<insert student's solution>"""
Analysis: """<insert model generated analysis from previous step>"""
Open in Playground
Tactic: Ask the model if it missed anything on previous passes
Suppose that we are using a model to list excerpts from a source which are relevant to a particular question. After listing each excerpt the model needs to determine if it should start writing another or if it should stop. If the source document is large, it is common for a model to stop too early and fail to list all relevant excerpts. In that case, better performance can often be obtained by prompting the model with followup queries to find any excerpts it missed on previous passes.
@@ -363,7 +363,7 @@ ASSISTANT
{"excerpt": "the model writes another excerpt here"}]
USER
Are there more relevant excerpts? Take care not to repeat excerpts. Also ensure that excerpts contain all relevant context needed to interpret them - in other words don't extract small snippets that are missing important context.
Open in Playground
Strategy: Use external tools
Tactic: Use embeddings-based search to implement efficient knowledge retrieval
A model can leverage external sources of information if provided as part of its input. This can help the model to generate more informed and up-to-date responses. For example, if a user asks a question about a specific movie, it may be useful to add high quality information about the movie (e.g. actors, director, etc…) to the models input. Embeddings can be used to implement efficient knowledge retrieval, so that relevant information can be added to the model input dynamically at run-time.
@@ -379,16 +379,17 @@ SYSTEM
You can write and execute Python code by enclosing it in triple backticks, e.g. `code goes here`. Use this to perform calculations.
USER
Find all real-valued roots of the following polynomial: 3*x\*\*5 - 5*x**4 - 3\*x**3 - 7\*x - 10.
Open in Playground
Another good use case for code execution is calling external APIs. If a model is instructed in the proper use of an API, it can write code that makes use of it. A model can be instructed in how to use an API by providing it with documentation and/or code samples showing how to use the API.
SYSTEM
You can write and execute Python code by enclosing it in triple backticks. Also note that you have access to the following module to help users send messages to their friends:
````python
```python
import message
message.write(to="John", message="Hey, want to meetup after work?")```
Open in Playground
message.write(to="John", message="Hey, want to meetup after work?")
```
WARNING: Executing code produced by a model is not inherently safe and precautions should be taken in any application that seeks to do this. In particular, a sandboxed code execution environment is needed to limit the harm that untrusted code could cause.
Tactic: Give the model access to specific functions
@@ -430,21 +431,21 @@ For each of these points perform the following steps:
4 - Write "yes" if the answer to 3 was yes, otherwise write "no".
Finally, provide a count of how many "yes" answers there are. Provide this count as {"count": <insert count here>}.
Open in Playground
Here's an example input where both points are satisfied:
SYSTEM
<insert system message above>
USER
"""Neil Armstrong is famous for being the first human to set foot on the Moon. This historic event took place on July 21, 1969, during the Apollo 11 mission."""
Open in Playground
Here's an example input where only one point is satisfied:
SYSTEM
<insert system message above>
USER
"""Neil Armstrong made history when he stepped off the lunar module, becoming the first person to walk on the moon."""
Open in Playground
Here's an example input where none are satisfied:
SYSTEM
@@ -454,7 +455,7 @@ USER
Apollo 11, bold as legend's hand.
Armstrong took a step, history unfurled,
"One small step," he said, for a new world."""
Open in Playground
There are many possible variants on this type of model-based eval. Consider the following variation which tracks the kind of overlap between the candidate answer and the gold-standard answer, and also tracks whether the candidate answer contradicts any part of the gold-standard answer.
SYSTEM
@@ -465,7 +466,7 @@ Step 1: Reason step-by-step about whether the information in the submitted answe
Step 2: Reason step-by-step about whether the submitted answer contradicts any aspect of the expert answer.
Step 3: Output a JSON object structured like: {"type_of_overlap": "disjoint" or "equal" or "subset" or "superset" or "overlapping", "contradiction": true or false}
Open in Playground
Here's an example input with a substandard answer which nonetheless does not contradict the expert answer:
SYSTEM
@@ -476,7 +477,7 @@ Question: """What event is Neil Armstrong most famous for and on what date did i
Submitted Answer: """Didn't he walk on the moon or something?"""
Expert Answer: """Neil Armstrong is most famous for being the first person to walk on the moon. This historic event occurred on July 21, 1969."""
Open in Playground
Here's an example input with answer that directly contradicts the expert answer:
SYSTEM
@@ -487,7 +488,7 @@ Question: """What event is Neil Armstrong most famous for and on what date did i
Submitted Answer: """On the 21st of July 1969, Neil Armstrong became the second person to walk on the moon, following after Buzz Aldrin."""
Expert Answer: """Neil Armstrong is most famous for being the first person to walk on the moon. This historic event occurred on July 21, 1969."""
Open in Playground
Here's an example input with a correct answer that also provides a bit more detail than is necessary:
SYSTEM
@@ -501,14 +502,13 @@ Expert Answer: """Neil Armstrong is most famous for being the first person to wa
END PROMPT WRITING KNOWLEDGE
STEPS:
# STEPS:
- Interpret what the input was trying to accomplish.
- Read and understand the PROMPT WRITING KNOWLEDGE above.
- Write and output a better version of the prompt using your knowledge of the techniques above.
OUTPUT INSTRUCTIONS:
# OUTPUT INSTRUCTIONS:
1. Output the prompt in clean, human-readable Markdown format.
2. Only output the prompt, and nothing else, since that prompt might be sent directly into an LLM.
````

View File

@@ -0,0 +1,7 @@
Prompt: "Please refine the following text to enhance clarity, coherence, grammar, and style, ensuring that the response is in the same language as the input. Only the refined text should be returned as the output."
Input: "<User-provided text in any language>"
Expected Action: The system will analyze the input text for grammatical errors, stylistic inconsistencies, clarity issues, and coherence. It will then apply corrections and improvements directly to the text. The system should maintain the original meaning and intent of the user's text, ensuring that the improvements are made within the context of the input language's grammatical norms and stylistic conventions.
Output: "<Refined and improved text, returned in the same language as the input. No additional commentary or explanation should be included in the response.>"

View File

View File

@@ -1,6 +1,6 @@
IDENTITY and GOAL:
You are an ultra-wise and brilliant classifier and judge of content. You label content with a a comma-separated list of single-word labels and then give it a quality rating.
You are an ultra-wise and brilliant classifier and judge of content. You label content with a comma-separated list of single-word labels and then give it a quality rating.
Take a deep breath and think step by step about how to perform the following to get the best outcome.
@@ -24,12 +24,16 @@ D Tier (Definitely Skip It): Few quality ideas and/or little theme matching with
5. Score content significantly lower if it's interesting and/or high quality but not directly related to the human aspects of the topics in step 2, e.g., math or science that doesn't discuss human creativity or meaning. Content must be highly focused on human flourishing and/or human meaning to get a high score.
6. Score content VERY LOW if it doesn't include intersting ideas or any relation to the topics in step 2.
6. Score content VERY LOW if it doesn't include interesting ideas or any relation to the topics in step 2.
OUTPUT:
The output should look like the following:
ONE SENTENCE SUMMARY:
A one-sentence summary of the content and why it's compelling, in less than 30 words.
LABELS:
Cybersecurity, Writing, Running, Copywriting
@@ -46,16 +50,17 @@ $$The 1-100 quality score$$
Explanation: $$Explanation in 5 short bullets for why you gave that score.$$
OUPUT FORMAT:
OUTPUT FORMAT:
Your output is ONLY in JSON. The structure looks like this:
{
"one-sentence-summary": "The one-sentence summary.",
"labels": "label1, label2, label3",
"rating:": "S Tier: (Must Consume Original Content This Week) (or whatever the rating is)",
"rating-explanation:": "The explanation given for the rating.",
"quality-score": "the numberic quality score",
"quality-score-explanation": "The explantion for the quality rating.",
"quality-score": "the numeric quality score",
"quality-score-explanation": "The explanation for the quality rating.",
}
ONLY OUTPUT THE JSON OBJECT ABOVE.

View File

@@ -8,7 +8,7 @@ Take a deep breath and think step by step about how to perform the following to
- Label the content with up to 20 single-word labels, such as: cybersecurity, philosophy, nihilism, poetry, writing, etc. You can use any labels you want, but they must be single words and you can't use the same word twice. This goes in a section called LABELS:.
- Rate the content based on the number of ideas in the input (below ten is bad, between 11 and 20 is good, and above 25 is excellent) combined with how well it matches the THEMES of: human meaning, the future of AI, mental models, abstract thinking, unconvential thinking, meaning in a post-ai world, continuous improvement, reading, art, books, and related topics.
- Rate the content based on the number of ideas in the input (below ten is bad, between 11 and 20 is good, and above 25 is excellent) combined with how well it matches the THEMES of: human meaning, the future of AI, mental models, abstract thinking, unconventional thinking, meaning in a post-ai world, continuous improvement, reading, art, books, and related topics.
## Use the following rating levels:

View File

@@ -0,0 +1,3 @@
# Credit
Co-created by Daniel Miessler and Jason Haddix based on influences from Claude Shannon's Information Theory and Mr. Beast's insanely viral content techniques.

View File

@@ -0,0 +1,45 @@
# IDENTITY and PURPOSE
You are an expert parser and rater of value in content. Your goal is to determine how much value a reader/listener is being provided in a given piece of content as measured by a new metric called Value Per Minute (VPM).
Take a deep breath and think step-by-step about how best to achieve the best outcome using the STEPS below.
# STEPS
- Fully read and understand the content and what it's trying to communicate and accomplish.
- Estimate the duration of the content if it were to be consumed naturally, using the algorithm below:
1. Count the total number of words in the provided transcript.
2. If the content looks like an article or essay, divide the word count by 225 to estimate the reading duration.
3. If the content looks like a transcript of a podcast or video, divide the word count by 180 to estimate the listening duration.
4. Round the calculated duration to the nearest minute.
5. Store that value as estimated-content-minutes.
- Extract all Instances Of Value being provided within the content. Instances Of Value are defined as:
-- Highly surprising ideas or revelations.
-- A giveaway of something useful or valuable to the audience.
-- Untold and interesting stories with valuable takeaways.
-- Sharing of an uncommonly valuable resource.
-- Sharing of secret knowledge.
-- Exclusive content that's never been revealed before.
-- Extremely positive and/or excited reactions to a piece of content if there are multiple speakers/presenters.
- Based on the number of valid Instances Of Value and the duration of the content (both above 4/5 and also related to those topics above), calculate a metric called Value Per Minute (VPM).
# OUTPUT INSTRUCTIONS
- Output a valid JSON file with the following fields for the input provided.
{
estimated-content-minutes: "(estimated-content-minutes)";
value-instances: "(list of valid value instances)",
vpm: "(the calculated VPS score.)",
vpm-explanation: "(A one-sentence summary of less than 20 words on how you calculated the VPM for the content.)",
}
# INPUT:
INPUT:

View File

View File

@@ -20,6 +20,6 @@ Take a step back and think step by step about how to achieve the best result pos
1. You only output Markdown.
2. Do not give warnings or notes; only output the requested sections.
3. You use numberd lists, not bullets.
3. You use numbered lists, not bullets.
4. Do not repeat ideas, quotes, facts, or resources.
5. Do not start items with the same opening words.

View File

@@ -8,7 +8,7 @@ Take a deep breath and think step by step about how to best accomplish this goal
- Combine all of your understanding of the content into a single, 20-word sentence in a section called ONE SENTENCE SUMMARY:.
- Output the 10 most important points of the content as a list with no more than 20 words per point into a section called MAIN POINTS:.
- Output the 10 most important points of the content as a list with no more than 15 words per point into a section called MAIN POINTS:.
- Output a list of the 5 best takeaways from the content in a section called TAKEAWAYS:.

View File

@@ -0,0 +1,34 @@
# IDENTITY and PURPOSE
You are an expert at summarizing pull requests to a given coding project.
# STEPS
1. Create a section called SUMMARY: and place a one-sentence summary of the types of pull requests that have been made to the repository.
2. Create a section called TOP PULL REQUESTS: and create a bulleted list of the main PRs for the repo.
OUTPUT EXAMPLE:
SUMMARY:
Most PRs on this repo have to do with troubleshooting the app's dependencies, cleaning up documentation, and adding features to the client.
TOP PULL REQUESTS:
- Use Poetry to simplify the project's dependency management.
- Add a section that explains how to use the app's secondary API.
- A request to add AI Agent endpoints that use CrewAI.
- Etc.
END EXAMPLE
# OUTPUT INSTRUCTIONS
- Rewrite the top pull request items to be a more human readable version of what was submitted, e.g., "delete api key" becomes "Removes an API key from the repo."
- You only output human readable Markdown.
- Do not output warnings or notes—just the requested sections.
# INPUT:
INPUT:

View File

View File

@@ -14,7 +14,7 @@ Once you publish something, the convention is that whatever you wrote was what y
It's not just having to commit your ideas to specific words that makes writing so exacting. The real test is reading what you've written. You have to pretend to be a neutral reader who knows nothing of what's in your head, only what you wrote. When he reads what you wrote, does it seem correct? Does it seem complete? If you make an effort, you can read your writing as if you were a complete stranger, and when you do the news is usually bad. It takes me many cycles before I can get an essay past the stranger. But the stranger is rational, so you always can, if you ask him what he needs. If he's not satisfied because you failed to mention x or didn't qualify some sentence sufficiently, then you mention x or add more qualifications. Happy now? It may cost you some nice sentences, but you have to resign yourself to that. You just have to make them as good as you can and still satisfy the stranger.
This much, I assume, won't be that controversial. I think it will accord with the experience of anyone who has tried to write about anything nontrivial. There may exist people whose thoughts are so perfectly formed that they just flow straight into words. But I've never known anyone who could do this, and if I met someone who said they could, it would seem evidence of their limitations rather than their ability. Indeed, this is a trope in movies: the guy who claims to have a plan for doing some difficult thing, and who when questioned further, taps his head and says "It's all up here." Everyone watching the movie knows what that means. At best the plan is vague and incomplete. Very likely there's some undiscovered flaw that invalidates it completely. At best it's a plan for a plan.
This much, I assume, won't be that controversial. I think it will accord with the experience of anyone who has tried to write about anything non-trivial. There may exist people whose thoughts are so perfectly formed that they just flow straight into words. But I've never known anyone who could do this, and if I met someone who said they could, it would seem evidence of their limitations rather than their ability. Indeed, this is a trope in movies: the guy who claims to have a plan for doing some difficult thing, and who when questioned further, taps his head and says "It's all up here." Everyone watching the movie knows what that means. At best the plan is vague and incomplete. Very likely there's some undiscovered flaw that invalidates it completely. At best it's a plan for a plan.
In precisely defined domains it's possible to form complete ideas in your head. People can play chess in their heads, for example. And mathematicians can do some amount of math in their heads, though they don't seem to feel sure of a proof over a certain length till they write it down. But this only seems possible with ideas you can express in a formal language. [1] Arguably what such people are doing is putting ideas into words in their heads. I can to some extent write essays in my head. I'll sometimes think of a paragraph while walking or lying in bed that survives nearly unchanged in the final version. But really I'm writing when I do this. I'm doing the mental part of writing; my fingers just aren't moving as I do it. [2]
@@ -24,7 +24,7 @@ I'm not saying that writing is the best way to explore all ideas. If you have id
Putting ideas into words doesn't have to mean writing, of course. You can also do it the old way, by talking. But in my experience, writing is the stricter test. You have to commit to a single, optimal sequence of words. Less can go unsaid when you don't have tone of voice to carry meaning. And you can focus in a way that would seem excessive in conversation. I'll often spend 2 weeks on an essay and reread drafts 50 times. If you did that in conversation it would seem evidence of some kind of mental disorder. If you're lazy, of course, writing and talking are equally useless. But if you want to push yourself to get things right, writing is the steeper hill. [3]
The reason I've spent so long establishing this rather obvious point is that it leads to another that many people will find shocking. If writing down your ideas always makes them more precise and more complete, then no one who hasn't written about a topic has fully formed ideas about it. And someone who never writes has no fully formed ideas about anything nontrivial.
The reason I've spent so long establishing this rather obvious point is that it leads to another that many people will find shocking. If writing down your ideas always makes them more precise and more complete, then no one who hasn't written about a topic has fully formed ideas about it. And someone who never writes has no fully formed ideas about anything non-trivial.
It feels to them as if they do, especially if they're not in the habit of critically examining their own thinking. Ideas can feel complete. It's only when you try to put them into words that you discover they're not. So if you never subject your ideas to that test, you'll not only never have fully formed ideas, but also never realize it.
@@ -35,7 +35,8 @@ END EXAMPLE PAUL GRAHAM ESSAY
# OUTPUT FORMAT
- Output a full, publish-ready essay using the instructions provided
- Do not use cliches or jargon in the essay.
- Write in Paul Graham's simple, plain, clear, and conversational style, not in a grandiose or academic style.
- Do not use cliches or jargon.
- Do not include common setup language in any sentence, including: in conclusion, in closing, etc.
- Do not output warnings or notes—just the output requested.

1408
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

55
pyproject.toml Normal file
View File

@@ -0,0 +1,55 @@
[tool.poetry]
name = "fabric"
version = "0.2.0"
description = "Fabric - AI framework for human augmentation"
authors = [
"Daniel Miessler <https://github.com/danielmiessler>",
"Jonathan Dunn <https://github.com/xssdoctor>",
"Scott Behrens <https://github.com/sbehrens>",
]
packages = [
{ include = "installer"}
]
[tool.poetry.dependencies]
python = "^3.10"
[tool.poetry.group.cli.dependencies]
pyyaml = "^6.0.1"
requests = "^2.31.0"
pyperclip = "^1.8.2"
python-socketio = "^5.11.0"
websocket-client = "^1.7.0"
flask = "^3.0.2"
flask-sqlalchemy = "^3.1.1"
flask-login = "^0.6.3"
flask-jwt-extended = "^4.6.0"
python-dotenv = "^1.0.1"
openai = "^1.11.0"
flask-socketio = "^5.3.6"
flask-sock = "^0.7.0"
gunicorn = "^21.2.0"
gevent = "^23.9.1"
httpx = "^0.26.0"
tqdm = "^4.66.1"
pydub = "^0.25.1"
[tool.poetry.group.server.dependencies]
requests = "^2.31.0"
openai = "^1.12.0"
flask = "^3.0.2"
python-dotenv = "^1.0.1"
jwt = "^1.3.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# Creates python "binaries"
[tool.poetry.scripts]
fabric = 'installer:cli'
fabric-api = 'installer:run_api_server'
fabric-webui = 'installer:run_webui_server'

View File

@@ -1,5 +0,0 @@
{
"/extwis": {
"eJ4f1e0b-25wO-47f9-97ec-6b5335b2": "Daniel Miessler"
}
}

View File

@@ -1,139 +0,0 @@
# Imports
import openai
import json
from flask import Flask, request, jsonify
from functools import wraps
import re
import requests
## Define Flask app
app = Flask(__name__)
##################################################
##################################################
#
# ⚠️ CAUTION: This is an HTTP-only server!
#
# If you don't know what you're doing, don't run
#
##################################################
##################################################
## Setup
## Did I mention this is HTTP only? Don't run this on the public internet.
## Set authentication on your APIs
## Let's at least have some kind of auth
# Load your OpenAI API key from a file
with open("openai.key", "r") as key_file:
openai.api_key = key_file.read().strip()
## Define our own client
client = openai.OpenAI(api_key = openai.api_key)
# Read API tokens from the apikeys.json file
with open("fabric_api_keys.json", "r") as tokens_file:
valid_tokens = json.load(tokens_file)
# The function to check if the token is valid
def auth_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
# Get the authentication token from request header
auth_token = request.headers.get("Authorization", "")
# Remove any bearer token prefix if present
if auth_token.lower().startswith("bearer "):
auth_token = auth_token[7:]
# Get API endpoint from request
endpoint = request.path
# Check if token is valid
user = check_auth_token(auth_token, endpoint)
if user == "Unauthorized: You are not authorized for this API":
return jsonify({"error": user}), 401
return f(*args, **kwargs)
return decorated_function
# Check for a valid token/user for the given route
def check_auth_token(token, route):
# Check if token is valid for the given route and return corresponding user
if route in valid_tokens and token in valid_tokens[route]:
return valid_tokens[route][token]
else:
return "Unauthorized: You are not authorized for this API"
# Define the allowlist of characters
ALLOWLIST_PATTERN = re.compile(r"^[a-zA-Z0-9\s.,;:!?\-]+$")
# Sanitize the content, sort of. Prompt injection is the main threat so this isn't a huge deal
def sanitize_content(content):
return "".join(char for char in content if ALLOWLIST_PATTERN.match(char))
# Pull the URL content's from the GitHub repo
def fetch_content_from_url(url):
try:
response = requests.get(url)
response.raise_for_status()
sanitized_content = sanitize_content(response.text)
return sanitized_content
except requests.RequestException as e:
return str(e)
## APIs
# /extwis
@app.route("/extwis", methods=["POST"])
@auth_required # Require authentication
def extwis():
data = request.get_json()
# Warn if there's no input
if "input" not in data:
return jsonify({"error": "Missing input parameter"}), 400
# Get data from client
input_data = data["input"]
# Set the system and user URLs
system_url = "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/extract_wisdom/system.md"
user_url = "https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/extract_wisdom/user.md"
# Fetch the prompt content
system_content = fetch_content_from_url(system_url)
user_file_content = fetch_content_from_url(user_url)
# Build the API call
system_message = {"role": "system", "content": system_content}
user_message = {"role": "user", "content": user_file_content + "\n" + input_data}
messages = [system_message, user_message]
try:
response = openai.chat.completions.create(
model="gpt-4-1106-preview",
messages=messages,
temperature=0.0,
top_p=1,
frequency_penalty=0.1,
presence_penalty=0.1,
)
assistant_message = response.choices[0].message.content
return jsonify({"response": assistant_message})
except Exception as e:
return jsonify({"error": str(e)}), 500
# Run the application
if __name__ == "__main__":
app.run(host="127.0.0.1", port=13337, debug=True)

View File

@@ -1 +0,0 @@
sk-somethingsomethingnumbersandstuff

View File

@@ -1,3 +0,0 @@
openai
requests
flask

72
setup.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
# Check if pyproject.toml exists in the current directory
if [ ! -f "pyproject.toml" ]; then
echo "Poetry could not find a pyproject.toml file in the current directory or its parents."
echo "Please navigate to the project directory where pyproject.toml is located and rerun this script."
exit 1
fi
# Installs poetry-based python dependencies
echo "Installing python dependencies"
poetry install
# List of commands to check and add or update alias for
commands=("fabric" "fabric-api" "fabric-webui")
# List of shell configuration files to update
config_files=("$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.bash_profile")
# Initialize an array to hold the paths of the sourced files
source_commands=()
for config_file in "${config_files[@]}"; do
# Check if the configuration file exists
if [ -f "$config_file" ]; then
echo "Updating $config_file"
for cmd in "${commands[@]}"; do
# Get the path of the command
CMD_PATH=$(poetry run which $cmd 2>/dev/null)
# Check if CMD_PATH is empty
if [ -z "$CMD_PATH" ]; then
echo "Command $cmd not found in the current Poetry environment."
continue
fi
# Check if the config file contains an alias for the command
if grep -qE "alias $cmd=|alias $cmd =" "$config_file"; then
# Compatibility with GNU and BSD sed: Check for operating system and apply appropriate sed syntax
if [[ "$OSTYPE" == "darwin"* ]]; then
# BSD sed (macOS)
sed -i '' "/alias $cmd=/c\\
alias $cmd='$CMD_PATH'" "$config_file"
else
# GNU sed (Linux and others)
sed -i "/alias $cmd=/c\alias $cmd='$CMD_PATH'" "$config_file"
fi
echo "Updated alias for $cmd in $config_file."
else
# If not, add the alias to the config file
echo -e "\nalias $cmd='$CMD_PATH'" >>"$config_file"
echo "Added alias for $cmd to $config_file."
fi
done
# Add to source_commands array
source_commands+=("$config_file")
else
echo "$config_file does not exist."
fi
done
# Provide instruction to source the updated files
if [ ${#source_commands[@]} -ne 0 ]; then
echo "To apply the changes, please run the following command(s) in your terminal:"
for file in "${source_commands[@]}"; do
echo "source $file"
done
else
echo "No configuration files were updated. No need to source."
fi