Fabric icon indicating copy to clipboard operation
Fabric copied to clipboard

[Feature request]: Fabric output to an .org file rather than .md

Open rrottier opened this issue 8 months ago • 5 comments

What do you need?

Fabric can already output to .md files for integration with obsidian, could support of .org files be added as well? I could post-convert the files using pandoc, but in the interest of lowering friction I wonder if native org output could be supported.

rrottier avatar Mar 21 '25 06:03 rrottier

WIth the right prompts you can also get the information from many LLMs in Org mode:

I asked gpt-4o:

fabric 'Why is the sky blue? Output the information in Org-mode'

The response verbatim (after "Certainly! Here's the explanation formatted in Org-mode:")

* Why is the sky blue?
The color of the sky is primarily due to a phenomenon known as *Rayleigh scattering*.

** Rayleigh Scattering
- Rayleigh scattering occurs when sunlight passes through the Earth's atmosphere.
- The atmosphere is composed of various gases and particles that scatter sunlight in different directions.
- Sunlight, or white light, is made up of many colors, each with different wavelengths.

** Wavelength and Scattering
- Blue light has a shorter wavelength compared to other visible colors like red.
- Shorter wavelengths are scattered more efficiently by the small particles and gases in the atmosphere.
- As a result, blue light is scattered in all directions, making the sky appear predominantly blue to our eyes.

** Position of the Sun
- The sky can appear different colors depending on the position of the sun.
  - During sunrise and sunset, the sky can appear reddish or orange.
  - This is because the light passes through a greater thickness of the atmosphere, scattering shorter wavelengths and leaving longer wavelengths like red and orange.

** Summary
- The blue color of the sky is due to the scattering of sunlight by the Earth's atmosphere.
- This scattering is more effective at shorter wavelengths, hence the prevalence of blue light.

ksylvan avatar Mar 23 '25 15:03 ksylvan

Thanks, that is certainly something I can look into. As you say though, it depends on the model and i would either have to update all the patterns I use to explicitly output to org or I need to pay for the extra token to do the conversion as a second step.

PS. Is there any way to specify as part of the pattern which model/s should be used to run it?

rrottier avatar Mar 24 '25 02:03 rrottier

Here is another idea. Put this file in ~/.config/fabric/strategies/org-mode.json:

{
    "description": "Org-Mode output",
    "prompt": "Answer the question, and return the final answer in Org-mode format. I repeat: return the answer in Org-Mode format and ignore any other formatting request."
}

Now, you have an org-mode strategy:

$ fabric --liststrategies                                                                                            
Available Strategies:

cod               Chain-of-Draft (CoD) Prompting
cot               Chain-of-Thought (CoT) Prompting
ltm               Least-to-Most Prompting
org-mode          Org-Mode output
reflexion         Reflexion Prompting
self-consistent   Self-Consistency Prompting
self-refine       Self-Refinement
standard          Standard Prompting
tot               Tree-of-Thought (ToT) Prompting

And you can do things like this:

$ echo 'The connections between Computer Science and Number Theory' | create_keynote -m gpt-4o --strategy org-mode 
` ` `org
* FLOW
1. Introduction to Computer Science and Number Theory
2. Brief history of Number Theory
3. Fundamental concepts in Computer Science
4. Key connections: Algorithms and Number Theory
5. Cryptography: A vital link
6. Prime numbers and computer security
7. Random number generation and Number Theory
8. Computational complexity and Number Theory
9. Applications in modern technology
10. Future directions and research opportunities

* DESIRED TAKEAWAY
Computer Science and Number Theory are deeply interconnected, driving innovations in technology and cryptography.

* PRESENTATION
1. **Title: Introduction to Computer Science and Number Theory**
   - Explore two critical fields
   - Understanding their interconnections
   - Impact on technology and cryptography
   - Image: Two interlocking gears labeled CS and NT
   - Speaker notes: "Today, we dive into the synergy between Computer Science and Number Theory."

2. **Title: Brief History of Number Theory**
   - Origin in ancient mathematics
   - Key historical milestones
   - Influence on modern theories
   - Image: Timeline of Number Theory milestones
   - Speaker notes: "Let's take a journey through the history of Number Theory."

3. **Title: Fundamental Concepts in Computer Science**
   - Algorithms and data structures
   - Computational theory basics
   - Importance of efficiency
   - Image: Diagram of a basic algorithm
   - Speaker notes: "We'll now review core Computer Science concepts crucial for our discussion."

4. **Title: Key Connections: Algorithms and Number Theory**
   - Algorithm efficiency
   - Number Theory applications
   - Optimization techniques
   - Image: Flowchart connecting algorithms to Number Theory
   - Speaker notes: "Algorithms often leverage Number Theory for efficiency and optimization."

5. **Title: Cryptography: A Vital Link**
   - Secure communication
   - Encryption methods
   - Role of Number Theory
   - Image: Encrypted message with a lock symbol
   - Speaker notes: "Cryptography heavily relies on Number Theory for secure data transmission."

6. **Title: Prime Numbers and Computer Security**
   - Importance of primes
   - RSA encryption
   - Security implications
   - Image: Illustration of prime numbers in a lock
   - Speaker notes: "Prime numbers are foundational in securing digital communications."

7. **Title: Random Number Generation and Number Theory**
   - Pseudorandom generators
   - Statistical properties
   - Applications in simulations
   - Image: Dice with numbers and formulas
   - Speaker notes: "Random number generation uses Number Theory to ensure unpredictability."

8. **Title: Computational Complexity and Number Theory**
   - Problem-solving challenges
   - Complexity classes
   - Influence on algorithm design
   - Image: Complexity chart with Number Theory elements
   - Speaker notes: "Number Theory helps us understand and tackle computational complexity."

9. **Title: Applications in Modern Technology**
   - Data encryption
   - Secure transactions
   - Error detection and correction
   - Image: Smartphone with security icons
   - Speaker notes: "These connections impact everything from online banking to error correction."

10. **Title: Future Directions and Research Opportunities**
    - Emerging trends
    - Interdisciplinary research
    - Innovation potential
    - Image: Brainstorming session with futuristic technology
    - Speaker notes: "The future holds exciting possibilities at the intersection of these fields."
` ` `

Without specifying the --strategy argument, the output is basically markdown.

PS. Is there any way to specify as part of the pattern which model/s should be used to run it?

I don't know of one. Some models, like DeepSeek, do some weird stuff with their output, like outputting a bunch of preamble between <think></think> blocks. You can pretty easily do some post-processing to eliminate that front matter.

ksylvan avatar Mar 24 '25 05:03 ksylvan

@ksylvan Fantastic solution. Worked flawlessly in my test.

asifm avatar Apr 11 '25 08:04 asifm

@asifm Awesome! I'm glad it worked for you. It's an interesting use case for strategies.

ksylvan avatar Apr 11 '25 08:04 ksylvan

Closing this issue.

ksylvan avatar Jul 06 '25 09:07 ksylvan