Skip to main content

LogSpanRetrievalContent

Span content for retrieval operations. Use this type when logging RAG (Retrieval-Augmented Generation) queries — vector similarity searches, keyword lookups, or any step that fetches context documents before passing them to an LLM.

Import

import type { LogSpanRetrievalContent } from '@adaline/api';
import { LogSpanRetrievalContentTypeEnum } from '@adaline/api';

Type Definition

interface LogSpanRetrievalContent {
  type: 'Retrieval';
  input: string;                   // JSON string (must be valid JSON)
  output: string;                  // JSON string (must be valid JSON)
}

Properties

  • type - Discriminator field, always 'Retrieval' for this content type
  • input - The retrieval query as a JSON string (JSON.stringify() of the search parameters)
  • output - The retrieved results as a JSON string (JSON.stringify() of the documents/chunks)
Both input and output must be valid, parseable JSON strings (the result of JSON.stringify()). Passing a plain string that isn’t valid JSON will cause the span to be rejected.

Example

async function searchDocuments(query: string, topK: number) {
  const res = await vectorStore.similaritySearch(query, topK);
  return res;
}

const input = { query: 'How do I configure SSO?', topK: 5, namespace: 'docs' };
const results = await searchDocuments(input.query, input.topK);

span.update({
  content: {
    type: 'Retrieval',
    input: JSON.stringify(input),
    output: JSON.stringify(results),
  },
});

  • LogSpanContent — union type that includes LogSpanRetrievalContent
  • LogSpanEmbeddingsContent — often used before retrieval to generate query embeddings
  • Span — class that accepts LogSpanContent via span.update()