Skip to content

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.

ai/prompts/simple-prompts.yaml
1
prompts:
2
- name: email-template-gen
3
system-prompt: You are an helpful executive assistant
4
user-prompt: |
5
Write {{ templatecount }} email templates to introduce {{your-brand}} in {{ charactercount }} characters or less
6
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-gen
9
user-prompt: |
10
Suggest titles of {{ count }} LinkedIn posts to introduce {{ product }} in sequence one for each day. The
11
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 less
by 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 gateway
2
{
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

ai/prompts/few-shot-text.yaml
1
prompts:
2
- name: few-shot-prompt
3
type: few-shot
4
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 text
10
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 gateway
2
{
3
"prompt": "few-shots-prompt",
4
"parameters": {
5
"user-prompt": "please tell me a good story"
6
}
7
}

Text generation example

ai/prompts/few-shot-text.yaml
1
prompts:
2
- name: few-shot-prompt
3
type: few-shot
4
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 text
10
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

ai/prompts/entity-few-shot.yaml
1
prompts:
2
- name: few-shot-entity
3
type: few-shot
4
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 backticks
8
content-type: yaml
9
samples:
10
- prompt: Create entity person with fields id, firstname, lastname, age and address
11
response: |
12
entities:
13
- name: person
14
fields:
15
- name: id
16
type: int
17
validations: []
18
- name: firstname
19
type: string
20
validations:
21
- type: length
22
max: 12
23
- name: lastname
24
type: string
25
validations:
26
- type: length
27
max: 12
28
- name: age
29
type: int
30
validations: []
31
- name: address
32
type: string
33
validations:
34
- type: length
35
max: 255
36
- prompt: Create entity car with fields id, name, brand, type, price
37
response: |
23 collapsed lines
38
entities:
39
- name: car
40
fields:
41
- name: id
42
type: int
43
validations:
44
- type: required
45
- type: unique
46
message: should me unique for all entries
47
- type: final
48
message: field cannot be updated
49
- name: name
50
type: string
51
validations: []
52
- name: brand
53
type: string
54
validations: []
55
- name: type
56
type: string
57
validations: []
58
- name: price
59
type: string
60
validations: []

When the user prompts

create entity address with fields id, building, street, locality, city, state, country, code

will give the following YAML response

1
entities:
2
- name: address
3
fields:
4
- name: id
5
type: int
6
validations:
7
- type: required
8
- type: unique
9
message: should me unique for all entries
10
- type: final
11
message: field cannot be updated
12
- name: building
13
type: string
14
validations: []
15
- name: street
16
type: string
17
validations: []
18
- name: locality
19
type: string
20
validations: []
21
- name: city
22
type: string
23
validations: []
24
- name: state
25
type: string
26
validations: []
27
- name: country
28
type: string
29
validations: []
30
- name: code
31
type: string
32
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.

ai/prompt/vue-kanban-prompt.yaml
1
- name: few-shot-kanbam
2
type: few-shot
3
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 backticks
7
content-type: vue
8
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:date
10
file: vue-kis-kanban/Example01.vue
11
- prompt: Another example, a kanban board for a bug-detection entity, having 3 states detected, danger_level, fixed would be like
12
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>
8
import { useEntityDataSource } from '@kis.ai/vue-data'
9
10
const { loading, loaded, data, fetchData, previousPage, nextPage, gotoPage } = useEntityDataSource('task', null, { immediate: true, pagesize: 1000 })
11
12
const 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>