Skip to content

Prompt

This docs was updated at: 2026-02-23

com.paragon.prompts.Prompt  ยท  Class


Represents an immutable text prompt that can contain template expressions.

A Prompt instance manages text content that can include various template features like variable placeholders ({{variable_name}}), conditional blocks ({{#if condition}...{{/if}}}), and iteration blocks ({{#each items}...{{/each}}}).

This class is immutable and thread-safe. All template processing methods return new Prompt instances.

Builder Features

  • Order Independent: All builder methods can be called in any order
  • No Dependencies: No method requires another method to be called first
  • Additive: Methods add to existing configuration rather than replacing
  • Multi-language: Supports English (US) and Portuguese (BR)

Builder Usage Examples

// Methods can be called in any order - these produce equivalent results:
Prompt prompt1 = Prompt.builder()
    .task("Analyze the data")
    .role("data analyst")
    .withChainOfThought()
    .build();
Prompt prompt2 = Prompt.builder()
    .withChainOfThought()
    .role("data analyst")
    .task("Analyze the data")
    .build();
// Multi-language support
Prompt ptBrPrompt = Prompt.builder()
    .language(Language.PT_BR)
    .role("analista de dados")
    .task("Analise os dados de vendas")
    .build();

Since: 1.0

Methods

of

public static Prompt of(String text)

Creates a new Prompt from text content.


fromText

public static Prompt fromText(String text)

Creates a new Prompt from text content (alias for .of(String)).


empty

public static Prompt empty()

Creates a new empty Prompt.


builder

public static Builder builder()

Creates a new Builder for constructing prompts with best practices.

Order Independence: All builder methods can be called in any order. The final prompt is assembled when Builder.build() is called.

No Dependencies: No method requires another method to be called. Each method is independent and optional.

Returns

a new Builder instance


builder

public static Builder builder(PromptTemplate template)

Creates a Builder pre-configured for a specific use case.


builder

public static Builder builder(Language language)

Creates a Builder with a specific language.

Parameters

Name Description
language the language for the prompt

Returns

a new Builder with the language set


forTask

public static Builder forTask(String taskInstruction)

Creates a Builder starting with a specific task instruction.


forExtraction

public static Builder forExtraction(String whatToExtract)

Creates a Builder configured for extracting structured data.


forClassification

public static Builder forClassification(String... categories)

Creates a Builder configured for classification tasks.


forReasoning

public static Builder forReasoning(String problem)

Creates a Builder configured for multi-step reasoning problems.


forCode

public static Builder forCode(String language)

Creates a Builder configured for code generation.


forRAG

public static Builder forRAG()

Creates a Builder configured for RAG (Retrieval Augmented Generation).


forConversation

public static Builder forConversation()

Creates a Builder configured for conversational AI.


forTranslation

public static Builder forTranslation(String sourceLanguage, String targetLanguage)

Creates a Builder configured for translation tasks.


forSummarization

public static Builder forSummarization()

Creates a Builder configured for summarization tasks.


forQA

public static Builder forQA()

Creates a Builder configured for question answering.


forCreativeWriting

public static Builder forCreativeWriting()

Creates a Builder configured for creative writing.


forDataAnalysis

public static Builder forDataAnalysis()

Creates a Builder configured for data analysis.


forInterview

public Builder forInterview()

Configures for conducting an interview.


forDebate

public Builder forDebate(String position)

Configures for a debate format.


forRolePlay

public Builder forRolePlay(String character, String scenario)

Configures for role-playing scenarios.


forSWOTAnalysis

public Builder forSWOTAnalysis()

Configures for SWOT analysis.


forProsConsAnalysis

public Builder forProsConsAnalysis()

Configures for pros and cons analysis.


forDecisionMaking

public Builder forDecisionMaking()

Configures for decision-making framework.


forRootCauseAnalysis

public Builder forRootCauseAnalysis()

Configures for root cause analysis (5 Whys).


forEmailDrafting

public Builder forEmailDrafting(EmailTone emailTone)

Configures for email drafting.


forTechnicalWriting

public Builder forTechnicalWriting()

Configures for technical writing.


forAcademicWriting

public Builder forAcademicWriting(CitationStyle citationStyle)

Configures for scientific/academic writing.


forMarketingCopy

public Builder forMarketingCopy()

Configures for persuasive/marketing copy.


forStorytelling

public Builder forStorytelling()

Configures for storytelling/narrative.


forLegalAnalysis

public Builder forLegalAnalysis()

Configures for legal document analysis (with disclaimer).


forMedicalInformation

public Builder forMedicalInformation()

Configures for medical information (with strong disclaimer).


forLanguageLearning

public Builder forLanguageLearning(String targetLang, String nativeLang)

Configures for language learning assistance.


forELI5

public Builder forELI5()

Configures for ELI5 (Explain Like I'm 5) style explanations.


forExpertExplanation

public Builder forExpertExplanation()

Configures for expert-level explanation.


forQuizGeneration

public Builder forQuizGeneration(int numQuestions, QuestionType questionType)

Configures for quiz/test generation.


forAPIDocumentation

public Builder forAPIDocumentation()

Configures for API documentation generation.


forChangelog

public Builder forChangelog()

Configures for changelog generation.


forUserStories

public Builder forUserStories()

Configures for user story generation.


forDataVisualization

public Builder forDataVisualization()

Configures for data visualization suggestions.


forAccessibilityReview

public Builder forAccessibilityReview()

Configures for accessibility review.


forSecurityReview

public Builder forSecurityReview()

Configures for security review.


forPerformanceOptimization

public Builder forPerformanceOptimization()

Configures for performance optimization suggestions.


bulletPointsOnly

public Builder bulletPointsOnly()

Requests a response in bullet points only.


executiveSummary

public Builder executiveSummary()

Requests an executive summary style response.


stepByStep

public Builder stepByStep()

Requests step-by-step format.


wordCount

public Builder wordCount(int min, int max)

Requests response with specific word count.


sentenceCount

public Builder sentenceCount(int count)

Requests response with specific sentence count.


avoid

public Builder avoid(String... items)

Configures to avoid certain topics or words.


focusOn

public Builder focusOn(String... topics)

Configures to focus on specific topics.


withFallback

public Builder withFallback(String fallbackBehavior)

Adds a fallback instruction for when the AI cannot complete the task.


withSelfAssessment

public Builder withSelfAssessment()

Requests self-assessment of the response quality.


handleAmbiguity

public Builder handleAmbiguity(AmbiguityStrategy strategy)

Configures for handling ambiguous inputs.


difficultyLevel

public Builder difficultyLevel(DifficultyLevel level)

Sets the difficulty level for explanations or content.


thinkingStyle

public Builder thinkingStyle(ThinkingStyle style)

Sets the thinking style to use.


thinkingStyles

public Builder thinkingStyles(ThinkingStyle... styles)

Combines multiple thinking styles.


withNumberedReferences

public Builder withNumberedReferences()

Requests numbered references/citations in the response.


withInlineCitations

public Builder withInlineCitations()

Requests inline citations.


forDomain

public Builder forDomain(String domain)

Configures for a specific domain/industry.


withTimeContext

public Builder withTimeContext(String timeContext)

Adds time constraints context.


withRegionalContext

public Builder withRegionalContext(String region)

Adds geographical/regional context.


withSummaryAtEnd

public Builder withSummaryAtEnd()

Requests a summary at the end of the response.


withTLDR

public Builder withTLDR()

Requests a TL;DR at the beginning of the response.


withStructuredThinking

public Builder withStructuredThinking()

Configures for structured thinking with explicit sections.


includeExamples

public Builder includeExamples(int count)

Requests examples to be included in the response.


useAnalogies

public Builder useAnalogies()

Requests analogies to be used in explanations.


neutral

public Builder neutral()

Configures for balanced/neutral perspective.


enthusiastic

public Builder enthusiastic()

Configures for enthusiastic/positive tone.


empathetic

public Builder empathetic()

Configures for empathetic response style.


actionable

public Builder actionable()

Configures response to be actionable.


withMetrics

public Builder withMetrics()

Requests specific metrics or quantification.


asTimeline

public Builder asTimeline()

Requests timeline or schedule format.


asPrioritizedList

public Builder asPrioritizedList()

Requests prioritized list format.


quickResponse

public Builder quickResponse()

Configures for quick/immediate response needs.


comprehensive

public Builder comprehensive()

Configures for comprehensive/thorough response.


forVersion

public Builder forVersion(String version)

Adds version/compatibility context.


forUseCase

public Builder forUseCase(String useCase)

Specifies the intended use case for the response.


withBudgetContext

public Builder withBudgetContext(String budget)

Specifies budget constraints context.


compliantWith

public Builder compliantWith(String... standards)

Configures for compliance with specific standards.