export function stringToNodeType()

in neuron_viewer/src/types.ts [70:96]


export function stringToNodeType(key: string | undefined): NodeType {
  // string used in the URL, might be different from the DST name
  switch (key) {
    case "attention_head":
      return NodeType.ATTENTION_HEAD;
    case "attn_write_norm":
      return NodeType.ATTENTION_HEAD;
    case "mlp_neuron":
      return NodeType.MLP_NEURON;
    case "autoencoder_latent":
      return NodeType.AUTOENCODER_LATENT;
    case "mlp_autoencoder_latent":
      return NodeType.MLP_AUTOENCODER_LATENT;
    case "attention_autoencoder_latent":
      return NodeType.ATTENTION_AUTOENCODER_LATENT;
    case "autoencoder_latent_by_token_pair":
      return NodeType.AUTOENCODER_LATENT_BY_TOKEN_PAIR;
    case "layer":
      return NodeType.LAYER;
    case "residual_stream_channel":
      return NodeType.RESIDUAL_STREAM_CHANNEL;
    case "vocab_token":
      return NodeType.VOCAB_TOKEN;
    default:
      throw new Error(`Invalid node type string: ${key}`);
  }
}