What is Prompting?
Prompting is the process of sending an advice to the AI and to get an answer back which can then be further processed:
In the context of AI language models, prompting refers to the way in which you phrase or structure a question, statement, or request to guide the AI in generating a relevant and accurate response. The prompt is the input provided to the model that defines the task or the type of information you're looking for.
Source: ChatGPT
It is very important to write a good prompt in order to get a reliable answer back. The process of finding the best prompt for your use case is called Prompt Engineering.
PIPEFORCE provides many tools to engineer and execute prompts, optimize and supervice them.
Simple Prompting - Send a question or advice to AI
One of most generic and simplest use cases is to send an advice to the AI and use the response data in your pipeline. For this you can use the ai.prompt.send
command. Here is an example to return some data from the AI:
pipeline: - ai.prompt.send: | Return the names of the 10 biggest cities in the world as JSON array.
This will result in an entry like this in the body:
[ "Tokyo", "Delhi", "Shanghai", "Sao Paulo", "Mumbai", "Beijing", "Mexico City", "Osaka", "Cairo", "Dhaka" ]
Adding context data (input) to the prompt
You can also apply the prompt with context data. This context data can be set as input
to the command:
pipeline: - ai.prompt.send: input: | [ "Tokyo", "Delhi", "Shanghai", "Sao Paulo", "Mumbai", "Beijing", "Mexico City", "Osaka", "Cairo", "Dhaka" ] prompt: | Order the given list alphabetically.
The result of this example in the body is then:
[ "Beijing", "Cairo", "Delhi", "Dhaka", "Mexico City", "Mumbai", "Osaka", "Sao Paulo", "Shanghai", "Tokyo" ]
The input
of the command will become the context data. It can be plain text, a file or an URI. In case it is a file (for example a PDF or Word document) or any other supported format, it will be automatically converted into an AI compatible format.
Here is an example which uses a PDF file as file context, stored in PIPEFORCE’s Drive cloud storage:
pipeline: - ai.prompt.send: input: $uri:drive:invoice-3662.pdf prompt: | Check the invoice to ensure it is correct both in terms of content and calculations. If everything is fine, return "OK". If not, provide the reason for the error in one sentence.
See another example which converts a given input:
pipeline: - ai.prompt.send: input: | <person> <firstName>Max</firstName> <lastName>Smith</lastName> <age>36</age> </person> prompt: "Convert to JSON"
And the result from the AI in the body will be this:
{ "person": { "firstName": "Max", "lastName": "Smith", "age": 36 } }
And one more example: Apply a data privacy filter:
pipeline: - ai.prompt.send: input: | { "person": { "firstName": "Max", "lastName": "Smith", "age": 36 } } prompt: | Remove all personal data because of privacy and replace by randomized names and add prefix p_
As a result, a changed JSON comes back:
{ "person": { "firstName": "p_Alex", "lastName": "p_Johnson", "age": 48 } }
Avanced prompting: Send multiple messages
In case you need to send multiple messages in one prompt, you can use the parameter messages
like this:
pipeline: - ai.prompt.send: messages: - role: system content: Tell me a joke based on given user input. - role: user content: I'm a 28 year old man living in New York.
The result could be like this in the body:
Why did the New York man bring a ladder to his job interview? Because he wanted to climb the corporate ladder!
If both parameters, messages
and prompt
are given, prompt
will be automatically added to messages
of role system
at the very end.
Possible values for role
are:
system
= A system message from the caller (typically the context data with basic advice).user
= A message from the user (typically the question or advice based on the context data).ai
= A message from the AI (typically used to enrich the context or trace the conversation).
The parameter content
can be a plain text or any AI convertable object (like a PDF file for example). The conversion and preparation to an AI compatible format is done by PIPEFORCE automatically.
Add Comment