From 48bda7a4900b584c5a78d2eba43afdce972c4514 Mon Sep 17 00:00:00 2001 From: agu3rra Date: Sat, 17 Feb 2024 14:35:07 -0300 Subject: [PATCH 01/10] adds templates on the repo --- .github/ISSUE_TEMPLATE/bug.yml | 37 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 13 ++++++++ .github/ISSUE_TEMPLATE/question.yml | 12 +++++++ .github/pull_request_template.md | 9 ++++++ 4 files changed, 71 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..602d0e7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -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. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..7510ea1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..1c201e1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -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 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..90e8adc --- /dev/null +++ b/.github/pull_request_template.md @@ -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. From 8aacaee643079665e82c836138e6969dc1f515c9 Mon Sep 17 00:00:00 2001 From: Daniel Miessler Date: Sat, 17 Feb 2024 19:03:45 -0800 Subject: [PATCH 02/10] Added a specific version of extract_wisdom just for articles. --- patterns/extract_article_wisdom/README.md | 154 ++++++++++++++++++ .../dmiessler/extract_wisdom-1.0.0/system.md | 29 ++++ .../dmiessler/extract_wisdom-1.0.0/user.md | 1 + patterns/extract_article_wisdom/system.md | 33 ++++ patterns/extract_article_wisdom/user.md | 1 + 5 files changed, 218 insertions(+) create mode 100644 patterns/extract_article_wisdom/README.md create mode 100644 patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/system.md create mode 100644 patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/user.md create mode 100644 patterns/extract_article_wisdom/system.md create mode 100644 patterns/extract_article_wisdom/user.md diff --git a/patterns/extract_article_wisdom/README.md b/patterns/extract_article_wisdom/README.md new file mode 100644 index 0000000..1c45a35 --- /dev/null +++ b/patterns/extract_article_wisdom/README.md @@ -0,0 +1,154 @@ +
+ +extwislogo + +# `/extractwisdom` + +

extractwisdom is a Fabric pattern that extracts wisdom from any text.

