Skip to content

Commit 5821c51

Browse files
committed
docs: add YAML example to PromptBuilder documentation
1 parent 428bcab commit 5821c51

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

docs-website/docs/pipeline-components/builders/promptbuilder.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,45 @@ p.run(
257257
Note that `language_template` introduces `answer_language` variable which is not bound to any pipeline variable. If not set otherwise, it would use its default value, "English". In this example, we overwrite its value to "German".
258258
The `template_variables` allows you to overwrite pipeline variables (such as documents) as well.
259259

260+
### In YAML
261+
262+
This is the YAML representation of the RAG pipeline shown above. It renders a custom prompt template by filling it with the contents of retrieved documents and a query, then sends the rendered prompt to a generator.
263+
264+
```yaml
265+
components:
266+
llm:
267+
init_parameters:
268+
api_base_url: null
269+
api_key:
270+
env_vars:
271+
- OPENAI_API_KEY
272+
strict: true
273+
type: env_var
274+
generation_kwargs: {}
275+
http_client_kwargs: null
276+
max_retries: null
277+
model: gpt-5-mini
278+
organization: null
279+
streaming_callback: null
280+
system_prompt: null
281+
timeout: null
282+
type: haystack.components.generators.openai.OpenAIGenerator
283+
prompt_builder:
284+
init_parameters:
285+
required_variables: null
286+
template: "\n Given these documents, answer the question.\\nDocuments:\n\
287+
\ {% for doc in documents %}\n {{ doc.content }}\n {% endfor\
288+
\ %}\n\n \\nQuestion: {{query}}\n \\nAnswer:\n "
289+
variables: null
290+
type: haystack.components.builders.prompt_builder.PromptBuilder
291+
connection_type_validation: true
292+
connections:
293+
- receiver: llm.prompt
294+
sender: prompt_builder.prompt
295+
max_runs_per_component: 100
296+
metadata: {}
297+
```
298+
260299
## Additional References
261300
262301
🧑‍🍳 Cookbooks:

0 commit comments

Comments
 (0)