Module: LlmConductor::Prompts

Included in:
Clients::BaseClient
Defined in:
lib/llm_conductor/prompts.rb,
lib/llm_conductor/prompts/base_prompt.rb

Overview

Collection of general-purpose prompt templates for common LLM tasks

Defined Under Namespace

Classes: BasePrompt

Instance Method Summary collapse

Instance Method Details

#prompt_analyze_content(data) ⇒ Object

General prompt for content analysis and data extraction Flexible template for various content analysis tasks



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/llm_conductor/prompts.rb', line 42

def prompt_analyze_content(data)
  content_type = data[:content_type] || 'webpage content'
  analysis_fields = data[:fields] || %w[summary key_points entities]
  output_format = data[:output_format] || 'structured text'

  "    Analyze the provided \#{content_type} and extract the requested information.\n\n    Content:\n    \#{data[:content] || data[:htmls] || data[:text]}\n\n    Analysis Fields:\n    \#{analysis_fields.map { |field| \"- \#{field}\" }.join(\"\\n\")}\n\n    \#{\"Additional Instructions:\\n\#{data[:instructions]}\" if data[:instructions]}\n\n    \#{if output_format == 'json'\n        json_structure = analysis_fields.map { |field| \"  \\\"\#{field}\\\": \\\"value or array\\\"\" }.join(\",\\n\")\n        \"Output Format: JSON with the following structure:\\n{\\n\#{json_structure}\\n}\"\n      else\n        \"Output Format: \#{output_format}\"\n      end}\n\n    \#{\"Constraints:\\n\#{data[:constraints]}\" if data[:constraints]}\n\n    Provide a comprehensive analysis focusing on the requested fields.\n  PROMPT\nend\n"

#prompt_classify_content(data) ⇒ Object

General prompt for data classification and categorization Useful for various classification tasks



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/llm_conductor/prompts.rb', line 104

def prompt_classify_content(data)
  categories = data[:categories] || []
  classification_type = data[:classification_type] || 'content'
  confidence_scores = data[:include_confidence] || false

  "    Classify the provided \#{classification_type} into the most appropriate category.\n\n    Content to Classify:\n    \#{data[:content] || data[:text] || data[:description]}\n\n    Available Categories:\n    \#{categories.map.with_index(1) { |cat, i| \"\#{i}. \#{cat}\" }.join(\"\\n\")}\n\n    \#{\"Classification Criteria:\\n\#{data[:classification_criteria]}\" if data[:classification_criteria]}\n\n    \#{if confidence_scores\n        'Output Format: JSON with category and confidence score (0-1)'\n      else\n        'Output Format: Return the most appropriate category name'\n      end}\n\n    \#{if data[:multiple_categories]\n        \"Note: Multiple categories may apply - select up to \#{data[:max_categories] || 3} most relevant.\"\n      else\n        'Note: Select only the single most appropriate category.'\n      end}\n\n    Provide your classification based on the content analysis.\n  PROMPT\nend\n"

#prompt_custom(data) ⇒ Object

Flexible custom prompt template Allows for dynamic prompt creation with variable substitution



138
139
140
141
# File 'lib/llm_conductor/prompts.rb', line 138

def prompt_custom(data)
  template = data.fetch(:template)
  template % data
end

General prompt for extracting links from HTML content More flexible and applicable to various use cases



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/llm_conductor/prompts.rb', line 8

def prompt_extract_links(data)
  criteria = data[:criteria] || 'relevant and useful'
  max_links = data[:max_links] || 10
  link_types = data[:link_types] || %w[navigation content footer]

  "    Analyze the provided HTML content and extract links based on the specified criteria.\n\n    HTML Content:\n    \#{data[:html_content] || data[:htmls]}\n\n    Extraction Criteria: \#{criteria}\n    Maximum Links: \#{max_links}\n    Link Types to Consider: \#{link_types.join(', ')}\n\n    \#{\"Domain Filter: Only include links from domain \#{data[:domain_filter]}\" if data[:domain_filter]}\n\n    Instructions:\n    1. Parse the HTML content and identify all hyperlinks\n    2. Filter links based on the provided criteria\n    3. Prioritize links from specified areas: \#{link_types.join(', ')}\n    4. Return up to \#{max_links} most relevant links\n    \#{if data[:format] == :json\n        '5. Format output as a JSON array of URLs'\n      else\n        '5. Format output as a newline-separated list of URLs'\n      end}\n\n    Provide only the links without additional commentary.\n  PROMPT\nend\n"

#prompt_summarize_text(data) ⇒ Object

General prompt for text summarization Applicable to various types of text content



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/llm_conductor/prompts.rb', line 73

def prompt_summarize_text(data)
  max_length = data[:max_length] || '200 words'
  focus_areas = data[:focus_areas] || []
  style = data[:style] || 'concise and informative'

  "    Summarize the following text content.\n\n    Text:\n    \#{data[:text] || data[:content] || data[:description]}\n\n    Summary Requirements:\n    - Maximum Length: \#{max_length}\n    - Style: \#{style}\n    \#{\"- Focus Areas: \#{focus_areas.join(', ')}\" if focus_areas.any?}\n    \#{\"- Target Audience: \#{data[:audience]}\" if data[:audience]}\n\n    \#{'Include key points and main themes.' if data[:include_key_points]}\n\n    \#{if data[:output_format] == 'bullet_points'\n        'Format as bullet points.'\n      elsif data[:output_format] == 'paragraph'\n        'Format as a single paragraph.'\n      end}\n\n    Provide a clear and accurate summary.\n  PROMPT\nend\n"