Skip to main content

LogSpanVariable

Variables attached to Model or ModelStream spans for evaluation tracking. A variable captures a named piece of content (text, image, PDF, etc.) that Adaline uses to power continuous evaluations.

Import

import type { LogSpanVariable, LogSpanVariableValue } from '@adaline/api';

Type Definitions

LogSpanVariable

interface LogSpanVariable {
  name: string;                  // 1-200 chars
  value: LogSpanVariableValue;
}
Properties:
  • name - Variable name, 1–200 characters. Should match a variable name defined in your prompt template.
  • value - The variable content, a discriminated union on modality (LogSpanVariableValue)

LogSpanVariableValue

type LogSpanVariableValue =
  | TextContent           // modality: 'text'
  | ImageContent          // modality: 'image'
  | PdfContent            // modality: 'pdf'
  | ReasoningContent      // modality: 'reasoning'
  | ToolCallContent       // modality: 'tool-call'
  | ToolResponseContent;  // modality: 'tool-response'
This is a subset of MessageContent, supporting the modalities relevant for evaluation variables.

Examples

Text Variable

import type { LogSpanVariable } from '@adaline/api';

const variable: LogSpanVariable = {
  name: 'user_question',
  value: { modality: 'text', value: 'What is quantum computing?' }
};

Image Variable

const imageVariable: LogSpanVariable = {
  name: 'uploaded_image',
  value: {
    modality: 'image',
    detail: 'high',
    value: { type: 'url', url: 'https://example.com/chart.png' }
  }
};

PDF Variable

const pdfVariable: LogSpanVariable = {
  name: 'source_document',
  value: {
    modality: 'pdf',
    value: { type: 'url', url: 'https://example.com/report.pdf' },
    file: { name: 'report.pdf', id: 'file_123' }
  }
};

Using with a Model Span

import OpenAI from 'openai';

const openai = new OpenAI();
const userQuestion = 'Explain quantum computing simply.';

const params = {
  model: 'gpt-4o',
  messages: [
    { role: 'system' as const, content: 'You are a helpful assistant.' },
    { role: 'user' as const, content: userQuestion },
  ],
};

const response = await openai.chat.completions.create(params);

span.update({
  content: {
    type: 'Model',
    provider: 'openai',
    model: 'gpt-4o',
    input: JSON.stringify(params),
    output: JSON.stringify(response),
    variables: {
      name: 'user_question',
      value: { modality: 'text', value: userQuestion }
    },
  },
});

  • LogSpanModelContent — uses LogSpanVariable in its variables field
  • MessageContent — full content union that LogSpanVariableValue is derived from
  • Span — class where span content with variables is set