MCPcopy Create free account
hub / github.com/MarketSquare/robotframework-ai / Module

Class Module

src/RobotFrameworkAI/modules/Module.py:16–282  ·  view source on GitHub ↗

The interface for all modules. A module is a class containing keywords for the Robot Framework to use. They use AI to perform the task they are intended to do. This can be the generation of test data or just a simple chatbot that answers your questions. In this base class for

Source from the content-addressed store, hash-verified

14
15@library
16class Module:
17 """
18 The interface for all modules.
19
20 A module is a class containing keywords for the Robot Framework to use.
21 They use AI to perform the task they are intended to do.
22 This can be the generation of test data or just a simple chatbot that answers your questions.
23
24 In this base class for modules common code is shared. This includes the creation of Prompt objects and
25 the validation and the setting of common arguments.
26
27 The setters can be used to set the defaut values for the arguments for each keyword.
28 All attributes and setters here are common arguments and are shared between every module.
29 This also means that setting these arguments will set them for every module.
30
31 To create a new module, create a new folder in the modules folder for all its logic.
32 Create a keyword that atleast accepts all these arguments and uses the get_default_values_for_arguments
33 method to set the values of each argument incase they are not given.
34 Make sure each arguments defaults to None so the setters can take effect.
35
36 Call the create_prompt method to create a Prompt and use this with the cal_ai_tool method from the AI_Interface.
37 This wil return a Response which then needs to be structured in the way the users of the module expect it.
38
39 NOTE: When creating a package all module will get inherited by the RobotFrameworkAI library. This way all
40 keywords and methods will be available. An anoying side effect of this is that methods in seperate classes
41 but with the same name will both be available. This causes only the method of the first inherited class to
42 be available.
43 """
44
45 def __init__(self) -> None:
46 self.ai_interface = AI_Interface()
47 self.module_name = "base_module"
48 self.ai_tool = None
49 # Set arguments
50 self.ai_model = None
51 self.model = None
52 self.max_tokens = 256
53 self.temperature = 1
54 self.top_p = .5
55 self.frequency_penalty = 0
56 self.presence_penalty = 0
57 self.response_format = None
58
59 def create_prompt(
60 self,
61 ai_tool:str,
62 ai_model:str,
63 system_message:str,
64 user_message:str,
65 history:str,
66 model:str,
67 max_tokens:int,
68 temperature:float,
69 top_p:float,
70 frequency_penalty:float,
71 presence_penalty:float,
72 response_format:dict,
73 ai_tool_data:AIToolData = None

Callers 1

moduleFunction · 0.90

Calls

no outgoing calls

Tested by 1

moduleFunction · 0.72