docs
This commit is contained in:
parent
a0a0e68c49
commit
51f86f214a
@ -629,13 +629,15 @@ __pdoc__ = {
|
|||||||
raise ValueError("Missing openai api_key")
|
raise ValueError("Missing openai api_key")
|
||||||
self.__prompt = {}
|
self.__prompt = {}
|
||||||
self.__prompt["original_system"] = """
|
self.__prompt["original_system"] = """
|
||||||
When provided with user input for an SSH connection management application, analyze the input and extract the following information:
|
You are the AI assistant of a network connection manager and automation app called connpy. When provided with user input analyze the input and extract the following information:
|
||||||
|
|
||||||
- app_related: True if the input is related to the application's purpose and the request is understood; False if the input is not related, not understood, or if mandatory information like filter is missing.
|
- app_related: True if the input is related to the application's purpose and the request is understood; False if the input is not related, not understood, or if mandatory information like filter is missing. If user ask information about the app it should be false
|
||||||
- type: Given a user input, identify the type of request they want to make. The input will represent one of two options:
|
- type: Given a user input, identify the type of request they want to make. The input will represent one of two options:
|
||||||
|
|
||||||
1. "command" - The user wants to get information from devices by running commands.
|
1. "command" - The user wants to get information from devices by running commands.
|
||||||
2. "list_nodes" - The user wants to get a list of nodes, devices, servers, or routers.
|
2. "list_nodes" - The user wants to get a list of nodes, devices, servers, or routers.
|
||||||
Response wich command or list_nodes type depending on the request.
|
The 'type' field should reflect whether the user input is a command or a request for a list of nodes.
|
||||||
|
|
||||||
- filter: One or more regex patterns indicating the device or group of devices the command should be run on, returned as a Python list (e.g., ['hostname', 'hostname@folder', '@subfolder@folder']). The filter can have different formats, such as:
|
- filter: One or more regex patterns indicating the device or group of devices the command should be run on, returned as a Python list (e.g., ['hostname', 'hostname@folder', '@subfolder@folder']). The filter can have different formats, such as:
|
||||||
- hostname
|
- hostname
|
||||||
- hostname@folder
|
- hostname@folder
|
||||||
@ -644,11 +646,16 @@ __pdoc__ = {
|
|||||||
- @folder
|
- @folder
|
||||||
- @subfolder@folder
|
- @subfolder@folder
|
||||||
- regex_pattern
|
- regex_pattern
|
||||||
|
|
||||||
The filter should be extracted from the user input exactly as it was provided.
|
The filter should be extracted from the user input exactly as it was provided.
|
||||||
Always preserve the exact filter pattern provided by the user, with no modifications. Do not process any regex, the application can do that.
|
Always preserve the exact filter pattern provided by the user, with no modifications. Do not process any regex, the application can do that.
|
||||||
If no filter is specified, set it to None.
|
If no filter is specified, set it to None.
|
||||||
- Expected: A value representing an expected output to search for when running the command. For the user this is a optional value. Set it to 'None' if no value was captured.
|
|
||||||
expected value should ALWAYS come from the user input explicitly.
|
- Expected: This field represents an expected output to search for when running the command. It's an optional value for the user.
|
||||||
|
Set it to 'None' if no value was captured.
|
||||||
|
The expected value should ALWAYS come from the user input explicitly.
|
||||||
|
Users will typically use words like verify, check, make sure, or similar to refer to the expected value.
|
||||||
|
|
||||||
- response: An optional field to be filled when app_related is False or when providing an explanation related to the app. This is where you can engage in small talk, answer questions not related to the app, or provide explanations about the extracted information.
|
- response: An optional field to be filled when app_related is False or when providing an explanation related to the app. This is where you can engage in small talk, answer questions not related to the app, or provide explanations about the extracted information.
|
||||||
|
|
||||||
Always respond in the following format:
|
Always respond in the following format:
|
||||||
@ -664,14 +671,14 @@ __pdoc__ = {
|
|||||||
self.__prompt["command_system"] = """
|
self.__prompt["command_system"] = """
|
||||||
For each device listed below, provide the command(s) needed to perform the specified action, depending on the device OS (e.g., Cisco IOSXR router, Linux server). Always format your response as a Python list (e.g., ['command1', 'command2']).
|
For each device listed below, provide the command(s) needed to perform the specified action, depending on the device OS (e.g., Cisco IOSXR router, Linux server). Always format your response as a Python list (e.g., ['command1', 'command2']).
|
||||||
|
|
||||||
It's very important to note: If a user has provided a specific command to be run, you should include that command exactly as provided, even if it's not recognized or understood. No alterations should be made to the user-provided commands under any circumstances.
|
|
||||||
|
|
||||||
The application knows how to connect to devices via SSH, so you only need to provide the command(s) to run after connecting.
|
The application knows how to connect to devices via SSH, so you only need to provide the command(s) to run after connecting.
|
||||||
|
|
||||||
If the commands needed are not for the specific OS type, just send an empty list (e.g., []).
|
If the commands needed are not for the specific OS type, just send an empty list (e.g., []).
|
||||||
|
|
||||||
It is crucial to always include the device name provided in your response, even when there is only one device.
|
It is crucial to always include the device name provided in your response, even when there is only one device.
|
||||||
|
|
||||||
|
Note: Preserving the integrity of user-provided commands is of utmost importance. If a user has provided a specific command to run, include that command exactly as it was given, even if it's not recognized or understood. Under no circumstances should you modify or alter user-provided commands.
|
||||||
|
|
||||||
Your response has to be always like this:
|
Your response has to be always like this:
|
||||||
node1: ["command1", "command2"]
|
node1: ["command1", "command2"]
|
||||||
node2: ["command1", "command2", "command3"]
|
node2: ["command1", "command2", "command3"]
|
||||||
@ -796,9 +803,9 @@ __pdoc__ = {
|
|||||||
output_str = "\n".join(output_list)
|
output_str = "\n".join(output_list)
|
||||||
command_input = f"input: {user_input}\n\nDevices:\n{output_str}"
|
command_input = f"input: {user_input}\n\nDevices:\n{output_str}"
|
||||||
message = []
|
message = []
|
||||||
message.append({"role": "system", "content": dedent(self.__prompt["command_system"])})
|
message.append({"role": "system", "content": dedent(self.__prompt["command_system"]).strip()})
|
||||||
message.append({"role": "user", "content": dedent(self.__prompt["command_user"])})
|
message.append({"role": "user", "content": dedent(self.__prompt["command_user"]).strip()})
|
||||||
message.append({"role": "assistant", "content": dedent(self.__prompt["command_assistant"])})
|
message.append({"role": "assistant", "content": dedent(self.__prompt["command_assistant"]).strip()})
|
||||||
message.append({"role": "user", "content": command_input})
|
message.append({"role": "user", "content": command_input})
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model=self.model,
|
model=self.model,
|
||||||
@ -814,9 +821,9 @@ __pdoc__ = {
|
|||||||
def _get_filter(self, user_input, chat_history = None):
|
def _get_filter(self, user_input, chat_history = None):
|
||||||
#Send the request to identify the filter and other attributes from the user input to GPT.
|
#Send the request to identify the filter and other attributes from the user input to GPT.
|
||||||
message = []
|
message = []
|
||||||
message.append({"role": "system", "content": dedent(self.__prompt["original_system"])})
|
message.append({"role": "system", "content": dedent(self.__prompt["original_system"]).strip()})
|
||||||
message.append({"role": "user", "content": dedent(self.__prompt["original_user"])})
|
message.append({"role": "user", "content": dedent(self.__prompt["original_user"]).strip()})
|
||||||
message.append({"role": "assistant", "content": dedent(self.__prompt["original_assistant"])})
|
message.append({"role": "assistant", "content": dedent(self.__prompt["original_assistant"]).strip()})
|
||||||
if not chat_history:
|
if not chat_history:
|
||||||
chat_history = []
|
chat_history = []
|
||||||
chat_history.append({"role": "user", "content": user_input})
|
chat_history.append({"role": "user", "content": user_input})
|
||||||
@ -840,9 +847,9 @@ __pdoc__ = {
|
|||||||
def _get_confirmation(self, user_input):
|
def _get_confirmation(self, user_input):
|
||||||
#Send the request to identify if user is confirming or denying the task
|
#Send the request to identify if user is confirming or denying the task
|
||||||
message = []
|
message = []
|
||||||
message.append({"role": "system", "content": dedent(self.__prompt["confirmation_system"])})
|
message.append({"role": "system", "content": dedent(self.__prompt["confirmation_system"]).strip()})
|
||||||
message.append({"role": "user", "content": dedent(self.__prompt["confirmation_user"])})
|
message.append({"role": "user", "content": dedent(self.__prompt["confirmation_user"]).strip()})
|
||||||
message.append({"role": "assistant", "content": dedent(self.__prompt["confirmation_assistant"])})
|
message.append({"role": "assistant", "content": dedent(self.__prompt["confirmation_assistant"]).strip()})
|
||||||
message.append({"role": "user", "content": user_input})
|
message.append({"role": "user", "content": user_input})
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model=self.model,
|
model=self.model,
|
||||||
@ -971,7 +978,7 @@ __pdoc__ = {
|
|||||||
output["args"] = {}
|
output["args"] = {}
|
||||||
output["args"]["commands"] = commands["response"]["commands"]
|
output["args"]["commands"] = commands["response"]["commands"]
|
||||||
output["args"]["vars"] = commands["response"]["variables"]
|
output["args"]["vars"] = commands["response"]["variables"]
|
||||||
if original["response"]["expected"]:
|
if original["response"].get("expected"):
|
||||||
output["args"]["expected"] = original["response"]["expected"]
|
output["args"]["expected"] = original["response"]["expected"]
|
||||||
output["action"] = "test"
|
output["action"] = "test"
|
||||||
else:
|
else:
|
||||||
@ -1135,7 +1142,7 @@ __pdoc__ = {
|
|||||||
output["args"] = {}
|
output["args"] = {}
|
||||||
output["args"]["commands"] = commands["response"]["commands"]
|
output["args"]["commands"] = commands["response"]["commands"]
|
||||||
output["args"]["vars"] = commands["response"]["variables"]
|
output["args"]["vars"] = commands["response"]["variables"]
|
||||||
if original["response"]["expected"]:
|
if original["response"].get("expected"):
|
||||||
output["args"]["expected"] = original["response"]["expected"]
|
output["args"]["expected"] = original["response"]["expected"]
|
||||||
output["action"] = "test"
|
output["action"] = "test"
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user