diff --git a/connpy/_version.py b/connpy/_version.py index 07abe38..0b3be50 100644 --- a/connpy/_version.py +++ b/connpy/_version.py @@ -1,2 +1,2 @@ -__version__ = "3.2.6" +__version__ = "3.2.7" diff --git a/connpy/ai.py b/connpy/ai.py index 11100c5..3df4df7 100755 --- a/connpy/ai.py +++ b/connpy/ai.py @@ -139,6 +139,16 @@ Users will typically use words like verify, check, make sure, or similar to refe self.model = model self.temp = temp + def process_string(self, s): + if s.startswith('[') and s.endswith(']') and not (s.startswith("['") and s.endswith("']")) and not (s.startswith('["') and s.endswith('"]')): + # Extract the content inside square brackets and split by comma + content = s[1:-1].split(',') + # Add single quotes around each item and join them back together with commas + new_content = ', '.join(f"'{item.strip()}'" for item in content) + # Replace the old content with the new content + s = '[' + new_content + ']' + return s + def _retry_function(self, function, max_retries, backoff_num, *args): #Retry openai requests retries = 0 @@ -176,6 +186,7 @@ Users will typically use words like verify, check, make sure, or similar to refe elif value.lower() == "none": value = None if key == "filter": + value = self.process_string(value) value = ast.literal_eval(value) #store in dictionary info_dict[key] = value @@ -229,10 +240,10 @@ Users will typically use words like verify, check, make sure, or similar to refe for key, value in nodes.items(): tags = value.get('tags', {}) try: - os_value = tags.get('os', '') + if os_value := tags.get('os'): + output_list.append(f"{key}: {os_value}") except: - os_value = "" - output_list.append(f"{key}: {os_value}") + pass output_str = "\n".join(output_list) command_input = f"input: {user_input}\n\nDevices:\n{output_str}" message = [] @@ -411,6 +422,7 @@ Users will typically use words like verify, check, make sure, or similar to refe output["args"] = {} output["args"]["commands"] = commands["response"]["commands"] output["args"]["vars"] = commands["response"]["variables"] + output["nodes"] = [item for item in output["nodes"] if output["args"]["vars"].get(item)] if original["response"].get("expected"): output["args"]["expected"] = original["response"]["expected"] output["action"] = "test" diff --git a/docs/connpy/index.html b/docs/connpy/index.html index 6d09519..381d7f5 100644 --- a/docs/connpy/index.html +++ b/docs/connpy/index.html @@ -706,6 +706,16 @@ Users will typically use words like verify, check, make sure, or similar to refe self.model = model self.temp = temp + def process_string(self, s): + if s.startswith('[') and s.endswith(']') and not (s.startswith("['") and s.endswith("']")) and not (s.startswith('["') and s.endswith('"]')): + # Extract the content inside square brackets and split by comma + content = s[1:-1].split(',') + # Add single quotes around each item and join them back together with commas + new_content = ', '.join(f"'{item.strip()}'" for item in content) + # Replace the old content with the new content + s = '[' + new_content + ']' + return s + def _retry_function(self, function, max_retries, backoff_num, *args): #Retry openai requests retries = 0 @@ -743,6 +753,7 @@ Users will typically use words like verify, check, make sure, or similar to refe elif value.lower() == "none": value = None if key == "filter": + value = self.process_string(value) value = ast.literal_eval(value) #store in dictionary info_dict[key] = value @@ -796,10 +807,10 @@ Users will typically use words like verify, check, make sure, or similar to refe for key, value in nodes.items(): tags = value.get('tags', {}) try: - os_value = tags.get('os', '') + if os_value := tags.get('os'): + output_list.append(f"{key}: {os_value}") except: - os_value = "" - output_list.append(f"{key}: {os_value}") + pass output_str = "\n".join(output_list) command_input = f"input: {user_input}\n\nDevices:\n{output_str}" message = [] @@ -978,6 +989,7 @@ Users will typically use words like verify, check, make sure, or similar to refe output["args"] = {} output["args"]["commands"] = commands["response"]["commands"] output["args"]["vars"] = commands["response"]["variables"] + output["nodes"] = [item for item in output["nodes"] if output["args"]["vars"].get(item)] if original["response"].get("expected"): output["args"]["expected"] = original["response"]["expected"] output["action"] = "test" @@ -1142,6 +1154,7 @@ Users will typically use words like verify, check, make sure, or similar to refe output["args"] = {} output["args"]["commands"] = commands["response"]["commands"] output["args"]["vars"] = commands["response"]["variables"] + output["nodes"] = [item for item in output["nodes"] if output["args"]["vars"].get(item)] if original["response"].get("expected"): output["args"]["expected"] = original["response"]["expected"] output["action"] = "test" @@ -1213,6 +1226,26 @@ Users will typically use words like verify, check, make sure, or similar to refe return output +
+def process_string(self, s)
+
def process_string(self, s):
+ if s.startswith('[') and s.endswith(']') and not (s.startswith("['") and s.endswith("']")) and not (s.startswith('["') and s.endswith('"]')):
+ # Extract the content inside square brackets and split by comma
+ content = s[1:-1].split(',')
+ # Add single quotes around each item and join them back together with commas
+ new_content = ', '.join(f"'{item.strip()}'" for item in content)
+ # Replace the old content with the new content
+ s = '[' + new_content + ']'
+ return s
+
@@ -4369,6 +4402,7 @@ tasks: