Agent Zero AI framework
windows timed input fix
frdeld2374bfe699a
diff --git a/main.py b/main.pyindex a57269806..68ffe9df2 100644--- a/main.py+++ b/main.py@@ -1,4 +1,3 @@-import signalimport threading, time, models, osfrom ansio import application_keypad, mouse_input, raw_inputfrom ansio.input import InputEvent, get_input_event@@ -13,7 +12,9 @@ os.chdir(files.get_abs_path("./work_dir")) #change CWD to work_dirdef initialize():- # chat model used by agents++ # main chat model used by agents (smarter, more accurate)+# chat_llm = models.get_groq_llama70b(temperature=0.2)# chat_llm = models.get_groq_llama70b_json(temperature=0.2)# chat_llm = models.get_groq_llama8b(temperature=0.2)@@ -30,12 +31,13 @@ def initialize():# chat_llm = models.get_ollama(model_name="qwen:14b")chat_llm = models.get_google_chat()- utility_llm = models.get_anthropic_haiku(temperature=0)+ # utility model used for helper functions (cheaper, faster)+ utility_llm = models.get_anthropic_haiku(temperature=0)# embedding model used for memory- # embedding_llm = models.get_embedding_openai()- embedding_llm = models.get_embedding_hf()+ embedding_llm = models.get_embedding_openai()+ # embedding_llm = models.get_embedding_hf()# agent configurationconfig = AgentConfig(@@ -149,18 +151,19 @@ def capture_keys():# User input with timeoutdef timeout_input(prompt, timeout=10):- def alarm_handler(signum, frame):- raise TimeoutError()+ result = []++ def get_input():+ result[0] = input(prompt)- signal.signal(signal.SIGALRM, alarm_handler)- signal.alarm(timeout)+ input_thread = threading.Thread(target=get_input)+ input_thread.start()+ input_thread.join(timeout)- try:- return input(prompt)- except TimeoutError:+ if input_thread.is_alive():return ""- finally:- signal.alarm(0) # Cancel the alarm+ else:+ return result[0]if __name__ == "__main__":print("Initializing framework...")