1- from hackingBuddyGPT .usecases .web_api_testing .prompt_generation .information .prompt_information import PromptStrategy , PromptContext , \
2- PromptPurpose
1+ from typing import List , Optional
2+
3+ from hackingBuddyGPT .usecases .web_api_testing .prompt_generation .information .prompt_information import (
4+ PromptStrategy , PromptContext , PromptPurpose
5+ )
36from hackingBuddyGPT .usecases .web_api_testing .prompt_generation .prompts .basic_prompt import BasicPrompt
47
58class TreeOfThoughtPrompt (BasicPrompt ):
@@ -13,52 +16,55 @@ class TreeOfThoughtPrompt(BasicPrompt):
1316 Attributes:
1417 context (PromptContext): The context in which prompts are generated.
1518 prompt_helper (PromptHelper): A helper object for managing and generating prompts.
19+ rest_api (str): The REST API endpoint for which prompts are generated.
20+ round (int): The round number for the prompt generation process.
21+ purpose (Optional[PromptPurpose]): The purpose of the prompt generation, which can be set during the process.
1622 """
1723
18- def __init__ (self , context , prompt_helper , rest_api , round ) :
24+ def __init__ (self , context : PromptContext , prompt_helper : 'PromptHelper' , rest_api : str , round : int ) -> None :
1925 """
2026 Initializes the TreeOfThoughtPrompt with a specific context and prompt helper.
2127
2228 Args:
2329 context (PromptContext): The context in which prompts are generated.
2430 prompt_helper (PromptHelper): A helper object for managing and generating prompts.
25- rest_api (str): The REST API endpoint
26- round (int): The round number
31+ rest_api (str): The REST API endpoint.
32+ round (int): The round number for the prompt generation process.
2733 """
2834 super ().__init__ (context , prompt_helper , PromptStrategy .TREE_OF_THOUGHT )
29- self .rest_api = rest_api
30- self .round = round
31- self .purpose = None
35+ self .rest_api : str = rest_api
36+ self .round : int = round
37+ self .purpose : Optional [ PromptPurpose ] = None
3238
33- def generate_prompt (self , move_type , hint , previous_prompt ): # still work in progress
39+ def generate_prompt (self , move_type : str , hint : str , previous_prompt : List [ dict ]) -> str :
3440 """
3541 Generates a prompt using the tree-of-thought strategy.
3642
3743 Args:
3844 move_type (str): The type of move to generate.
3945 hint (str): An optional hint to guide the prompt generation.
40- previous_prompt (list ): A list of previous prompt entries, each containing a "content" key.
46+ previous_prompt (List[dict] ): A list of previous prompt entries, each containing a "content" key.
4147
4248 Returns:
4349 str: The generated prompt.
4450 """
4551 if self .context == PromptContext .DOCUMENTATION :
4652 tree_of_thoughts_steps = [(
47- "Imagine three different OpenAPI specification specialist .\n "
48- "All experts will write down one step of their thinking,\n "
49- "then share it with the group.\n "
50- "After that, all remaining specialists will proceed to the next step, and so on.\n "
51- "If any specialist realizes they're wrong at any point, they will leave.\n "
52- f"The question is: Create an OpenAPI specification for this REST API { self .rest_api } "
53+ "Imagine three different OpenAPI specification specialists .\n "
54+ "All experts will write down one step of their thinking,\n "
55+ "then share it with the group.\n "
56+ "After that, all remaining specialists will proceed to the next step, and so on.\n "
57+ "If any specialist realizes they're wrong at any point, they will leave.\n "
58+ f"The question is: Create an OpenAPI specification for this REST API { self .rest_api } "
5359 )]
5460 else :
5561 tree_of_thoughts_steps = [(
56- "Imagine three different Pentest experts are answering this question.\n "
57- "All experts will write down one step of their thinking,\n "
58- "then share it with the group.\n "
59- "After that, all experts will proceed to the next step, and so on.\n "
60- "If any expert realizes they're wrong at any point, they will leave.\n "
61- f"The question is: Create pentests for this REST API { self .rest_api } "
62+ "Imagine three different Pentest experts are answering this question.\n "
63+ "All experts will write down one step of their thinking,\n "
64+ "then share it with the group.\n "
65+ "After that, all experts will proceed to the next step, and so on.\n "
66+ "If any expert realizes they're wrong at any point, they will leave.\n "
67+ f"The question is: Create pentests for this REST API { self .rest_api } "
6268 )]
6369 self .purpose = PromptPurpose .AUTHENTICATION_AUTHORIZATION
6470
0 commit comments