Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How do I chain/combine outputs before passing them on to the next step? #1226

Closed
michaelgroeger opened this issue Dec 23, 2024 · 3 comments
Labels
question Further information is requested

Comments

@michaelgroeger
Copy link

What is your question?

First, thank you for this great project. I wanted to try it out for a long time and finally could do so, and I love it.

However, I hit a small roadblock. I wanted to adapt the output of one of the patterns a bit before passing it on to my Obsidian vault. Concretly, this is what I want to do:

  1. Get the transcript of this video: https://www.youtube.com/watch?v=q1qKv5TBaOA&ab_channel=Coderized
  2. Summarize the content.
  3. Add examples to each of the points. Possibly, improve the prompt.
  4. Pass on to Obisidian.

Currently, my attempts look like this:
echo "Extract the whole knowldege of the video. Especially the seven deadly sins and how to avoid them. I want to keep that knowledge easily understandable and retrievable in my Obisidian vault. For each Sin, come up with an example. Properly format the output." | improve_prompt | yt https://www.youtube.com/watch\?v\=q1qKv5TBaOA\&ab_channel\=Coderized | summarize | save " How principled coders outperform the competition"

If I understood the tool correctly, I lose my initial and improved prompt between improve_prompt | yt https://www.youtube.com/watch\?v\=q1qKv5TBaOA\&ab_channel\=Coderized because I then pass on the transcript without my improved prompt.

In essence: How can I adjust the patterns using custom instructions on the fly without having to add custom prompts?

Thank you very much for your time and help with this.

@michaelgroeger michaelgroeger added the question Further information is requested label Dec 23, 2024
@javflocor
Copy link

Hi Michael!

I played around with your idea and was able to do the following (multi-step in the terminal):

Step 1: Define the initial prompt:

initial_prompt="Extract the whole knowledge of the video. Especially the seven deadly sins and how to avoid them. I want to keep that knowledge easily understandable and retrievable in my Obsidian vault. For each Sin, come up with an example. Properly format the output."

Step 2: Pipe the initial prompt to the 'improve_prompt' pattern and save the output:

improved_prompt=$(echo "$initial_prompt" | improve_prompt)

Step 3: Extract the YouTube transcript and save it into a variable:

video_transcript=$(yt "https://www.youtube.com/watch?v=q1qKv5TBaOA&ab_channel=Coderized")

Step 4: Concatenate the improved prompt with the video transcript:

combined_text="$improved_prompt
$video_transcript"

Step 5: Pipe the combined text into the summarization pattern:

echo "$combined_text" | summarize "How principled coders outperform the competition"

It is not a long piped instruction but 5 separate instructions that work quite well!
Hope it helps!

@johnconnor-sec
Copy link
Contributor

I'm not sure if this is what you're trying to do but here's how I would try this:

echo "Extract the whole knowldege of the video. Especially the seven deadly sins and how to avoid them. I want to keep that knowledge easily understandable and retrievable in my Obisidian vault. For each Sin, come up with an example. Properly format the output." | improve_prompt -o improved_prompt.txt && echo "$(cat improved_prompt.txt && yt https://www.youtube.com/watch\?v\=q1qKv5TBaOA\&ab_channel\=Coderized)" | summarize >> ~/path/to/vault/"How principled coders outperform the competition.md" 

I hope this helps

@michaelgroeger
Copy link
Author

Thank you two for your answers and your inspirations, in the end I came up with this solution, and it should be useable for all kinds of similar problems:
General Approach:
echo "$(command1) $(command2)" | <fabric_command>

Translated to my problem:
echo "$(echo "Extract the whole knowledge of the video. Especially the seven deadly sins and how to avoid them. I want to keep that knowledge easily understandable and retrievable in my Obisidian vault. For each Sin, come up with an example. Properly format the output." | improve_prompt) $(echo "\nINPUT: \n") $(yt https://www.youtube.com/watch\?v\=q1qKv5TBaOA\&ab_channel\=Coderized)" | ai | save "7 deadly sins of programming"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants