Building with generative AI 🚀
Tags: ai, tutorial, programming, devops
Published: 2023-12-05 00:40:30

## TL;DR
In this tutorial, we'll show you how to streamline the way you integrate generative AI models into production! 

## LastMile AI - dev platform for generative AI 🚀
A quick background about LastMile AI. We are a developer platform for engineering teams to go from prototype to production with generative AI models. Our platform is multi-modal and model-agnostic so you aren't tied to dependencies on a single provider. 

We recently launched our first open-source project AIConfig! Check us out and give us feedback ⭐️: https://github.com/lastmile-ai/aiconfig

Demo Video - https://www.youtube.com/watch?v=ej85StfHEFo 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2usoguydxxefas36nd7.jpg)



## 1. Let's get started 
First, go to www.lastmileai.dev and sign in for free. 

You'll land on an AI Workbook. AI Workbooks are a notebook-like interface where you can experiment text, image, and audio AI models from various providers. You can prototype and parametrize your prompt chains all in a single place. 


![empty_wb](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2o8qfzssme4xt877ls3c.png)

## 2. Write your prompt chains
We are going to prototype a simple trip planner. 

First prompt: 
1. Select 'ChatGPT' as model (should be default). 
2. Add global parameter '`city`' with value 'London'. 
3. Name cell as '`get_activities`'
4. Write prompt 'Tell me the top 5 fun attractions in `{{city}}`'

![first_prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhlyekhtol8nbjm3ja1s.png)

For our second prompt: 
1. Add a new cell but change model to 'GPT4'. 
2. Add a local parameter for the cell `{{cuisine}}`. 
3. Add a system prompt to format the response (see image) 
3. Write prompt 'generate a one-day personalized itinerary based on 1/ my favorite cuisine: `{{cuisine}}`, 2/ list of activities: `{{get_activities.output}}`'

![second_prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wzqx1cc4xpxl2p6fedp3.png)

AI Workbook - https://lastmileai.dev/workbooks/clpdo3pnl019dpejj3kvl49g2

## 3. Download your AIConfig 
AIConfig is a JSON serializable format that contains your prompts, model parameters, and settings. It is essentially your generative AI artifact to be managed in source control and easily shared across applications. 

![download_config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffglc3h4mi4jylzch1lv.png)

## 4. Use AIConfig in your application code
Here are a few of the python SDK commands on how you can use AIConfig easily in your application code. 

But first why store your generative AI components in a config? It enables you to: 
- Decouple your application code from the generative AI components which decreases complexity 
- Manage your generative AI components in source control 
- Evaluate and monitor performance across models
- Iterate fast - switch models and try different parameters

Colab Notebook: https://colab.research.google.com/drive/1RlGQmtR0uK7OTI5nG10E219JoH2mgAQr#scrollTo=Kd6BFPGiHPJe 

### Install python package 
AIConfig SDK is available in python and Typescript. 

![install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztjoyn0kblz8l9qzgikm.png)

### Load your AI Config 

![load](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qmsfc0pqor495ron1fpa.png)

### Run your prompt 

![run](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5509i3h7d7c7ydj1nys.png)

### Run prompt with different parameter value

![diff_params](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4lx296nhn2wfj3ckpg27.png)

### Add a new prompt to your AIConfig

![add_new](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8cvb0puancgtghbfirg.png)

### Save outputs in your AIConfig 
![save](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns05old9vbm8qxdrw2ow.png)

AIConfig is our first open-source project and we'd love your help. See our [contributing guidelines](https://aiconfig.lastmileai.dev/docs/contributing/) -- we would especially love help adding support for additional models that the community wants.
⭐️ https://github.com/lastmile-ai/aiconfig