HexdocsMcp.Embeddings (HexDocs MCP v0.6.0)

View Source

Functions for generating embeddings from markdown chunks using Ollama.

Summary

Functions

Generates a SHA-256 hash for the given text content.

Delete all embeddings for a package and version.

Check if embeddings exist for a package and version.

Generate embeddings for all chunks in a package and store them in SQLite.

Search for similar text in embeddings using SQLite.

Functions

content_hash(text)

@spec content_hash(String.t()) :: String.t()

Generates a SHA-256 hash for the given text content.

Returns a lowercase hex-encoded string representation of the hash.

delete_embeddings(package, version)

Delete all embeddings for a package and version.

Parameters

  • package - The name of the package
  • version - The version of the package or "latest"

Returns

  • {:ok, count} - The number of embeddings deleted

embeddings_exist?(package, version)

Check if embeddings exist for a package and version.

Parameters

  • package - The name of the package
  • version - The version of the package or "latest"

Returns

  • true - Embeddings exist
  • false - No embeddings exist

generate(package, version, model, opts \\ [])

Generate embeddings for all chunks in a package and store them in SQLite.

Parameters

  • package - The name of the package
  • version - The version of the package or "latest"
  • model - The Ollama model to use, "nomic-embed-text" is recommended
  • progress_callback - (Optional) Function called with progress updates

Returns

  • {:ok, count} - The number of embeddings generated

search(query, package, version, model, opts \\ [])

Search for similar text in embeddings using SQLite.

Parameters

  • query - The search query
  • package - The name of the package to search in
  • version - The version of the package or "latest"
  • model - The Ollama model to use, "nomic-embed-text" is recommended
  • top_k - (Optional) Number of results to return, defaults to 3
  • progress_callback - (Optional) Function called with progress updates
  • all_versions - (Optional) Include all versions in search, defaults to false