All files / src/embedding Embedding.ts

83.33% Statements 5/6
50% Branches 1/2
66.66% Functions 2/3
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                  12x 12x 12x 12x             1x                    
import { EmbeddingResponse } from "../providers/Provider.js";
 
export class Embedding {
  public readonly vectors: number[][];
  public readonly model: string;
  public readonly input_tokens: number;
  public readonly dimensions: number;
 
  constructor(response: EmbeddingResponse) {
    this.vectors = response.vectors;
    this.model = response.model;
    this.input_tokens = response.input_tokens;
    this.dimensions = response.dimensions;
  }
 
  /**
   * Get the first vector (useful for single-input embeddings)
   */
  get vector(): number[] {
    return this.vectors[0] || [];
  }
 
  /**
   * Convert to string representation (shows dimensions and token count)
   */
  toString(): string {
    return `Embedding(model=${this.model}, dimensions=${this.dimensions}, tokens=${this.input_tokens}, count=${this.vectors.length})`;
  }
}