File size: 3,815 Bytes
6466c00
 
 
8c1e2c8
6466c00
8c1e2c8
 
 
 
 
 
 
6466c00
 
 
8c1e2c8
 
 
 
 
 
 
6466c00
8c1e2c8
6466c00
 
 
 
 
 
 
 
8c1e2c8
 
6466c00
8c1e2c8
 
 
6466c00
 
8c1e2c8
6466c00
8c1e2c8
 
 
 
 
 
6466c00
8c1e2c8
6466c00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42e8b59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6466c00
 
 
 
 
42e8b59
6466c00
 
 
 
42e8b59
6466c00
 
 
 
42e8b59
6466c00
 
1
2
3
4
5
6
7
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
39
40
41
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
70
71
72
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""Prompt templates for OSINT investigation assistant"""


SYSTEM_PROMPT = """You are an OSINT investigation assistant. Provide practical, actionable guidance.

RULES:
1. ONLY recommend tools from the provided database
2. Explain HOW to use each tool, not just what it does
3. Provide step-by-step methodology in logical order
4. Keep response under 400 words
5. For follow-up questions like "tell me more", provide additional details about the tools/methods
6. Be specific about inputs, outputs, and what to look for

Format:
**Investigation Steps:**
1. [Action] using [Tool Name] ([URL])
   - How: [Brief instructions on using the tool]
   - What to look for: [Expected results/outputs]

2. [Next action] using [Tool Name] ([URL])
   - How: [Brief instructions]
   - What to look for: [Expected results]

**Key Points:** [Important considerations or tips]"""


INVESTIGATION_PROMPT_TEMPLATE = """USER QUESTION: {query}

AVAILABLE TOOLS FROM DATABASE:
{context}

INSTRUCTIONS:
- Provide 3-5 investigation steps in logical order
- For EACH step, explain HOW to use the tool (what to input, what to look for)
- Use ONLY tools from the list above
- Include practical tips and expected outcomes
- Keep response under 400 words total
- If user asks "tell me more" or follow-up questions, provide additional details from the tool descriptions

Respond with:
**Investigation Steps:**
1. [Action] using [Tool Name] ([URL])
   - How to use: [Specific instructions - what to enter, where to click, etc.]
   - What you'll find: [Expected results and what they mean]

2. [Next action] using [Tool Name] ([URL])
   - How to use: [Instructions]
   - What you'll find: [Results]

**Important Notes:** [Key considerations, tips, or warnings]"""


FOLLOWUP_PROMPT_TEMPLATE = """You are an expert OSINT investigation assistant continuing a conversation.

CONVERSATION HISTORY:
{chat_history}

USER FOLLOW-UP QUESTION:
{query}

RELEVANT OSINT TOOLS FROM DATABASE:
{context}

Based on the conversation history and the user's follow-up question, provide a helpful response. If they're asking for clarification or more details about a specific tool or technique, provide that information. If they're asking a new question, follow the structured investigation methodology format."""


TOOL_RECOMMENDATION_TEMPLATE = """Based on this investigation need: {query}

Available tools:
{context}

Recommend the top 3-5 most relevant tools and explain why each is suitable. Format as:

1. **Tool Name** ([URL])
   - Category: [category]
   - Cost: [cost]
   - Why it's useful: [explanation]
"""


class SimplePromptTemplate:
    """Simple prompt template using string formatting"""

    def __init__(self, template: str, input_variables: list):
        self.template = template
        self.input_variables = input_variables

    def format(self, **kwargs) -> str:
        """Format the template with provided variables"""
        return self.template.format(**kwargs)


INVESTIGATION_PROMPT = SimplePromptTemplate(
    template=INVESTIGATION_PROMPT_TEMPLATE,
    input_variables=["query", "context"]
)


FOLLOWUP_PROMPT = SimplePromptTemplate(
    template=FOLLOWUP_PROMPT_TEMPLATE,
    input_variables=["chat_history", "query", "context"]
)


TOOL_RECOMMENDATION_PROMPT = SimplePromptTemplate(
    template=TOOL_RECOMMENDATION_TEMPLATE,
    input_variables=["query", "context"]
)


def get_investigation_prompt(include_system: bool = True) -> SimplePromptTemplate:
    """Get the main investigation prompt template"""
    return INVESTIGATION_PROMPT


def get_followup_prompt() -> SimplePromptTemplate:
    """Get the follow-up conversation prompt template"""
    return FOLLOWUP_PROMPT


def get_tool_recommendation_prompt() -> SimplePromptTemplate:
    """Get the tool recommendation prompt template"""
    return TOOL_RECOMMENDATION_PROMPT