Typeblock founder

Tosh Velaga

Founder of Typeblock

June 9, 2023

Chaining Prompts with no-code

video

Agents vs. Prompt Chains

If you’ve been paying to attention to the recent developments in AI you’ve probably heard of AI agents and prompt chains. Agents are autonomous programs that can execute tasks. The most famous of these is BabyAGI and AutoGPT, which have both been open sourced on Github. Although these agents are interesting and show a glimpse into our AI powered future, currently they have some practical issues. These agents frequently produce unreliable results, finish executing prematurely, and can cause your OpenAI bill to blow up. In contrast to agents, a more reliable way to get things done with large language models is to use prompt chaining.

Screen_Shot_2023-06-09_at_8.57.08_PM.png

Prompt chaining is a way to sequentially chain prompts that have been pre-writen by the user. A practical example of a prompt chain would be a youtube content creation bot. To create the bot we can chain the following prompts:

  1. Brainstorm several ideas for a youtube video on no-code tools
  2. Out of the best ideas that you came up with reason which would get the most views and then write a script.
  3. Based on the script, create an SEO optimized description that we can include once we upload to Youtube

As you can see from the above example we can create powerful automations just by chaining these simple prompts. Additionally we can choose to give these chains access to APIs and the internet to produce even more powerful results. For example in the second step we can give the model access to the Youtube data API to better understand which videos are getting the most views.

Benefits of Prompt Chaining

The reasons to use chains over agents is that you can have better control of the outcome, select optimized models (such as GPT-4, Claude Instant, Cohere, Palm) for each step in the chain depending on the task, and to have better visibility into API spend.

Prompt Chaining Resources

Screen_Shot_2023-06-09_at_9.09.57_PM.png

While building chains you can use either code or no-code solutions. There are several popular open source libraries like LangChain that make building chains easier. The only downside is that it can be time consuming to set these up and you will need to write code that needs to be maintained. An easier way is to use no-code tools like PromptChainer or LangFlow. These tools are very powerful and have a similar drag and drop interface. The only downside with these tools is that they have a somewhat steep learning curve. In the case of LangFlow you also need to be a developer. LangFlow itself is built on top of LangChain and underneath the hood relies on a library called react-flow which gives it the drag-and-drop UI. All the code for LangFlow is open sourced and it currently has over 8000 Github stars showing how popular the library is among developers. LangFlow is an excellent solution if you already have some programming experience while PromptChainer has a hosted site that anyone can use. Additionally with PromptChainer you are given some free credits to play around with.

Potential Applications

There are essentially limitless possibilities that you can do with prompt chains. Interesting use cases include everything from sales, marketing, customer support, to business strategy. One possible application is to create a chain that can read and improve copy on your landing page. Here is a hypothetical chain of prompts. First access the contents of the site and prompt the LLM to suggest improvements in the copy to lead to a higher conversion rate. The second prompt would be to brainstorm blog post ideas based on the copy of your site and the final step would be to actually write the blog posts for each idea. Now you could do something like this with an agent, however, you would have less control over the end result. Another idea is to build a chain that can research prospects and then write cold emails that are highly personalized.

Easiest way to chain prompts without code

Perhaps the easiest way to create powerful chains is to use a tool like Typeblock where you can simply just click “Add a prompt to chain” to create sequential prompt chains. You can of course change the model, temperature, and messages for each prompt giving you maximum flexibility with no learning curve. Typeblock requires zero coding and is free to get started.

Screen_Shot_2023-06-09_at_8.34.45_PM.png