.prompt Prompt file
overview
The prompt file, also called a dotprompt
file, is a text file with a .prompt
extension. It contains the prompt, along with some metadata. The metadata lives at the top, in the file's front matter.
prompt
We may use a fixed prompt or a template prompt:
- The fixed prompt is not customizable and is used as-is.
- The template prompt is a piece of text that includes slots, which makes it customizable. The caller provides data to customize the prompt.
Translate to english: { { character } }
front matter
the front matter follows a YAML syntax, and provides metadata.
---
name: requestExamples
model: openai/gpt-4o
config:
temperature: 0.5
---
front matter for a template prompt
If the prompt is to receive arguments, we define their name, type and default value in the front matter.
The arguments live in the input
object. schema
provides the types, while default
provides the default values.
___
...
input:
schema:
character: string
default:
character: 我
---
Translate to english: {{character}}
reference the prompt file
We provide the prompt file path. prompt()
returns an object of type ExecutablePrompt.
const requestExamples = ai.prompt("requestExamples")
run the prompt file
We may use the handle to trigger the request.
// wait for completion
const { text } = await requestExamples({ character: "菠萝" })
// stream
const { stream } = requestExamples.stream({ character: "菠萝" })