Skip to content

Commit a689019

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

2 files changed

Lines changed: 71 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
@@ -188,6 +188,45 @@ result = p.run({"prompt_builder": {"documents": documents, "query": question}})
188188
print(result)
189189
```
190190

191+
#### In YAML
192+
193+
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.
194+
195+
```yaml
196+
components:
197+
llm:
198+
init_parameters:
199+
api_base_url: null
200+
api_key:
201+
env_vars:
202+
- OPENAI_API_KEY
203+
strict: true
204+
type: env_var
205+
generation_kwargs: {}
206+
http_client_kwargs: null
207+
max_retries: null
208+
model: gpt-4o-mini
209+
organization: null
210+
streaming_callback: null
211+
system_prompt: null
212+
timeout: null
213+
type: haystack.components.generators.openai.OpenAIGenerator
214+
prompt_builder:
215+
init_parameters:
216+
required_variables: null
217+
template: "\n Given these documents, answer the question.\\nDocuments:\n\
218+
\ {% for doc in documents %}\n {{ doc.content }}\n {% endfor\
219+
\ %}\n\n \\nQuestion: {{query}}\n \\nAnswer:\n "
220+
variables: null
221+
type: haystack.components.builders.prompt_builder.PromptBuilder
222+
connection_type_validation: true
223+
connections:
224+
- receiver: llm.prompt
225+
sender: prompt_builder.prompt
226+
max_runs_per_component: 100
227+
metadata: {}
228+
```
229+
191230
#### Changing the template at runtime (Prompt Engineering)
192231
193232
`PromptBuilder` allows you to switch the prompt template of an existing pipeline. The example below builds on top of the existing pipeline in the previous section. We are invoking the existing pipeline with a new prompt template:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
highlights: >
3+
Replace this text with content to appear at the top of the section for this
4+
release. The highlights might repeat some details that are also present in other notes
5+
from the same release, that's ok. Not every release note requires highlights,
6+
use this section only to describe major features or notable changes.
7+
upgrade:
8+
- |
9+
List upgrade notes here, or remove this section.
10+
Upgrade notes should be rare: only list known/potential breaking changes,
11+
or major changes that require user action before the upgrade.
12+
Notes here must include steps that users can follow to 1. know if they're
13+
affected and 2. handle the change gracefully on their end.
14+
features:
15+
- |
16+
List new features here, or remove this section.
17+
enhancements:
18+
- |
19+
List new behavior that is too small to be
20+
considered a new feature, or remove this section.
21+
issues:
22+
- |
23+
List known issues here, or remove this section. For example, if some change is experimental or known to not work in some cases, it should be mentioned here.
24+
deprecations:
25+
- |
26+
List deprecations notes here, or remove this section. Deprecations should not be used for something that is removed in the release, use upgrade section instead. Deprecation should allow time for users to make necessary changes for the removal to happen in a future release.
27+
security:
28+
- |
29+
Add security notes here, or remove this section.
30+
fixes:
31+
- |
32+
Add normal bug fixes here, or remove this section.

0 commit comments

Comments
 (0)