+ +[Description](#description) • +[Functionality](#functionality) • +[Usage](#usage) • +[Output](#output) • +[Meta](#meta) + +
+ +
+ +## 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`
+ Allows you to quickly see if content is worth an in-depth review or not. +2. `Note Taking`
+ 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 diff --git a/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/system.md b/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/system.md new file mode 100644 index 0000000..5e02fd7 --- /dev/null +++ b/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/system.md @@ -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. diff --git a/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/user.md b/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/user.md new file mode 100644 index 0000000..b8504b7 --- /dev/null +++ b/patterns/extract_article_wisdom/dmiessler/extract_wisdom-1.0.0/user.md @@ -0,0 +1 @@ +CONTENT: diff --git a/patterns/extract_article_wisdom/system.md b/patterns/extract_article_wisdom/system.md new file mode 100644 index 0000000..9174b73 --- /dev/null +++ b/patterns/extract_article_wisdom/system.md @@ -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: diff --git a/patterns/extract_article_wisdom/user.md b/patterns/extract_article_wisdom/user.md new file mode 100644 index 0000000..b8504b7 --- /dev/null +++ b/patterns/extract_article_wisdom/user.md @@ -0,0 +1 @@ +CONTENT: From 0deab1ebb3fa706fc08fa3b86b248168817443ca Mon Sep 17 00:00:00 2001 From: Daniel Miessler Date: Sat, 17 Feb 2024 19:35:09 -0800 Subject: [PATCH 03/10] Updated analyze_paper with more detail and legibility. --- patterns/analyze_paper/system.md | 50 +++++++++----------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/patterns/analyze_paper/system.md b/patterns/analyze_paper/system.md index b42c0a7..8054563 100644 --- a/patterns/analyze_paper/system.md +++ b/patterns/analyze_paper/system.md @@ -6,53 +6,31 @@ 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 From b127fbec15f50ca9f39f77c5d28db622d9a3ccbb Mon Sep 17 00:00:00 2001 From: Daniel Miessler Date: Sat, 17 Feb 2024 19:38:12 -0800 Subject: [PATCH 04/10] Updated analyze_paper with more detail and legibility. --- patterns/analyze_paper/system.md | 1 + 1 file changed, 1 insertion(+) diff --git a/patterns/analyze_paper/system.md b/patterns/analyze_paper/system.md index 8054563..77ba384 100644 --- a/patterns/analyze_paper/system.md +++ b/patterns/analyze_paper/system.md @@ -36,6 +36,7 @@ Take a deep breath and think step by step about how to best accomplish this goal - 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: From 8f4ab672c6b905f54dd5f31ea0f45d4ec9dc1faf Mon Sep 17 00:00:00 2001 From: jad2121 Date: Sun, 18 Feb 2024 13:25:07 -0500 Subject: [PATCH 05/10] added context to cli. edit context.md and add -C to add context to your queries --- installer/client/cli/context.md | 3 ++ installer/client/cli/fabric.py | 18 ++++++++-- installer/client/cli/utils.py | 58 +++++++++++++++++++-------------- setup.sh | 14 +++++++- 4 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 installer/client/cli/context.md diff --git a/installer/client/cli/context.md b/installer/client/cli/context.md new file mode 100644 index 0000000..d18dc68 --- /dev/null +++ b/installer/client/cli/context.md @@ -0,0 +1,3 @@ +# Context + +The user should place a context here diff --git a/installer/client/cli/fabric.py b/installer/client/cli/fabric.py index 315ef78..f2a24b3 100755 --- a/installer/client/cli/fabric.py +++ b/installer/client/cli/fabric.py @@ -5,6 +5,8 @@ import os script_directory = os.path.dirname(os.path.realpath(__file__)) +context_file = os.path.join(script_directory, "context.md") + def main(): parser = argparse.ArgumentParser( @@ -31,7 +33,8 @@ def main(): 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" @@ -42,6 +45,8 @@ def main(): 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("~") @@ -80,10 +85,19 @@ def main(): text = args.text else: text = standalone.get_cli_input() - if args.stream: + if args.stream and not args.context: standalone.streamMessage(text) + if args.stream and args.context: + with open(context_file, "r") as f: + context = f.read() + standalone.streamMessage(text, context=context) + elif args.context: + with open(context_file, "r") as f: + context = f.read() + standalone.sendMessage(text, context=context) else: standalone.sendMessage(text) + if __name__ == "__main__": main() diff --git a/installer/client/cli/utils.py b/installer/client/cli/utils.py index 9f0e522..3379e8c 100644 --- a/installer/client/cli/utils.py +++ b/installer/client/cli/utils.py @@ -13,7 +13,6 @@ 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. @@ -49,7 +48,7 @@ class Standalone: self.args = args self.model = args.model - def streamMessage(self, input_data: str): + def streamMessage(self, input_data: str, context=""): """ Stream a message and handle exceptions. Args: @@ -71,7 +70,10 @@ class Standalone: if self.pattern: try: with open(wisdom_File, "r") as f: - system = f.read() + 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: @@ -109,7 +111,7 @@ class Standalone: with open(self.args.output, "w") as f: f.write(buffer) - def sendMessage(self, input_data: str): + def sendMessage(self, input_data: str, context=""): """ Send a message using the input data and generate a response. Args: @@ -130,7 +132,10 @@ class Standalone: if self.pattern: try: with open(wisdom_File, "r") as f: - system = f.read() + 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: @@ -159,28 +164,30 @@ class Standalone: def fetch_available_models(self): headers = { - "Authorization": f"Bearer { self.client.api_key }" + "Authorization": f"Bearer {self.client.api_key}" } - - response = requests.get("https://api.openai.com/v1/models", headers=headers) + + 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"))] + 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: @@ -191,7 +198,8 @@ class Standalone: if not sys.stdin.isatty(): # Check if input is being piped return sys.stdin.read().strip() # Read piped input else: - return input("Enter Question: ") # Prompt user for input from console + # Prompt user for input from console + return input("Enter Question: ") else: return sys.stdin.read() @@ -209,7 +217,8 @@ class Update: 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") + 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. @@ -313,7 +322,9 @@ class Update: ) 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}") + print( + f"Failed to fetch directory contents due to an HTTP error: {e}") + class Setup: def __init__(self): @@ -324,7 +335,8 @@ class Setup: """ self.config_directory = os.path.expanduser("~/.config/fabric") - self.pattern_directory = os.path.join(self.config_directory, "patterns") + 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") @@ -370,25 +382,25 @@ class Setup: 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) @@ -399,5 +411,3 @@ class Transcribe: except Exception as e: print("Error:", e) return None - - diff --git a/setup.sh b/setup.sh index 810597c..acfb5c3 100755 --- a/setup.sh +++ b/setup.sh @@ -10,6 +10,9 @@ commands=("fabric" "fabric-api" "fabric-webui") # List of shell configuration files to update config_files=(~/.bashrc ~/.zshrc ~/.bash_profile) +# Initialize an empty string to hold the path of the sourced file +source_command="" + for config_file in "${config_files[@]}"; do # Check if the configuration file exists if [ -f "$config_file" ]; then @@ -29,9 +32,18 @@ for config_file in "${config_files[@]}"; do echo "Added alias for $cmd to $config_file." fi done + # Set source_command to source the updated file + source_command="source $config_file" else echo "$config_file does not exist." fi done -echo "Please close this terminal window to have new aliases work." \ No newline at end of file +# Provide instruction to source the updated file +if [ ! -z "$source_command" ]; then + echo "To apply the changes, please run the following command in your terminal:" + echo "$source_command" +else + echo "No configuration files were updated. No need to source." +fi + From d15e022abfc75165270df6b2aa9efa29f0c870f6 Mon Sep 17 00:00:00 2001 From: jad2121 Date: Sun, 18 Feb 2024 16:34:47 -0500 Subject: [PATCH 06/10] fixed context --- installer/client/cli/context.md | 2 +- installer/client/cli/fabric.py | 4 ++-- installer/client/cli/utils.py | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/installer/client/cli/context.md b/installer/client/cli/context.md index d18dc68..4a7052a 100644 --- a/installer/client/cli/context.md +++ b/installer/client/cli/context.md @@ -1,3 +1,3 @@ # Context -The user should place a context here +please give all responses in spanish diff --git a/installer/client/cli/fabric.py b/installer/client/cli/fabric.py index f2a24b3..bdeba6e 100755 --- a/installer/client/cli/fabric.py +++ b/installer/client/cli/fabric.py @@ -14,7 +14,7 @@ def main(): ) 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", @@ -45,7 +45,7 @@ def main(): parser.add_argument( "--listmodels", help="List all available models", action="store_true" ) - parser.add_argument('--context', '-C', + parser.add_argument('--context', '-c', help="Use Context file (context.md) to add context to your pattern", action="store_true") args = parser.parse_args() diff --git a/installer/client/cli/utils.py b/installer/client/cli/utils.py index 3379e8c..f3ccf00 100644 --- a/installer/client/cli/utils.py +++ b/installer/client/cli/utils.py @@ -80,7 +80,11 @@ class Standalone: print("pattern not found") return else: - messages = [user_message] + 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, @@ -142,7 +146,11 @@ class Standalone: print("pattern not found") return else: - messages = [user_message] + 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, From a0d264bead2a3d11b57cd4d779047b5388d94055 Mon Sep 17 00:00:00 2001 From: jad2121 Date: Sun, 18 Feb 2024 16:36:17 -0500 Subject: [PATCH 07/10] updated readme --- installer/client/cli/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/installer/client/cli/README.md b/installer/client/cli/README.md index d2f9219..c512e84 100644 --- a/installer/client/cli/README.md +++ b/installer/client/cli/README.md @@ -32,7 +32,8 @@ 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: From 335fea353b07dce0eb330776bb2401b7e28a4f64 Mon Sep 17 00:00:00 2001 From: jad2121 Date: Sun, 18 Feb 2024 16:48:47 -0500 Subject: [PATCH 08/10] now context.md is in .config --- installer/client/cli/fabric.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/installer/client/cli/fabric.py b/installer/client/cli/fabric.py index bdeba6e..0ddc79c 100755 --- a/installer/client/cli/fabric.py +++ b/installer/client/cli/fabric.py @@ -5,7 +5,6 @@ import os script_directory = os.path.dirname(os.path.realpath(__file__)) -context_file = os.path.join(script_directory, "context.md") def main(): @@ -52,6 +51,7 @@ def main(): 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) @@ -68,6 +68,10 @@ def main(): Update() print("Your Patterns have been updated.") 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: @@ -88,11 +92,11 @@ def main(): if args.stream and not args.context: standalone.streamMessage(text) if args.stream and args.context: - with open(context_file, "r") as f: + with open(config_context, "r") as f: context = f.read() standalone.streamMessage(text, context=context) elif args.context: - with open(context_file, "r") as f: + with open(config_context, "r") as f: context = f.read() standalone.sendMessage(text, context=context) else: From 9863573ff6d1eb7afc1a214d38fdbd14b7944eec Mon Sep 17 00:00:00 2001 From: Fureigh Date: Sun, 18 Feb 2024 17:05:08 -0800 Subject: [PATCH 09/10] Remove stray .DS_Store file --- patterns/.DS_Store | Bin 12292 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 patterns/.DS_Store diff --git a/patterns/.DS_Store b/patterns/.DS_Store deleted file mode 100644 index 630ca07ad550ea76400e0606dd58c940d3d656b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12292 zcmeHNZ)_Ar6n}5q!Y*CfEwr>8S2(Cj#8diDNb zHYP+3sL@YG(Zo*}iAIeY(T^(riTXiNgE4+UV>HpkXyPXmeY3MiXbTk#QL8hT*|+oN zy}6m+&hEb7%mM(mW%UMt8UT_64F6iJu+H!LvNy|wBNGFpcmg#!+^Vid4c%Wvzr~Y_O~z^RPj>ayON6EUU|LP1elNpl2NPSlyJW!JV#?@!I{y22E<8 zTWML>=r*WPGiP*A({AM?)KNKGR<2ddn_pSApgMBxij~c)*KHU~Iq9@vdv2eVNE+5a zj`x0-PA#-&3_9w)F7;wJQ{3+8=3ORf_M5ieYbVmi9;V)&aJ|kE!#4CYH48(F!nNv> zft=}@Nz3TVo4U7eDB-3ITQ}{!edK5ylq)c*XtTNXGW8l+(-p0R7niHo%i1+K4*b06+VQ6)+dahOI>0b+t&;i?Fm>%$>@E|+}Ps7XbHk^jDa1OqMpWrt{ zEW`O&gUhiVSL1rzj61LsyRirRa1X{Yfl1UcjW&+p0d(~e0A3GSdMF&Y3EFjW*5yj5?S{uA^9nM1>eFC@GBuHVF}K{Qmn)(tR_sC;tFiRR$PN? zu>-sC4#IU84ilm&AJYtan8h67c?9pn`|$yMl(0OGPx@HCfG^@p_y!^O0e*-d;pcdc zfffKK(|cbefq+0jATR*|_I!v?W-=DYaW4Hw2OU@l!RlEE;U_vL9^mUDfs6%moJ-%8 ze0*1u+!X_gf!v++5oS&@7RYffxjP_t2Mqoh1BQbBzms3YHwTPyDUJdGfxuJ*{xtT_ z^<-?zvGMfc~GERPoeT8azp%q+l%1(1YRt-{u;l*AMtky zB$Vbzl~R?oKw2V2q-9c_v`T7`V$v3=UkcX9&J&oSiMOXT{Fm-G!PEs)pJ`0}$|w4y z*V4p0N0crLff8<2!}$NkORxW5R$IbIARrK!nFwHUM^8r^^*!L$Q%1qKc7*aUWtN!T zIG4T)9RfP;*ZEYObiw+uuZxj6^Bd>VccU_Q``Z=)3VRA-<3Ma2P;AcTBBd!C2c(-z z{MM#y!J+dUH$!`2E*O(Sk7;+#l6g0X$Kh0g|9)23Ih!q)%6InA))?PLXiH>vu~M(& zSjob9BH2$HW^t{u-LbudNjn(61CdHH**!p;NKU@Z$=bT>`}Xh(S&@~vws3T`p}x5} z8fk588jD6oTN~@6k>;jVV`GY3<&PYI#Q@Wc^`Gy5OH(wmy0v*q|Laz+?T+ua(zbJy z4+RUCb8axSf;cw)5XBOOSfcnJ?*CoAC5mYtAL7FS@!`M>{BU6U7sh|%{eNZe&%(P@ UNP&PrKp-Fx5C{kaW- Date: Sun, 18 Feb 2024 17:34:39 -0800 Subject: [PATCH 10/10] Minor README edit for verb form consistency Change `Create` to `Creating`. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 920562b..a157797 100644 --- a/README.md +++ b/README.md @@ -96,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