bug fixes
This commit is contained in:
parent
51f86f214a
commit
acbfb03b10
@ -1,2 +1,2 @@
|
|||||||
__version__ = "3.2.6"
|
__version__ = "3.2.7"
|
||||||
|
|
||||||
|
18
connpy/ai.py
18
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.model = model
|
||||||
self.temp = temp
|
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):
|
def _retry_function(self, function, max_retries, backoff_num, *args):
|
||||||
#Retry openai requests
|
#Retry openai requests
|
||||||
retries = 0
|
retries = 0
|
||||||
@ -176,6 +186,7 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
elif value.lower() == "none":
|
elif value.lower() == "none":
|
||||||
value = None
|
value = None
|
||||||
if key == "filter":
|
if key == "filter":
|
||||||
|
value = self.process_string(value)
|
||||||
value = ast.literal_eval(value)
|
value = ast.literal_eval(value)
|
||||||
#store in dictionary
|
#store in dictionary
|
||||||
info_dict[key] = value
|
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():
|
for key, value in nodes.items():
|
||||||
tags = value.get('tags', {})
|
tags = value.get('tags', {})
|
||||||
try:
|
try:
|
||||||
os_value = tags.get('os', '')
|
if os_value := tags.get('os'):
|
||||||
|
output_list.append(f"{key}: {os_value}")
|
||||||
except:
|
except:
|
||||||
os_value = ""
|
pass
|
||||||
output_list.append(f"{key}: {os_value}")
|
|
||||||
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 = []
|
||||||
@ -411,6 +422,7 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
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"]
|
||||||
|
output["nodes"] = [item for item in output["nodes"] if output["args"]["vars"].get(item)]
|
||||||
if original["response"].get("expected"):
|
if original["response"].get("expected"):
|
||||||
output["args"]["expected"] = original["response"]["expected"]
|
output["args"]["expected"] = original["response"]["expected"]
|
||||||
output["action"] = "test"
|
output["action"] = "test"
|
||||||
|
@ -706,6 +706,16 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
self.model = model
|
self.model = model
|
||||||
self.temp = temp
|
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):
|
def _retry_function(self, function, max_retries, backoff_num, *args):
|
||||||
#Retry openai requests
|
#Retry openai requests
|
||||||
retries = 0
|
retries = 0
|
||||||
@ -743,6 +753,7 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
elif value.lower() == "none":
|
elif value.lower() == "none":
|
||||||
value = None
|
value = None
|
||||||
if key == "filter":
|
if key == "filter":
|
||||||
|
value = self.process_string(value)
|
||||||
value = ast.literal_eval(value)
|
value = ast.literal_eval(value)
|
||||||
#store in dictionary
|
#store in dictionary
|
||||||
info_dict[key] = value
|
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():
|
for key, value in nodes.items():
|
||||||
tags = value.get('tags', {})
|
tags = value.get('tags', {})
|
||||||
try:
|
try:
|
||||||
os_value = tags.get('os', '')
|
if os_value := tags.get('os'):
|
||||||
|
output_list.append(f"{key}: {os_value}")
|
||||||
except:
|
except:
|
||||||
os_value = ""
|
pass
|
||||||
output_list.append(f"{key}: {os_value}")
|
|
||||||
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 = []
|
||||||
@ -978,6 +989,7 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
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"]
|
||||||
|
output["nodes"] = [item for item in output["nodes"] if output["args"]["vars"].get(item)]
|
||||||
if original["response"].get("expected"):
|
if original["response"].get("expected"):
|
||||||
output["args"]["expected"] = original["response"]["expected"]
|
output["args"]["expected"] = original["response"]["expected"]
|
||||||
output["action"] = "test"
|
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"] = {}
|
||||||
output["args"]["commands"] = commands["response"]["commands"]
|
output["args"]["commands"] = commands["response"]["commands"]
|
||||||
output["args"]["vars"] = commands["response"]["variables"]
|
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"):
|
if original["response"].get("expected"):
|
||||||
output["args"]["expected"] = original["response"]["expected"]
|
output["args"]["expected"] = original["response"]["expected"]
|
||||||
output["action"] = "test"
|
output["action"] = "test"
|
||||||
@ -1213,6 +1226,26 @@ Users will typically use words like verify, check, make sure, or similar to refe
|
|||||||
return output</code></pre>
|
return output</code></pre>
|
||||||
</details>
|
</details>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt id="connpy.ai.process_string"><code class="name flex">
|
||||||
|
<span>def <span class="ident">process_string</span></span>(<span>self, s)</span>
|
||||||
|
</code></dt>
|
||||||
|
<dd>
|
||||||
|
<div class="desc"></div>
|
||||||
|
<details class="source">
|
||||||
|
<summary>
|
||||||
|
<span>Expand source code</span>
|
||||||
|
</summary>
|
||||||
|
<pre><code class="python">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</code></pre>
|
||||||
|
</details>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="connpy.configfile"><code class="flex name class">
|
<dt id="connpy.configfile"><code class="flex name class">
|
||||||
@ -4369,6 +4402,7 @@ tasks:
|
|||||||
<ul class="">
|
<ul class="">
|
||||||
<li><code><a title="connpy.ai.ask" href="#connpy.ai.ask">ask</a></code></li>
|
<li><code><a title="connpy.ai.ask" href="#connpy.ai.ask">ask</a></code></li>
|
||||||
<li><code><a title="connpy.ai.confirm" href="#connpy.ai.confirm">confirm</a></code></li>
|
<li><code><a title="connpy.ai.confirm" href="#connpy.ai.confirm">confirm</a></code></li>
|
||||||
|
<li><code><a title="connpy.ai.process_string" href="#connpy.ai.process_string">process_string</a></code></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
Loading…
Reference in New Issue
Block a user