Documentation Index
Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
PromptVariable
Types for prompt variables with modality definitions.
Overview
Variable types define dynamic content that can be injected into prompts, with support for multiple modalities.
PromptVariable
Prompt variable with name and modality.
interface PromptVariable {
name: string;
modality: VariableModality;
}
Properties:
name - Variable name (used as {{variable_name}} in prompts)
modality - Variable modality type (VariableModality)
Example:
import type { PromptVariable } from '@adaline/api';
const variables: PromptVariable[] = [
{ name: 'user_name', modality: 'text' },
{ name: 'company_name', modality: 'text' },
{ name: 'company_logo', modality: 'image' },
{ name: 'report', modality: 'pdf' },
{ name: 'external_data', modality: 'api' },
{ name: 'nested_prompt', modality: 'prompt' }
];
JSON:
[
{ "name": "user_name", "modality": "text" },
{ "name": "company_name", "modality": "text" },
{ "name": "company_logo", "modality": "image" },
{ "name": "report", "modality": "pdf" }
]
VariableModality
See the dedicated VariableModality page for full documentation.
Variable modality type enumeration.
type VariableModality = 'text' | 'image' | 'pdf' | 'api' | 'prompt';
Values:
'text' - Plain text content
'image' - Image content (URL or base64)
'pdf' - PDF document content
'api' - External API data source
'prompt' - Nested prompt reference
Example:
import type { VariableModality } from '@adaline/api';
const modality: VariableModality = 'text';
VariableValue
See the dedicated VariableValue page for full documentation.
Variable value type, discriminated by modality. Used when providing values for prompt variables.
type VariableValue =
| TextContent
| ImageContent
| PdfContent
| ApiContent
| PromptContent;
Example:
import type { VariableValue } from '@adaline/api';
// Text value
const textValue: VariableValue = {
modality: 'text',
value: 'John Doe'
};
// Image value
const imageValue: VariableValue = {
modality: 'image',
detail: 'auto',
value: {
type: 'url',
url: 'https://example.com/logo.png'
}
};
// PDF value
const pdfValue: VariableValue = {
modality: 'pdf',
value: {
type: 'url',
url: 'https://example.com/docs.pdf'
},
file: {
name: 'user_guide.pdf',
id: 'file_123'
}
};
Using with Deployments
import { Adaline } from '@adaline/client';
import type { Deployment, PromptVariable } from '@adaline/api';
const adaline = new Adaline();
const deployment: Deployment = await adaline.getLatestDeployment({
promptId: 'prompt_abc123',
deploymentEnvironmentId: 'environment_abc123'
});
// Access variable definitions from the deployment
const variables: PromptVariable[] = deployment.prompt.variables;
variables.forEach(v => {
console.log(`Variable: ${v.name}, Modality: ${v.modality}`);
});
Replacing variables at runtime
The SDK returns deployments with {{variable_name}} placeholders intact — substitute them yourself before sending the prompt to your AI provider.
Text variables
import { Adaline } from '@adaline/client';
const adaline = new Adaline();
const deployment = await adaline.getLatestDeployment({
promptId: 'prompt_abc123',
deploymentEnvironmentId: 'environment_abc123'
});
const variables = {
user_name: 'Alice',
company_name: 'Acme Corp',
};
// Replace placeholders in text content across every message
const messages = deployment.prompt.messages.map((msg) => ({
...msg,
content: msg.content.map((c) => {
if (c.modality !== 'text') return c;
return {
...c,
value: c.value.replace(/\{\{(\w+)\}\}/g, (match, name) => {
return typeof variables[name] === 'string' ? variables[name] : match;
}),
};
}),
}));
Image and PDF variables
For non-text variables, replace a text content item whose entire value is {{variable_name}} with the corresponding ImageContent or PdfContent item:
import type { ImageContent, MessageContent, PdfContent } from '@adaline/api';
const assets: Record<string, ImageContent | PdfContent> = {
profile_pic: {
modality: 'image',
detail: 'auto',
value: { type: 'url', url: 'https://example.com/alice.png' },
},
report: {
modality: 'pdf',
value: { type: 'url', url: 'https://example.com/report.pdf' },
file: { name: 'report.pdf', id: 'file_abc123' },
},
};
const messages = deployment.prompt.messages.map((msg) => ({
...msg,
content: msg.content.flatMap<MessageContent>((c) => {
if (c.modality !== 'text') return [c];
const match = c.value.trim().match(/^\{\{(\w+)\}\}$/);
if (match && assets[match[1]]) return [assets[match[1]]];
return [c];
}),
}));
Image and PDF variables can only replace a text content item whose entire value is {{variable_name}}. A placeholder embedded in larger text (e.g., "See: {{pic}}") cannot be swapped for a binary modality.