Agent Zero AI framework
perplexity model, shell decode
frdela3ad9655454d
diff --git a/python/helpers/perplexity_search.py b/python/helpers/perplexity_search.pyindex 1bdb309f4..ee5c4aaf3 100644--- a/python/helpers/perplexity_search.py+++ b/python/helpers/perplexity_search.py@@ -94,7 +94,7 @@ def PerplexitySearchLLM(api_key,model_name="sonar-medium-online",base_url="httpsreturn call_model-call_llm = PerplexitySearchLLM(api_key=api_key_from_env,model_name="sonar-medium-online")+call_llm = PerplexitySearchLLM(api_key=api_key_from_env,model_name="llama-3-sonar-large-32k-online")def perplexity_search(search_query: str):return call_llm(search_query)\ No newline at end of filediff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.pyindex b980b7df9..3879cba9e 100644--- a/python/helpers/shell_ssh.py+++ b/python/helpers/shell_ssh.py@@ -17,7 +17,7 @@ class SSHInteractiveSession:self.client = paramiko.SSHClient()self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())self.shell = None- self.full_output = ''+ self.full_output = b''def connect(self):# try 3 times with wait and then except@@ -49,29 +49,34 @@ class SSHInteractiveSession:def send_command(self, command: str):if not self.shell:raise Exception("Shell not connected")- self.full_output = ""+ self.full_output = b""self.shell.send((command + " \\\n" +SSHInteractiveSession.end_comment + "\n").encode())def read_output(self) -> Tuple[str, str]:if not self.shell:raise Exception("Shell not connected")- partial_output = ''+ partial_output = b''while self.shell.recv_ready():- data = self.shell.recv(1024).decode('utf-8')- data = self.clean_string(data)+ data = self.shell.recv(1024)partial_output += dataself.full_output += datatime.sleep(0.1) # Prevent busy waiting- self.full_output = self.clean_string(self.full_output)+ # Decode once at the end+ decoded_partial_output = partial_output.decode('utf-8', errors='replace')+ decoded_full_output = self.full_output.decode('utf-8', errors='replace')++ decoded_partial_output = self.clean_string(decoded_partial_output)+ decoded_full_output = self.clean_string(decoded_full_output)- # split output at end_comment- if SSHInteractiveSession.end_comment in self.full_output:- self.full_output = self.full_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")- partial_output = partial_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")+ # Split output at end_comment+ if SSHInteractiveSession.end_comment in decoded_full_output:+ decoded_full_output = decoded_full_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")+ decoded_partial_output = decoded_partial_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")- return self.full_output, partial_output+ return decoded_full_output, decoded_partial_output+def clean_string(self, input_string):# Remove ANSI escape codes