Skip to main content

Module llm

Module llm 

Source
Expand description

Claude API client for LLM-generated function summaries (SQ-6).

Uses reqwest::blocking to avoid nested tokio runtime issues (the Store already uses rt.block_on()).

The summary pass uses the Batches API for throughput (no RPM limit, 50% discount). Individual summarize_chunk() is available for single-chunk fallback.

Split into submodules by concern:

  • prompts - prompt construction (summary, doc, HyDE)
  • batch - batch submission, polling, result fetching
  • summary - llm_summary_pass orchestration
  • doc_comments - doc comment generation pass + needs_doc_comment
  • hyde - HyDE query prediction pass

Re-exports§

pub use provider::BatchProvider;

Modules§

provider
LLM batch provider abstraction.

Structs§

LlmClient
Claude API client for generating summaries.
LlmConfig
Resolved LLM configuration (env vars > config file > constants).
SummaryEntry
A summary entry ready for storage.

Enums§

LlmError
Typed error for LLM operations (EH-14).
LlmProvider
LLM API provider type.

Functions§

create_client
Create a batch provider from the resolved config.
doc_comment_pass
Run the LLM doc-comment generation pass using the Batches API. Scans all indexed chunks, selects those needing doc comments (via needs_doc_comment), checks the cache, submits uncached candidates as a batch to Claude with build_doc_prompt, and returns the results. Cached results are returned without an API call. max_docs limits how many functions to process (0 = unlimited). improve_all regenerates docs for all functions, even those with existing adequate docs.
hyde_query_pass
Run the HyDE query prediction pass using the Batches API. Scans all callable chunks, submits them as a batch to Claude for query prediction, polls for completion, then stores results with purpose=“hyde”. Returns the number of new HyDE predictions generated.
llm_summary_pass
Run the LLM summary pass using the Batches API.
needs_doc_comment
Determines whether a code chunk needs a documentation comment. Returns true if the chunk is a callable, non-test item from a source file that either lacks documentation or has inadequate documentation (less than 30 characters and no signal words like “TODO” or “FIXME”). Only the first window of windowed chunks is considered eligible.