Prompts
Prompts are essential for interacting effectively with Large Language Models (LLMs). They serve as a specific way to communicate with LLMs, guiding them to generate the desired responses. AI models often require fine-tuning of prompts to enhance performance.
In kis.ai, prompts are managed through YAML files in a product, located in the folder ai/prompts
. As these files are part of the product git repository, their changes can be tracked over a period of time. Prompts can be categorized, tagged, and searched for quick retrieval. kis.ai provides analytics and feedback mechanisms to help developers refine their prompts, ensuring high-quality responses from the LLMs.
Simple Prompts
Developers can define prompts in a structured manner, in multiple folders and YAML files to match the complexity of the product and its context. Each prompt has a name and has some natural language text to be sent to the LLM. Prompts are also essentially string templates, written in liquid, allowing developers to dynamically change the prompts to match the information passed by the end-users.
For most models, system-prompt and user-prompt are available and give the way to request the LLM on what is expected. The {{ parameter }}
notation of liquid templates can be used to demarcate the dynamic sections of the prompt.
1prompts:2- name: email-template-gen3 system-prompt: You are an helpful executive assistant4 user-prompt: |5 Write {{ templatecount }} email templates to introduce {{your-brand}} in {{ charactercount }} characters or less6 by weaving in the specific trigger to {{ topic }} on {{ brand }}. Customer's firstname is {{ firstname }}7 and lastname is {{ lastname }}. My signature is {{ signature }}.8- name: linkedin-post-gen9 user-prompt: |10 Suggest titles of {{ count }} LinkedIn posts to introduce {{ product }} in sequence one for each day. The11 features to be highlighted are {{ featurelist }}.
In the above example, email-template-gen’s user-prompt with be translated into
Write 5 email templates to introduce kis.ai in 150 characters or lessby weaving in the specific trigger to hotel management software on Sun and Sands Resorts.Customer's firstname is Joe and lastname is Pescano. My signature is Wishing a sunny day, AP
with the following json payload AI Gateway or AI Flow
1//payload to gateway2{3 "prompt": "email-template-gen",4 "parameters": {5 "templatecount": 5,6 "your-brand": "kis.ai",7 "charactercount": 150,8 "topic": "hotel management software",9 "brand": "Sun and Sands Resorts",10 "firstname": "Joe",11 "lastname": "Pescano",12 "signature": "Wishing a sunny day, AP"13 }14}
Few-shot Prompts
Few-shot prompting is a technique in natural language processing where a language model is provided with a small number of examples (typically a few) to understand the context or task it needs to perform. Unlike zero-shot prompting, which relies on the model’s pre-existing knowledge without examples, few-shot prompting gives the model specific examples to guide its responses, improving accuracy and relevance. This approach helps the model generalize from the examples to generate appropriate outputs for similar tasks.
With plain text
Question & Answer example
1prompts:2- name: few-shot-prompt3 type: few-shot4 system-prompt: You are an helpful assistant, but give precise answers.5 samples-prefix: Give the response as a simple one or two word answer.6 samples-suffix: Do not respond with anything in addition to what is asked. Do not be too verbose.7 samples:8 - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. Where is Eiffel tower located?9 content-type: text # default is text10 response: Paris, France.11 - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. How tall is the Eiffel tower?12 response: 324 meters
When the user prompts
In 1873, the three cities of Buda, Óbuda (Old Buda), and Pest were united to form Budapest, which was originally named "Pest-Buda". Budapest has a population of about 1.7 million people. What is the popoulation of Budapest?
they get the response
1.7 million
This will be the sample json being sent to the AI Gateway
1//json payload to gateway2{3 "prompt": "few-shots-prompt",4 "parameters": {5 "user-prompt": "please tell me a good story"6 }7}
Text generation example
1prompts:2- name: few-shot-prompt3 type: few-shot4 system-prompt: You are an helpful assistant, but give precise answers.5 samples-prefix: Give the response as a simple one or two word answer.6 samples-suffix: Do not respond with anything in addition to what is asked. Do not be too verbose.7 samples:8 - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. Where is Eiffel tower located?9 content-type: text # default is text10 response: Paris, France.11 - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. How tall is the Eiffel tower?12 response: 324 meters
When the user prompts
In 1873, the three cities of Buda, Óbuda (Old Buda), and Pest were united to form Budapest, which was originally named "Pest-Buda". Budapest has a population of about 1.7 million people. What is the popoulation of Budapest?
they get the response
1.7 million
With inline code
Generate YAML with inline samples
This is an example prpmpt if you want to genrate structured YAML as outputs
1prompts:2- name: few-shot-entity3 type: few-shot4 system-prompt: You are an helpful developer, helping a developer create a valid yaml.5 samples-prefix: Give a valid yaml as output.6 samples-suffix: Do not respond with anything in addition YAML. Include the YAML in triple backticks and also add the type yaml when after starting the triple backticks.7 backticks: true # this tells AI Gateway and other services to return code in tripe backticks8 content-type: yaml9 samples:10 - prompt: Create entity person with fields id, firstname, lastname, age and address11 response: |12 entities:13 - name: person14 fields:15 - name: id16 type: int17 validations: []18 - name: firstname19 type: string20 validations:21 - type: length22 max: 1223 - name: lastname24 type: string25 validations:26 - type: length27 max: 1228 - name: age29 type: int30 validations: []31 - name: address32 type: string33 validations:34 - type: length35 max: 25536 - prompt: Create entity car with fields id, name, brand, type, price37 response: |23 collapsed lines
38 entities:39 - name: car40 fields:41 - name: id42 type: int43 validations:44 - type: required45 - type: unique46 message: should me unique for all entries47 - type: final48 message: field cannot be updated49 - name: name50 type: string51 validations: []52 - name: brand53 type: string54 validations: []55 - name: type56 type: string57 validations: []58 - name: price59 type: string60 validations: []
When the user prompts
create entity address with fields id, building, street, locality, city, state, country, code
will give the following YAML response
1entities:2 - name: address3 fields:4 - name: id5 type: int6 validations:7 - type: required8 - type: unique9 message: should me unique for all entries10 - type: final11 message: field cannot be updated12 - name: building13 type: string14 validations: []15 - name: street16 type: string17 validations: []18 - name: locality19 type: string20 validations: []21 - name: city22 type: string23 validations: []24 - name: state25 type: string26 validations: []27 - name: country28 type: string29 validations: []30 - name: code31 type: string32 validations: []
With file inclusion
Generate Vue Code In this example prompt, user prompt will generate Vue code, based on the samples provided through code file inclusions.
1- name: few-shot-kanbam2 type: few-shot3 system-prompt: You are an helpful developer, helping a developer create valid vue code.4 samples-prefix: Give a valid Vuejs code as output.5 samples-suffix: Do not respond with anything in addition to Vue code.6 backticks: true # this tells AI Gateway and other services to return code in tripe backticks7 content-type: vue8 samples:9 - prompt: Create a kanban board for bug entity with states new, inprogress, fixed, closed. The attribute values are access-key:aid, discriminator:state, date-key:date10 file: vue-kis-kanban/Example01.vue11 - prompt: Another example, a kanban board for a bug-detection entity, having 3 states detected, danger_level, fixed would be like12 file: vue-kis-kanban/Example02.vue
When user prompts
Create a kanban board for task entity with states new, inprogress, fixed, closed. The attribute values are access-key:id, discriminator:state, date-key:duedate
will give the following Vue code as response
1<template>2 <div>3 <KisKanbanViewer ref="kanban" :width=1400 :height=800 access-key="id" discriminator="state" date-key="duedate"4 :buckets="buckets" :data="data" />5 </div>6</template>7<script setup>8import { useEntityDataSource } from '@kis.ai/vue-data'9
10const { loading, loaded, data, fetchData, previousPage, nextPage, gotoPage } = useEntityDataSource('task', null, { immediate: true, pagesize: 1000 })11
12const buckets = [13 {14 title: 'New',15 value: 'new',16 style: {17 headerStyle: 'bg-blue-100 text-black items-center p-3',18 bucketStyle: 'bg-blue-100 px-4 rounded-lg'19 }20 },21 {22 title: 'In Progress',23 value: 'inprogress',24 style: {25 headerStyle: 'bg-blue-100 text-black p-3',26 bucketStyle: 'bg-blue-100 px-4 rounded-lg'27 }28 },29 {30 title: 'Fixed',31 value: 'fixed',32 style: {33 headerStyle: 'bg-blue-100 text-black p-3',34 bucketStyle: 'bg-blue-100 px-4 rounded-lg'35 }36 },37 {38 title: 'Closed',39 value: 'closed',40 style: {41 headerStyle: 'bg-green-100 text-black p-3',42 bucketStyle: 'bg-green-100 px-4 rounded-lg'43 }44 }45]46</script>