Class: Deepsearch::PromptsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/deepsearch/prompts_config.rb

Overview

Defines the default prompts used in various steps of the Deepsearch pipeline. Users can provide their own prompt configuration object to customize these prompts. The custom object should respond to the same methods as this class.

Instance Method Summary collapse

Instance Method Details

#enrich_query_prompt(query:) ⇒ String

Returns The prompt for enriching the query with tags for embedding.

Parameters:

  • query (String)

    The user query to be enriched.

Returns:

  • (String)

    The prompt for enriching the query with tags for embedding.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/deepsearch/prompts_config.rb', line 28

def enrich_query_prompt(query:)
  "    You are a search query expansion assistant. Based on the user's query, generate 5 to 7 highly relevant tags or keywords that expand its core concepts. These tags are used to improve vector search results.\n\n    INSTRUCTIONS:\n    - Do NOT add any explanation, numbering, or introductory text.\n    - Provide ONLY a single line of comma-separated tags.\n\n    USER QUERY: \"\#{query}\"\n\n    TAGS:\n  PROMPT\nend\n"

#subquery_prompt(query:) ⇒ String

Returns The prompt for generating subqueries.

Parameters:

  • query (String)

    The original user query.

Returns:

  • (String)

    The prompt for generating subqueries.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/deepsearch/prompts_config.rb', line 10

def subquery_prompt(query:)
  "    You are a search query expansion expert. Given a search query, generate 3-5 related subqueries that would help find more comprehensive information about the topic.\n\n    Original query: \"\#{query}\"\n\n    Please generate subqueries that:\n    1. Cover different aspects of the topic\n    2. Use varied terminology and synonyms\n    3. Are specific enough to be useful but broad enough to capture relevant information\n    4. Focus on different angles (technical, practical, conceptual, etc.)\n\n    Format your response as a simple list, one subquery per line, without numbering or bullet points.\n  PROMPT\nend\n"

#summarization_prompt(query:, context_text:, sources_list:) ⇒ String

Returns The prompt for summarizing the context and answering the query.

Parameters:

  • query (String)

    The original user query.

  • context_text (String)

    The aggregated text from relevant sources.

  • sources_list (String)

    The formatted list of sources for citation.

Returns:

  • (String)

    The prompt for summarizing the context and answering the query.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/deepsearch/prompts_config.rb', line 46

def summarization_prompt(query:, context_text:, sources_list:)
  "    You are a research assistant. Your task is to synthesize a comprehensive answer to the user's query based *only* on the provided text snippets.\n\n    User Query: \"\#{query}\"\n\n    Provided Context:\n    ---\n    \#{context_text}\n    ---\n\n    Sources:\n    \#{sources_list}\n\n    Instructions:\n    0.  Format: Markdown\n    1.  Carefully read the user's query and all the provided context from the sources.\n    2.  When you use information from a source, you MUST cite it using the following markdown link format: `[<source_number>](<source_link>)`.\n        *   **To find the `<source_link>`:** The 'Sources' section provides a numbered list where each source is in the format `[<number>]: <url>`. Extract this URL for the specific source number you are citing.\n        *   **Example Citation:** If a fact comes from source number 1, and the 'Sources' section lists `[1]: https://example.com/source1`, your citation should be `[1](https://example.com/source1)`.\n        *   **Placement:** Place citations immediately after the sentence or clause where the information is used.\n        *   **Multiple Sources:** If a single statement draws information from multiple sources, cite each source individually, for example: `[1](https://link1.com) [3](https://link3.com)`.\n        *   **Crucial:** Always use the exact format `[<source_number>](<source_link>)` with square brackets around the number.\n    3.  Structure your response with clear headings and bullet points where appropriate.\n    4.  If the provided context does not contain enough information to answer the query, state that clearly: \"I cannot answer this query based on the provided sources.\"\n    5.  At the end of your response, include a \"## References\" section that lists all used sources in the following format:\n        ```\n        ## References\n        1. [Source Title](<source_link>)\n        2. [Another Source](<another_link>)\n        ```\n        Where possible, extract meaningful titles from the context or use the domain name if no title is available.\n    6.  Do not include sources in the References section that you didn't actually cite in your response.\n  PROMPT\nend\n"