agilecoder
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: agilecoder | ||
| Version: 0.1.6.1 | ||
| Version: 0.1.9 | ||
| Summary: AgileCoder | ||
@@ -11,10 +11,10 @@ Home-page: https://github.com/FSoft-AI4Code/AgileCoder | ||
| Requires-Dist: openai==0.28.1 | ||
| Requires-Dist: tiktoken | ||
| Requires-Dist: markdown | ||
| Requires-Dist: tiktoken==0.6.0 | ||
| Requires-Dist: markdown==3.5.2 | ||
| Requires-Dist: colorama | ||
| Requires-Dist: nltk | ||
| Requires-Dist: nltk==3.8.1 | ||
| Requires-Dist: flask | ||
| Requires-Dist: tenacity | ||
| Requires-Dist: tenacity==8.2.3 | ||
| Requires-Dist: python-dotenv | ||
| Requires-Dist: codebleu | ||
| Requires-Dist: codebleu==0.7.0 | ||
| Requires-Dist: google-auth | ||
@@ -24,1 +24,4 @@ Requires-Dist: google-auth-oauthlib | ||
| Requires-Dist: anthropic | ||
| Requires-Dist: pygame | ||
| Requires-Dist: numpy | ||
| Requires-Dist: tree-sitter |
| openai==0.28.1 | ||
| tiktoken | ||
| markdown | ||
| tiktoken==0.6.0 | ||
| markdown==3.5.2 | ||
| colorama | ||
| nltk | ||
| nltk==3.8.1 | ||
| flask | ||
| tenacity | ||
| tenacity==8.2.3 | ||
| python-dotenv | ||
| codebleu | ||
| codebleu==0.7.0 | ||
| google-auth | ||
@@ -14,1 +14,4 @@ google-auth-oauthlib | ||
| anthropic | ||
| pygame | ||
| numpy | ||
| tree-sitter |
@@ -6,4 +6,7 @@ import ast | ||
| """Extract import statements from a Python source file.""" | ||
| with open(filename, 'r') as file: | ||
| tree = ast.parse(file.read(), filename=filename) | ||
| try: | ||
| with open(filename, 'r') as file: | ||
| tree = ast.parse(file.read(), filename=filename) | ||
| except: | ||
| return [] | ||
@@ -10,0 +13,0 @@ imports = [] |
@@ -143,3 +143,3 @@ # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== | ||
| API_KEY = os.environ['API_KEY'] | ||
| print('RESOURCE_ENDPOINT', RESOURCE_ENDPOINT) | ||
| # print('RESOURCE_ENDPOINT', RESOURCE_ENDPOINT) | ||
| openai.api_key = API_KEY | ||
@@ -172,3 +172,3 @@ openai.api_type = API_TYPE | ||
| kwargs['engine'] = os.environ['API_ENGINE'] | ||
| print('API_ENGINE', os.environ['API_ENGINE']) | ||
| # print('API_ENGINE', os.environ['API_ENGINE']) | ||
| else: | ||
@@ -175,0 +175,0 @@ kwargs['model'] = self.model_type.value |
@@ -143,13 +143,14 @@ # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== | ||
| def wrapper(self, *args, **kwargs): | ||
| from agilecoder.camel.agents.chat_agent import ChatAgent | ||
| if not isinstance(self, ChatAgent): | ||
| raise ValueError("Expected ChatAgent") | ||
| if self.model == ModelType.STUB: | ||
| return func(self, *args, **kwargs) | ||
| elif 'OPENAI_API_KEY' in os.environ or 'API_KEY' in os.environ: | ||
| return func(self, *args, **kwargs) | ||
| elif 'CLAUDE' in os.environ: | ||
| return func(self, *args, **kwargs) | ||
| else: | ||
| raise ValueError('OpenAI API key not found.') | ||
| return func(self, *args, **kwargs) | ||
| # from agilecoder.camel.agents.chat_agent import ChatAgent | ||
| # if not isinstance(self, ChatAgent): | ||
| # raise ValueError("Expected ChatAgent") | ||
| # if self.model == ModelType.STUB: | ||
| # return func(self, *args, **kwargs) | ||
| # elif 'OPENAI_API_KEY' in os.environ or 'API_KEY' in os.environ: | ||
| # return func(self, *args, **kwargs) | ||
| # elif 'CLAUDE' in os.environ: | ||
| # return func(self, *args, **kwargs) | ||
| # else: | ||
| # raise ValueError('OpenAI API key not found.') | ||
@@ -156,0 +157,0 @@ return wrapper |
@@ -5,2 +5,7 @@ import argparse | ||
| def main(): | ||
| try: | ||
| import tree_sitter_python | ||
| except Exception as e: | ||
| print('Please run the following command to fix this error: pip install git+https://github.com/tree-sitter/tree-sitter-python.git@master') | ||
| raise e | ||
| parser = argparse.ArgumentParser(description='argparse') | ||
@@ -7,0 +12,0 @@ parser.add_argument('--config', type=str, default="Agile", |
@@ -499,2 +499,14 @@ { | ||
| ] | ||
| }, | ||
| { | ||
| "phase": "EnvironmentDoc", | ||
| "phaseType": "SimplePhase", | ||
| "max_turn_step": 1, | ||
| "need_reflect": "True" | ||
| }, | ||
| { | ||
| "phase": "Manual", | ||
| "phaseType": "SimplePhase", | ||
| "max_turn_step": 1, | ||
| "need_reflect": "False" | ||
| } | ||
@@ -501,0 +513,0 @@ ], |
@@ -96,3 +96,3 @@ import importlib | ||
| user_role_name = self.config_phase[phase]['user_role_name'] | ||
| phase_prompt = "\n\n".join(self.config_phase[phase]['phase_prompt']) | ||
| phase_prompt = "\n".join(self.config_phase[phase]['phase_prompt']) | ||
| phase_class = getattr(self.phase_module, phase) | ||
@@ -99,0 +99,0 @@ phase_instance = phase_class(assistant_role_name=assistant_role_name, |
@@ -44,8 +44,13 @@ import os | ||
| # Check for standalone code (no functions or classes) | ||
| all_flags = [] | ||
| for node in ast.iter_child_nodes(tree): | ||
| if not isinstance(node, (ast.Expr, ast.Import, ast.ImportFrom, ast.Module, ast.FunctionDef, ast.ClassDef)): | ||
| if isinstance(node, ast.Call): | ||
| return True | ||
| elif not isinstance(node, (ast.Assign, ast.AugAssign, ast.Import, ast.ImportFrom, ast.Module, ast.FunctionDef, ast.ClassDef)): | ||
| all_flags.append(has_entry_point(node)) | ||
| if len(all_flags): return any(all_flags) | ||
| return False | ||
| except SyntaxError: | ||
@@ -107,4 +112,4 @@ return False | ||
| module = match.group(1) | ||
| subprocess.Popen("pip3 install {}".format(module), shell=True).wait() | ||
| log_and_print_online("**[CMD Execute]**\n\n[CMD] pip3 install {}".format(module)) | ||
| subprocess.Popen("pip install {}".format(module), shell=True).wait() | ||
| log_and_print_online("**[CMD Execute]**\n\n[CMD] pip install {}".format(module)) | ||
| return module | ||
@@ -159,3 +164,3 @@ | ||
| runnable_files.append(file) | ||
| if not (('test_' in file) or ('_test' in file)): | ||
| if not (('test' in file) or ('test' in file)): | ||
| program_files.append(file) | ||
@@ -166,3 +171,3 @@ return_flag = False | ||
| testing_commands = self.env_dict['commands'] | ||
| _testing_commands = list(filter(lambda x: x.startswith('test_') or x.split('.')[0].endswith('_test'), get_test_order(chat_env.dependency_graph, chat_env.testing_file_map))) | ||
| _testing_commands = list(filter(lambda x: x.startswith('test') or x.split('.')[0].endswith('test'), get_test_order(chat_env.dependency_graph, chat_env.testing_file_map))) | ||
| additional_commands = list(set(testing_commands) - set(_testing_commands)) | ||
@@ -172,2 +177,4 @@ # print('additional_commands', additional_commands) | ||
| testing_commands = _testing_commands + additional_commands + program_files | ||
| if len(program_files) == 0: | ||
| testing_commands.append('no_entry_point') | ||
| # testing_commands = _testing_commands + additional_commands | ||
@@ -190,5 +197,6 @@ # for file in program_files: | ||
| current_idx = 0 | ||
| no_entry_point_error = False | ||
| for testing_command in testing_commands: | ||
| if testing_command != '-m unittest' and testing_command not in runnable_files: | ||
| if testing_command.startswith('test_') or testing_command.split('.')[0].endswith('_test'): | ||
| if testing_command == 'no_entry_point' or testing_command not in runnable_files: | ||
| if testing_command.startswith('test') or testing_command.split('.')[0].endswith('test'): | ||
| errs = "[Error] the testing script lacks an entry point to start. Please modify accordingly to run test cases." | ||
@@ -198,8 +206,16 @@ | ||
| return_flag = True | ||
| no_entry_point_error = True | ||
| break | ||
| else: | ||
| elif testing_command != 'no_entry_point': | ||
| errs = "[Error] the software lacks an entry point to start. Please modify accordingly to make the program executable." | ||
| error_contents += """\nError Traceback for Running File "{testing_command}":\n{errs}""".format(testing_command = testing_command, errs = errs) | ||
| return_flag = True | ||
| no_entry_point_error = True | ||
| break | ||
| else: | ||
| errs = "[Error] the software lacks an entry point to start. Please modify accordingly to make the program executable." | ||
| error_contents += """There is a serious bug:\n{errs}""".format(testing_command = testing_command, errs = errs) | ||
| return_flag = True | ||
| no_entry_point_error = True | ||
| break | ||
| if 'main.py' in self.codes.codebooks and testing_command == 'main.py': | ||
@@ -254,3 +270,6 @@ command = "cd {}; ls -l; python main.py;".format(directory) | ||
| if len(new_errs): | ||
| errs = new_errs | ||
| if len(new_errs.splitlines()) < 50: | ||
| errs = new_errs | ||
| else: | ||
| errs = extract_first_error_traceback(errs, 1) | ||
@@ -260,3 +279,3 @@ # return True, errs | ||
| return_flag = True | ||
| elif testing_command.startswith('test_') or testing_command.split('.')[0].endswith('_test'): | ||
| elif testing_command.startswith('test') or testing_command.split('.')[0].endswith('test'): | ||
| if 'FAILED' in std_output and '**************' not in std_output: | ||
@@ -281,2 +300,5 @@ std_output = extract_top_k_errors(std_output, k = 1) | ||
| return return_flag, error_contents | ||
| if no_entry_point_error: | ||
| current_idx += 1 | ||
| chat_env.env_dict['testing_commands'] = testing_commands[current_idx:] | ||
| if return_flag: | ||
@@ -321,3 +343,3 @@ return return_flag, error_contents | ||
| runnable_files.append(file) | ||
| if not (('test_' in file) or ('_test' in file)): | ||
| if not (('test' in file) or ('test' in file)): | ||
| program_files.append(file) | ||
@@ -327,3 +349,3 @@ return_flag = False | ||
| testing_commands = self.env_dict['commands'] | ||
| _testing_commands = list(filter(lambda x: x.startswith('test_') or x.split('.')[0].endswith('_test'), get_test_order(chat_env.dependency_graph, chat_env.testing_file_map))) | ||
| _testing_commands = list(filter(lambda x: x.startswith('test') or x.split('.')[0].endswith('test'), get_test_order(chat_env.dependency_graph, chat_env.testing_file_map))) | ||
| additional_commands = list(set(testing_commands) - set(_testing_commands)) | ||
@@ -335,2 +357,4 @@ # print('additional_commands', additional_commands) | ||
| if len(program_files) == 0: | ||
| return True, "[Error] There is a serious bug since the software lacks an entry point to start. Please modify accordingly to make the program executable." | ||
@@ -391,5 +415,8 @@ for testing_command in testing_commands: | ||
| if errs.count('--------------------------') > 1: | ||
| new_errs = extract_first_error_traceback(errs, 1) | ||
| new_errs = extract_first_error_traceback(errs) | ||
| if len(new_errs): | ||
| errs = new_errs | ||
| if len(new_errs.splitlines()) < 50: | ||
| errs = new_errs | ||
| else: | ||
| errs = extract_first_error_traceback(errs, 1) | ||
@@ -399,3 +426,3 @@ # return True, errs | ||
| return_flag = True | ||
| elif testing_command.startswith('test_') or testing_command.split('.')[0].endswith('_test'): | ||
| elif testing_command.startswith('test') or testing_command.split('.')[0].endswith('test'): | ||
| if 'FAILED' in std_output and '**************' not in std_output: | ||
@@ -402,0 +429,0 @@ std_output = extract_top_k_errors(std_output, k = 1) |
@@ -83,8 +83,13 @@ import os | ||
| # Check for standalone code (no functions or classes) | ||
| all_flags = [] | ||
| for node in ast.iter_child_nodes(tree): | ||
| if not isinstance(node, (ast.Expr, ast.Import, ast.ImportFrom, ast.Module, ast.FunctionDef, ast.ClassDef)): | ||
| if isinstance(node, ast.Call): | ||
| return True | ||
| elif not isinstance(node, (ast.Assign, ast.AugAssign, ast.Import, ast.ImportFrom, ast.Module, ast.FunctionDef, ast.ClassDef)): | ||
| all_flags.append(has_entry_point(node)) | ||
| if len(all_flags): return any(all_flags) | ||
| return False | ||
| except SyntaxError: | ||
@@ -297,2 +302,3 @@ return False | ||
| for key in new_codes.codebooks.keys(): | ||
| if is_testing and key == file_name: continue | ||
| if file_name is not None and not check_the_same_file(key, file_name): continue | ||
@@ -340,3 +346,3 @@ | ||
| log_and_print_online(update_codes_content) | ||
| log_and_print_online('FILE==' + str(corres_key) + '--OLD==' + key) | ||
| self.codebooks[corres_key or key] = new_codes.codebooks[key] | ||
@@ -346,2 +352,3 @@ changed_files.append(corres_key or key) | ||
| flag = True | ||
| log_and_print_online('AFTERCODE==:' + str(self.codebooks.keys())) | ||
| self.total_changed_lines = total_changed_lines | ||
@@ -367,4 +374,10 @@ self.changed_files = changed_files | ||
| for filename in self.codebooks.keys(): | ||
| filepath = os.path.join(directory, os.path.basename(filename)) | ||
| if self.codebooks[filename].endswith('.py') and 'flask' in self.codebooks[filename]: | ||
| os.makedirs(os.path.join(directory, 'templates'), exist_ok = True) | ||
| if filename.endswith('.html'): | ||
| filepath = os.path.join(directory, 'templates', os.path.basename(filename)) | ||
| else: | ||
| filepath = os.path.join(directory, os.path.basename(filename)) | ||
| with open(filepath, "w", encoding="utf-8") as writer: | ||
@@ -388,3 +401,3 @@ writer.write(self.codebooks[filename]) | ||
| if has_entry_point(self.codebooks[filename]): | ||
| if ignore_test_code and (filename.startswith('test_') or filename.split('.')[0].endswith('_test')): continue | ||
| if ignore_test_code and (filename.startswith('test') or filename.split('.')[0].endswith('test')): continue | ||
| code = self.codebooks[filename] | ||
@@ -397,4 +410,4 @@ if _simplify_code: | ||
| continue | ||
| if only_test_code and not (filename.startswith('test_') or filename.split('.')[0].endswith('_test')): continue | ||
| elif ignore_test_code and (filename.startswith('test_') or filename.split('.')[0].endswith('_test')): continue | ||
| if only_test_code and not (filename.startswith('test') or filename.split('.')[0].endswith('test')): continue | ||
| elif ignore_test_code and (filename.startswith('test') or filename.split('.')[0].endswith('test')): continue | ||
| code = self.codebooks[filename] | ||
@@ -401,0 +414,0 @@ if _simplify_code: |
@@ -538,3 +538,3 @@ import importlib | ||
| for file_name in all_changed_files: | ||
| if file_name.startswith('test_') or file_name.split('.')[0].endswith('_test'): continue | ||
| if file_name.startswith('test') or file_name.split('.')[0].endswith('test'): continue | ||
| for phase_item in self.composition: | ||
@@ -541,0 +541,0 @@ if phase_item["phaseType"] == "SimplePhase": # right now we do not support nested composition |
@@ -145,3 +145,3 @@ import html | ||
| for node, deps in adj_list.items(): | ||
| if node.startswith('test_') or node.split('.')[0].endswith('_test'): continue | ||
| if node.startswith('test') or node.split('.')[0].endswith('test'): continue | ||
| all_deps.extend(deps) | ||
@@ -151,3 +151,3 @@ all_nodes = set() | ||
| all_nodes.update(v + [k]) | ||
| return [node for node in all_nodes if node not in all_deps and not (node.startswith('test_') or node.split('.')[0].endswith('_test'))] | ||
| return [node for node in all_nodes if node not in all_deps and not (node.startswith('test') or node.split('.')[0].endswith('test'))] | ||
@@ -154,0 +154,0 @@ def extract_first_error_traceback(traceback_output, num_returns = 3): |
+9
-6
| Metadata-Version: 2.1 | ||
| Name: agilecoder | ||
| Version: 0.1.6.1 | ||
| Version: 0.1.9 | ||
| Summary: AgileCoder | ||
@@ -11,10 +11,10 @@ Home-page: https://github.com/FSoft-AI4Code/AgileCoder | ||
| Requires-Dist: openai==0.28.1 | ||
| Requires-Dist: tiktoken | ||
| Requires-Dist: markdown | ||
| Requires-Dist: tiktoken==0.6.0 | ||
| Requires-Dist: markdown==3.5.2 | ||
| Requires-Dist: colorama | ||
| Requires-Dist: nltk | ||
| Requires-Dist: nltk==3.8.1 | ||
| Requires-Dist: flask | ||
| Requires-Dist: tenacity | ||
| Requires-Dist: tenacity==8.2.3 | ||
| Requires-Dist: python-dotenv | ||
| Requires-Dist: codebleu | ||
| Requires-Dist: codebleu==0.7.0 | ||
| Requires-Dist: google-auth | ||
@@ -24,1 +24,4 @@ Requires-Dist: google-auth-oauthlib | ||
| Requires-Dist: anthropic | ||
| Requires-Dist: pygame | ||
| Requires-Dist: numpy | ||
| Requires-Dist: tree-sitter |
+10
-7
| from setuptools import setup, find_packages | ||
| setup(name='agilecoder', | ||
| version='0.1.6.1', | ||
| version='0.1.9', | ||
| description='AgileCoder', | ||
@@ -17,16 +17,19 @@ url='https://github.com/FSoft-AI4Code/AgileCoder', | ||
| "openai==0.28.1", | ||
| "tiktoken", | ||
| "markdown", | ||
| "tiktoken==0.6.0", | ||
| "markdown==3.5.2", | ||
| "colorama", | ||
| "nltk", | ||
| "nltk==3.8.1", | ||
| "flask", | ||
| "tenacity", | ||
| "tenacity==8.2.3", | ||
| "python-dotenv", | ||
| "codebleu", | ||
| "codebleu==0.7.0", | ||
| "google-auth", | ||
| "google-auth-oauthlib", | ||
| "google-auth-httplib2", | ||
| "anthropic" | ||
| "anthropic", | ||
| "pygame", | ||
| "numpy", | ||
| "tree-sitter" | ||
| ], | ||
| packages=find_packages(), | ||
| zip_safe=False) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
546113
5.06%10395
4.78%