Skip to main content

Module prompt_enrichment

Module prompt_enrichment 

Source
Expand description

Prompt enrichment service.

Enriches prompt templates with LLM-generated metadata including:

  • Prompt-level description
  • Tags for categorization
  • Variable descriptions, defaults, and required flags

§Fallback Behavior

The enrichment service degrades gracefully when the LLM is unavailable:

ConditionBehaviorResult Status
LLM available, successFull metadata generatedFull
LLM available, timeoutUse extracted variables onlyFallback
LLM available, errorUse extracted variables onlyFallback
No LLM configuredUse extracted variables onlyFallback
User passed --no-enrichSkip enrichment entirelySkipped

§Fallback Metadata

When enrichment fails or is unavailable, minimal metadata is generated:

  • description: Empty string (user can edit later)
  • tags: Empty array
  • variables: Names preserved, descriptions set to “No description”

§User Values Take Precedence

User-provided metadata is never overwritten by LLM enrichment:

User provides: description="My review prompt", tags=["review"]
LLM generates: description="Code review assistant", tags=["code", "review", "quality"]

Result: description="My review prompt", tags=["review"]  (user values preserved)

§Error Handling

Error TypeLoggingUser Impact
Timeout (5s)WARNPrompt saved with fallback metadata
Parse errorWARNPrompt saved with fallback metadata
Network errorWARNPrompt saved with fallback metadata
No LLM configDEBUGPrompt saved with fallback metadata

The service never fails a prompt save due to enrichment errors.

Structs§

EnrichmentRequest
Request for prompt enrichment.
LlmEnrichmentResponse 🔒
LLM response format for enrichment.
LlmVariableResponse 🔒
Variable definition from LLM response.
PartialMetadata
Partial metadata provided by the user.
PromptEnrichmentResult
Result of prompt enrichment.
PromptEnrichmentService
Service for enriching prompt templates with LLM-generated metadata.

Enums§

EnrichmentStatus
Status of the enrichment operation.

Constants§

ENRICHMENT_TIMEOUT
Default timeout for LLM enrichment calls.
PROMPT_ENRICHMENT_SYSTEM_PROMPT
System prompt for prompt template enrichment.

Functions§

default_required 🔒
Default for required field.
escape_xml 🔒