Writing good AI prompts and handling their input and output can be very tedious. One tool that I found to help with this isĀ Fabric, an open-source framework for using AI that runs in your terminal created byĀ Daniel Miessler. It has a lot of pre-configured prompts, which are calledĀ patterns, that are open and easily readable (using the Markdown format), enabling anyone to improve them orĀ create a custom pattern. Besides this, the super power of this tool is the ability to useĀ pipesĀ (|) to easily send the output of one command to another, creating endless possibilities.

Just to give a quick idea of how it works and the use of pipes, here is a command using the extract_book_ideas pattern to extract the main ideas from a book given its title and use the output to make a summary using the summarize pattern:

echo "The Lean Product Playbook" | fabric --stream --pattern extract_book_ideas | fabric --stream --pattern summarize
Bash

Here is an example of the result:

# ONE SENTENCE SUMMARY:
The Lean Product Playbook offers a systematic, customer-centric approach to product development, integrating Lean Startup principles and best practices.

# MAIN POINTS:
1. A systematic approach to product development is emphasized throughout the playbook.
2. It combines Lean Startup principles with effective product management practices.
3. Product-market fit is identified as a crucial factor for success.
4. Early validation of product ideas is encouraged to minimize risks.
5. Customer needs and feedback should guide the entire development process.
6. Iterative design and testing are essential for refining product concepts.
7. Cross-functional collaboration within teams enhances product outcomes.
8. Clear metrics for success must be defined and tracked.
9. A culture of experimentation is promoted to foster innovation.
10. Continuous learning and adaptation are vital for long-term success.

# TAKEAWAYS:
1. Embrace failure as a learning opportunity to improve products.
2. Prioritize features based on customer value for better alignment.
3. Use prototyping and user feedback to iterate quickly on ideas.
4. Foster a collaborative environment to enhance team effectiveness.
Markdown

Now that I’ve got your attention, let’s look how to setup Fabric on Ubuntu Linux.

First, get access to LLM models and other APIs

You need to have this before installing Fabric.

OpenAI

This is required if you want to use OpenAI models.

Before generating an API key I recommend creating a new project just for Fabric, so you can easily monitor it’s usage.

You need to purchase API credits to use their models. Check their pricing page to better understand how much each model cost. GPT-4o mini is their most cost-efficient small model thatā€™s smarter and cheaper than GPT-3.5 Turbo.

Some tips to keep the costs under control:

  1. Go into the “Usage limits” setting page and fill the “Set a monthly budget” and “Set an email notification threshold” fields;
  2. Disable auto recharge.

YouTube

This is required if you want to get YouTube videos transcript.

Follow these official instructions to get YouTube Data API keys. I’ve created a new project just for Fabric and had to manually enable the YouTube Data API v3 in the Enabled APIs page (use the search feature to find this option).

Ollama

This enables you to easily run local models. The installation is very simple and to download a new model is very easy too.

Here is an example using Llama 3.1 with 8B parameter size:

ollama pull llama3.1:8b
Bash

Others

There is also support for Claude and Google models.

Installation and solving some errors

After following the official Fabric installation instructions for Linux I run into the following errors.

Error: RuntimeError: Unsupported compiler — at least C++11 support is needed!

To fix this, just run the following command:

sudo apt-get install build-essential -y
Bash

For reference, here is the complete error message:

Fatal error from pip prevented installation. Full pip output in file:
    /home/kossmann/.local/state/pipx/log/cmd_2024-07-19_16.24.17_pip_errors.log

pip failed to build package:
    chroma-hnswlib

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    RuntimeError: Unsupported compiler -- at least C++11 support is needed!
    ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (chroma-hnswlib)

Error installing fabric from spec '/home/kossmann/workspace/fabric'.
Bash

Couldn’t find ffmpeg or avconv

To fix this, just run the following command:

sudo apt-get install ffmpeg libavcodec-extra
Bash

For reference, here is the complete error message:

/home/kossmann/.local/share/pipx/venvs/fabric/lib/python3.12/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Bash

OpenAI: You exceeded your current quota

This was a little bit confusing because I thought that having a ChatGPT subscription would give me access to the API too, but that’s not the case. You have to purchase API credits separately from your ChatGPT subscription, this is why I already added this in the beginning of the tutorial.

For reference, here is the complete error message:

Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}
Bash

Using specific models for each command

To list available models run:

fabric --listmodels
Bash

To run a command with a specific model just add --model NAME at the end. Here is an example:

fabric --stream --pattern summarize --model gpt-4o-mini
Bash

I’m very excited with this tool and will post more follow ups about it (one will be about using pbpaste and pbcopy on Linux)!

If you want to learn more about the project, I recommend readingĀ Fabric origin story. Daniel Miessler also writes theĀ Unsupervised Learning newsletter, one of my favorite sources of content for Artificial Intelligence.



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *