[go: up one dir, main page]

DEV Community

Cover image for Prompt Chaining with AiConfig
Ranjan Dailata
Ranjan Dailata

Posted on • Edited on

Prompt Chaining with AiConfig

Introduction

In this blog post, you will be guided with the prompt chaining techniques with the real-world example. AiConfig will be utilized for this purpose. First, let us try to understand what AiConfig is all about, then we can deep dive in to the prompt chaining.

AiConfig is an easy-to-use configuration driven application development framework. The beauty of AiConfig is, it's a JSON based config. There are various ways of creating the config, including the programmatic capabilities.

I would highly recommend you to start using the LastMileAI workbooks for building the prompt based apps. Download the AiConfig and then start playing with it. Finetune as per your requirements and design or develop an API to serve the prompt based AI Apps.

Prompt Chaining

Let me take you to the world of prompt chaining with a real-world example of "NYC Trip Planner". This one is an extended code sample based on the original code from AiConfig Python repo. The idea of prompt chaining is to execute a series of prompts, with the output of one prompt will be fed to the next one.

Here's the plan. At high-level, we are going to have a two-step based prompt instruction for performing the NYC Trip Planner. We are going to plan our trip and return the response in JSON, so you could utilize this approach for building an API/Service.

  1. Tell me 5 fun attractions to do in NYC.
  2. Generate an itinerary and pricing information ordered by geographic location for these activities: {{get_activities.output}}. Return the response in JSON format.

You need to do the following steps and tweak the prompts based on your requirements.

  1. Download travel.aiconfig.json
  2. Login to LastMileAI
  3. Navigate to the Workbooks and then do the following to upload the aiconfig file.

AiConfigCreate

Once the config is loaded, you will be seeing two chained prompts or instructions. As discussed, the first one is for fetching the fun attractions to do in NYC. The workbook prompt cell is named with get_activities, we are going to use that cell as a reference in the next prompt which is basically responsible for producing the itinerary and pricing information order by the geolocation. Also, we are going to return the response in JSON.

NYCTripPlanner

TripPlannerResponse

Reference

AiConfig Web
AiConfig Open Source

Conclusion

Hope you had a lot of fun with the AiConfig, Prompt chaining and using the LastMileAI workbook. Creativity or imagination is the limit. You can potentially create or build any useful AI based apps or service in a matter of minutes.

Top comments (3)

Collapse
 
andrewlastmile profile image
andrew-lastmile

Really informative! Great post @ranjancse

Collapse
 
gupta0112 profile image
gupta

Looks Great

Collapse
 
aaravpatel1985 profile image
AaravPatel1985

Great post