Documentation
¶
Overview ¶
This sample demonstrates how a prompt turns your own data into a request. It fills all four content slots (system, conversation, user, and context documents) from one typed input, with the template form of each alongside.
The rule: template text is yours, so it is compiled; anything a function returns is content you already produced, so it is sent verbatim. Use a template when the wording is fixed and only values vary, and a function when the content depends on the data, such as branching on a field, trimming a conversation, attaching an image, or choosing documents.
Run it:
go run .
Or with the Dev UI, to see the assembled request in a trace of every run at http://localhost:4000/traces:
curl -sL cli.genkit.dev | bash # install the Genkit CLI, once genkit start -- go run .
Or over HTTP. Answer a question with a conversation behind it:
curl -N -X POST 'http://localhost:8080/supportFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"request": {"area": "billing", "tier": "pro", "question": "Why was I charged twice this month?"}, "history": [{"role": "user", "text": "Hi, I have a question about my bill."}, {"role": "model", "text": "Happy to help. What is going on?"}]}}'
Triage one into a structured verdict. This question contains handlebars syntax, which reaches the model as written:
curl -X POST http://localhost:8080/triageFlow \
-H "Content-Type: application/json" \
-d '{"data": {"request": {"area": "api", "tier": "free", "question": "How do I write {{#if}} in a prompt template?"}}}'