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 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 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
Section titled “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 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.
Example: ai/prompts/simple-prompts.yaml
Section titled “Example: ai/prompts/simple-prompts.yaml”prompts:- name: email-template-gen system-prompt: You are an helpful executive assistant user-prompt: | Write {{ templatecount }} email templates to introduce {{your-brand}} in {{ charactercount }} characters or less by weaving in the specific trigger to {{ topic }} on {{ brand }}. Customer's firstname is {{ firstname }} and lastname is {{ lastname }}. My signature is {{ signature }}.- name: linkedin-post-gen user-prompt: | Suggest titles of {{ count }} LinkedIn posts to introduce {{ product }} in sequence one for each day. The features to be highlighted are {{ featurelist }}.In the above example, email-template-gen’s user-prompt will 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, APWith the following JSON payload to AI Gateway or AI Flow:
{ "prompt": "email-template-gen", "parameters": { "templatecount": 5, "your-brand": "kis.ai", "charactercount": 150, "topic": "hotel management software", "brand": "Sun and Sands Resorts", "firstname": "Joe", "lastname": "Pescano", "signature": "Wishing a sunny day, AP" }}Few-shot Prompts
Section titled “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.
With Plain Text
Section titled “With Plain Text”Question & Answer example
ai/prompts/few-shot-text.yaml
Section titled “ai/prompts/few-shot-text.yaml”prompts:- name: few-shot-prompt type: few-shot system-prompt: You are an helpful assistant, but give precise answers. samples-prefix: Give the response as a simple one or two word answer. samples-suffix: Do not respond with anything in addition to what is asked. Do not be too verbose. samples: - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. Where is Eiffel tower located? content-type: text # default is text response: Paris, France. - prompt: The Eiffel Tower, located in Paris, France, was completed in 1889 and stands 324 meters tall. How tall is the Eiffel tower? response: 324 metersWhen 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 millionThis will be the sample JSON being sent to the AI Gateway:
{ "prompt": "few-shots-prompt", "parameters": { "user-prompt": "please tell me a good story" }}Text generation example
The same YAML structure applies for text generation tasks.
With Inline Code
Section titled “With Inline Code”Generate YAML with inline samples
ai/prompts/entity-few-shot.yaml
Section titled “ai/prompts/entity-few-shot.yaml”prompts:- name: few-shot-entity type: few-shot system-prompt: You are an helpful developer, helping a developer create a valid yaml. samples-prefix: Give a valid yaml as output. 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. backticks: true content-type: yaml samples: - prompt: Create entity person with fields id, firstname, lastname, age and address response: | entities: - name: person fields: - name: id type: int validations: [] - name: firstname type: string validations: - type: length max: 12 - name: lastname type: string validations: - type: length max: 12 - name: age type: int validations: [] - name: address type: string validations: - type: length max: 255 - prompt: Create entity car with fields id, name, brand, type, price response: | entities: - name: car fields: - name: id type: int validations: - type: required - type: unique message: should me unique for all entries - type: final message: field cannot be updated - name: name type: string validations: [] - name: brand type: string validations: [] - name: type type: string validations: [] - name: price type: string validations: []When the user prompts:
create entity address with fields id, building, street, locality, city, state, country, codeThe following YAML response is generated:
entities: - name: address fields: - name: id type: int validations: - type: required - type: unique message: should me unique for all entries - type: final message: field cannot be updated - name: building type: string validations: [] - name: street type: string validations: [] - name: locality type: string validations: [] - name: city type: string validations: [] - name: state type: string validations: [] - name: country type: string validations: [] - name: code type: string validations: []With File Inclusion
Section titled “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/prompts/vue-kanban-prompt.yaml
Section titled “ai/prompts/vue-kanban-prompt.yaml”- name: few-shot-kanbam type: few-shot system-prompt: You are an helpful developer, helping a developer create valid vue code. samples-prefix: Give a valid Vuejs code as output. samples-suffix: Do not respond with anything in addition to Vue code. backticks: true content-type: vue samples: - 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 file: vue-kis-kanban/Example01.vue - prompt: Another example, a kanban board for a bug-detection entity, having 3 states detected, danger_level, fixed would be like file: vue-kis-kanban/Example02.vueWhen 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:duedateThe following Vue code response is generated:
<template> <div> <KisKanbanViewer ref="kanban" :width=1400 :height=800 access-key="id" discriminator="state" date-key="duedate" :buckets="buckets" :data="data" /> </div></template><script setup>import { useEntityDataSource } from '@kis.ai/vue-data'
const { loading, loaded, data, fetchData, previousPage, nextPage, gotoPage } = useEntityDataSource('task', null, { immediate: true, pagesize: 1000 })
const buckets = [ { title: 'New', value: 'new', style: { headerStyle: 'bg-blue-100 text-black items-center p-3', bucketStyle: 'bg-blue-100 px-4 rounded-lg' } }, { title: 'In Progress', value: 'inprogress', style: { headerStyle: 'bg-blue-100 text-black p-3', bucketStyle: 'bg-blue-100 px-4 rounded-lg' } }, { title: 'Fixed', value: 'fixed', style: { headerStyle: 'bg-blue-100 text-black p-3', bucketStyle: 'bg-blue-100 px-4 rounded-lg' } }, { title: 'Closed', value: 'closed', style: { headerStyle: 'bg-green-100 text-black p-3', bucketStyle: 'bg-green-100 px-4 rounded-lg' } }]</script>