Skip to content

Commit ed0b4b7

Browse files
committed
RDoc-3483 added loadAttachment details
1 parent f78031d commit ed0b4b7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/ai-integration/gen-ai-integration/process-attachments/processing-attachments_api.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ To send documents to the LLM along with their attachments using the API, define
6363
.withPng(loadAttachment(`electric-circuit.png`));
6464
```
6565

66+
<Admonition type="note" title="">
67+
Additional options include:
68+
69+
* [Conditional attachment](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#conditional-attachment)
70+
* [Multiple attachments](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#multiple-attachments)
71+
* [Embedding base64-encoded images in the context object](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#embedding-base64-encoded-images-in-the-context-object)
72+
* [Embedding text in the context object](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#embedding-text-in-the-context-object)
73+
74+
</Admonition>
75+
76+
6677
* When [defining the task Prompt and JSON schema](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#set-task-prompt-and-json-schema), make sure to include in the prompt instructions for how the LLM should handle the attachments, and set in the schema fields for any information you expect the LLM to return related to the attachments.
6778

6879
* When [defining the task Update script](../../../ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio#set-task-update-script), make sure to include logic for how to handle the LLM's responses related to the attachments.

docs/ai-integration/gen-ai-integration/process-attachments/processing-attachments_studio.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ We will then embed this explanation in the original document.
9191

9292
### Conditional attachment:
9393

94-
You can use conditional logic in the context generation script to include attachments only if they exist.
95-
E.g., to include a PNG attachment only if it exists, use:
94+
When `loadAttachment` fails to load an attachment, it will return `null`.
95+
You can use this to condition the delivery of an attachment on `loadAttachment`'s succees to load it.
96+
Including a non-existing attachment in the context object will not generate an error, but the LLM will receive a "not found" message instead of the attachment.
9697

9798
```javascript
99+
// Verify attachment existance before sending it to the LLM
98100
const img = loadAttachment("electric-circuit.png");
99-
if (attachment != null) {
101+
if (img != null) {
100102
ai.genContext({ ToyName: this.Name, ToyId: id(this) })
101103
.withPng(img);
102104
} else {
@@ -106,7 +108,7 @@ if (attachment != null) {
106108

107109
### Multiple attachments:
108110

109-
You can include multiple attachments of the same or different types in the context object.
111+
You can include multiple attachments in the context object.
110112
E.g., to include both a PNG and a PDF attachment, use:
111113

112114
```javascript

0 commit comments

Comments
 (0)