From 795ebfd97e651b96d82ed46b462097ea58ea6af0 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Thu, 10 Aug 2023 08:44:02 +0200 Subject: [PATCH] A couple of fixes --- euclid/helpers/agents/Developer.py | 8 ++++---- euclid/utils/llm_connection.py | 3 +++ euclid/utils/utils.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/euclid/helpers/agents/Developer.py b/euclid/helpers/agents/Developer.py index 529d3d6..07d9a85 100644 --- a/euclid/helpers/agents/Developer.py +++ b/euclid/helpers/agents/Developer.py @@ -33,8 +33,8 @@ class Developer(Agent): def implement_task(self, sibling_tasks, current_task_index, parent_task=None): print(colored('-------------------------', 'green', attrs=['bold'])) - print(colored(f"Implementing task {current_task_index + 1}...\n", "green")) - print(colored(sibling_tasks[current_task_index]['description'], 'green')) + print(colored(f"Implementing task {current_task_index + 1}...\n", "green", attrs=['bold'])) + print(colored(sibling_tasks[current_task_index]['description'], 'green', attrs=['bold'])) print(colored('-------------------------', 'green', attrs=['bold'])) convo_dev_task = AgentConvo(self) @@ -133,8 +133,8 @@ class Developer(Agent): }, 'send_convo': True }) - - if not llm_response == 'DONE': + + if llm_response != 'DONE': installation_commands = self.convo_os_specific_tech.send_message('development/env_setup/unsuccessful_installation.prompt', { 'technology': technology }, EXECUTE_COMMANDS) if installation_commands is not None: diff --git a/euclid/utils/llm_connection.py b/euclid/utils/llm_connection.py index 771f978..b106e56 100644 --- a/euclid/utils/llm_connection.py +++ b/euclid/utils/llm_connection.py @@ -153,6 +153,9 @@ def stream_gpt_completion(data, req_type): try: json_line = load_data_to_json(line) + if 'error' in json_line: + logger.error(f'Error in LLM response: {json_line}') + raise ValueError(f'Error in LLM response: {json_line["error"]["message"]}') if json_line['choices'][0]['finish_reason'] == 'function_call': function_calls['arguments'] = load_data_to_json(function_calls['arguments']) return return_result({'function_calls': function_calls}); diff --git a/euclid/utils/utils.py b/euclid/utils/utils.py index 170c10d..6fea50d 100644 --- a/euclid/utils/utils.py +++ b/euclid/utils/utils.py @@ -146,7 +146,7 @@ def replace_functions(obj): return obj def fix_json_newlines(s): - pattern = r'("(?:\\.|[^"\\])*")' + pattern = r'("(?:\\\\n|\\.|[^"\\])*")' def replace_newlines(match): return match.group(1).replace('\n', '\\n')