Skip to content

Commit cd23d9b

Browse files
authored
Tools demos: use prompt engineering to limit RAG context (#425)
1 parent 7400ea6 commit cd23d9b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examplecode/tools/langflow.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ Also:
142142
Answer:
143143
```
144144

145+
<Tip>
146+
To answer the question, the preceding prompt uses the context along with general information that the text-based LLM is
147+
trained on. To use only the context to answer the question, you can change the prompt, for example to something like this:
148+
149+
```text
150+
{context}
151+
152+
---
153+
154+
Given the context above, answer the question as best as possible. Use only the context to answer the question. Do not use
155+
any other sources of information. If the context does not provide enough information to answer the question, reply with
156+
'I do not have enough context to answer the question.'
157+
158+
Question: {question}
159+
160+
Answer:
161+
```
162+
163+
</Tip>
164+
145165
4. Click **Check & Save**.
146166

147167
![Prompt component](/img/langflow/edit-prompt.png)

examplecode/tools/vectorshift.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ Also:
103103
Answer the Question based on Context. Use Memory when relevant.
104104
```
105105

106+
<Tip>
107+
To answer the question, the preceding prompt uses the context along with general information that the text-based LLM is
108+
trained on. To use only the context to answer the question, you can change the prompt, for example to something like this:
109+
110+
```text
111+
Answer the Question based only on the Context. Do not use any other sources of
112+
information. If the context does not provide enough information to answer the
113+
question, reply with 'I do not have enough context to answer the question.'
114+
Use Memory when relevant.
115+
```
116+
117+
</Tip>
118+
106119
3. For **Prompt**, enter the following text:
107120

108121
```

0 commit comments

Comments
 (0)