Prompts
This guide will get you all set up and ready to use Superagent Prompts. Superagent allows users to configure their Agents using prompts. A prompt is piece of text that gives context to the LLM. It can contain instructions on how the Agent should act, input variables used for injecting data into the prompt. Common examples of input_variables are human_input, question and chat_history for in context memory.
The Prompt Model
The Superagent Swift SDK comes with publicly available models. This makes it easy for you to configure your requests correctly. Prompts in superagent allow the following properties in the request.
- Name
name
- Type
- string
- Description
The name of the prompt.
- Name
inputVariables
- Type
- array of strings
- Description
A
String array
containing input variables.
- Name
template
- Type
- string
- Description
The prompt template.
List all prompts
This endpoint allows you to retrieve a list of all your prompts
myprompts.swift
do {
let myprompts = try await superagent.listPrompts()
print("prompt: \(myprompts)")
} catch {
print("Error when creating agent: \(error)")
throw error
}
You can access the response key value pairs by requesting a specific key. For example myprompts["id"]
for the prompt Id
Response
{[
{
"id": "cli28c2vd00016itbrlhekwql",
"name": "My prompt",
"template": "...",
"input_variables": [
"question",
"history"
],
}
]
}
Get prompt
This endpoint allows you to retrieve a single prompt
Require attributes
- Name
id
- Type
- string
- Description
The id of the prompt.
myprompts.swift
do {
let myprompts = try await superagent.getPrompt(id: "mypromptId")
print("prompt: \(myprompts)")
} catch {
print("Error when creating agent: \(error)")
throw error
}
You can access the response key value pairs by requesting a specific key. For example myprompts["id"]
for the prompt Id
Response
{
"id": "cli28c2vd00016itbrlhekwql",
"name": "My prompt",
"template": "...",
"input_variables": [
"question",
"history"
]
}
Update a prompt
This endpoint allows you to update a single prompt
Require attributes
- Name
id
- Type
- string
- Description
The id of the prompt.
- Name
Prompt(name: "New Name", inputVariables: "", template: "")
- Type
- Prompt Model
- Description
The updated prompt as a Prompt model
myprompts.swift
let newPrompt = Prompt(name: "My prompt", inputVariables: ["question", "history"], template: "My prompt template with {histroy} and {question}")
do {
let myprompts = try await superagent.updatePrompt(id: "mypromptId", newPrompt: newPrompt)
print("prompt: \(myprompts)")
} catch {
print("Error when creating agent: \(error)")
throw error
}
You can access the response key value pairs by requesting a specific key. For example myprompts["id"]
for the prompt Id
Response
{
"id": "cli28c2vd00016itbrlhekwql",
"name": "My prompt",
"template": "...",
"input_variables": [
"question",
"history"
]
}
Create prompt
This endpoint allows you to update a single prompt
Require attributes
- Name
Prompt(name: "New Name", inputVariables: "", template: "")
- Type
- Prompt Model
- Description
The updated prompt as a Prompt model
myprompts.swift
let newPrompt = Prompt(name: "New Name", inputVariables: "", template: "")
do {
let myprompts = try await superagent.createPrompt(prompt: newPrompt)
print("prompt: \(myprompts)")
} catch {
print("Error when creating agent: \(error)")
throw error
}
You can access the response key value pairs by requesting a specific key. For example myprompts["id"]
for the prompt Id
Response
{
"id": "cli28c2vd00016itbrlhekwql",
"name": "My prompt",
"template": "...",
"input_variables": [
"question",
"history"
]
}
Delete prompt
This endpoint allows you to retrieve a single prompt. The delet function returns a simple true or false boolean value
Require attributes
- Name
id
- Type
- string
- Description
The id of the prompt.
myprompts.swift
do {
let myprompts = try await superagent.deletePrompt(id: "mypromptId")
print("prompt: \(myprompts)")
} catch {
print("Error when creating agent: \(error)")
throw error
}