├── Baselines ├── c.log ├── codeBERT.py └── codeT5.py ├── CompanyConfig └── Default │ ├── ChatChainConfig.json │ ├── PhaseConfig.json │ └── RoleConfig.json ├── Diff-CodeAgent4.0 ├── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-commit.txt ├── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-context.txt └── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-message.txt ├── Example ├── c# │ ├── 0e231c7a81b318e9eade972f7b877e66128ed67d-commit.txt │ ├── 0e231c7a81b318e9eade972f7b877e66128ed67d-context.txt │ ├── 0e231c7a81b318e9eade972f7b877e66128ed67d-message.txt │ └── c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d.prompt │ │ ├── c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440.log │ │ ├── manual.md │ │ ├── meta.txt │ │ └── planner.executeasync ├── c++ │ ├── 09e88c7c20347cdf513323fa8c616aba0a1b9ea7-commit.txt │ ├── 09e88c7c20347cdf513323fa8c616aba0a1b9ea7-context.txt │ └── 09e88c7c20347cdf513323fa8c616aba0a1b9ea7-message.txt ├── c │ ├── 5f93cf43dd6f809d7927abb79884285ad77e8a58-commit.txt │ ├── 5f93cf43dd6f809d7927abb79884285ad77e8a58-context.txt │ ├── 5f93cf43dd6f809d7927abb79884285ad77e8a58-message.txt │ └── c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58.prompt │ │ ├── c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751.log │ │ ├── manual.md │ │ ├── meta.txt │ │ └── requirements.txt ├── java │ ├── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-commit.txt │ ├── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-context.txt │ ├── 6e3c6d17d943f5ac70b421653eb167e0c34b119f-message.txt │ ├── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f.prompt │ │ ├── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316.log │ │ ├── manual.md │ │ ├── meta.txt │ │ ├── requirements.txt │ │ └── snackbar.this │ └── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── commit.py │ │ ├── i.e │ │ ├── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f.prompt │ │ ├── java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718.log │ │ ├── manual.md │ │ ├── meta.txt │ │ ├── requirements.txt │ │ └── snackbar.this ├── javascript │ ├── 6e9a80d93b470aef4978677ed0b7c9996fddbe20-commit.txt │ ├── 6e9a80d93b470aef4978677ed0b7c9996fddbe20-context.txt │ ├── 6e9a80d93b470aef4978677ed0b7c9996fddbe20-message.txt │ └── javascript__closed__6e9a80d93b470aef4978677ed0b7c9996fddbe20__20240124080405 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── javascript__closed__6e9a80d93b470aef4978677ed0b7c9996fddbe20.prompt │ │ ├── javascript__closed__6e9a80d93b470aef4978677ed0b7c9996fddbe20__20240124080405.log │ │ ├── manual.md │ │ ├── meta.txt │ │ └── requirements.txt ├── php │ ├── 6679f059b9a0972a90df198471188da652f5c547-commit.txt │ ├── 6679f059b9a0972a90df198471188da652f5c547-context.txt │ ├── 6679f059b9a0972a90df198471188da652f5c547-message.txt │ └── php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── get_posts.py │ │ ├── manual.md │ │ ├── meta.txt │ │ ├── php__closed__6679f059b9a0972a90df198471188da652f5c547.prompt │ │ ├── php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337.log │ │ └── requirements.txt ├── ruby │ ├── 584f72e7f4c65066ccbd2183af76bf380b6eb974-commit.txt │ ├── 584f72e7f4c65066ccbd2183af76bf380b6eb974-context.txt │ ├── 584f72e7f4c65066ccbd2183af76bf380b6eb974-message.txt │ └── ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950 │ │ ├── 6.0 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── manual.md │ │ ├── meta.txt │ │ ├── requirements.txt │ │ ├── ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974.prompt │ │ └── ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950.log ├── video-example-1 │ ├── 42f249941b687a73c020c11779a511a90cbedb28-commit.txt │ ├── 42f249941b687a73c020c11779a511a90cbedb28-context.txt │ ├── 42f249941b687a73c020c11779a511a90cbedb28-message.txt │ └── java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017 │ │ ├── 21.1 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── java__merged__42f249941b687a73c020c11779a511a90cbedb28.prompt │ │ ├── java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017.log │ │ ├── manual.md │ │ └── meta.txt ├── video-example-2 │ └── ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951 │ │ ├── ChatChainConfig.json │ │ ├── PhaseConfig.json │ │ ├── RoleConfig.json │ │ ├── manual.md │ │ ├── meta.txt │ │ ├── ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c.prompt │ │ ├── ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951.log │ │ └── where.not └── video-exmple-3-security │ └── javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af__20240124011600 │ ├── ChatChainConfig.json │ ├── PhaseConfig.json │ ├── RoleConfig.json │ ├── client.py │ ├── javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af.prompt │ ├── javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af__20240124011600.log │ ├── manual.md │ ├── meta.txt │ └── requirements.txt ├── Logs └── main_logs │ ├── output-c#.log │ ├── output-c++.log │ ├── output-c.log │ ├── output-go.log │ ├── output-java.log │ ├── output-javascript.log │ ├── output-php.log │ ├── output-python.log │ └── output-ruby.log ├── PR ├── README.md └── requirements.txt ├── README.md ├── camel ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── __init__.cpython-39.pyc │ ├── configs.cpython-37.pyc │ ├── configs.cpython-39.pyc │ ├── generators.cpython-39.pyc │ ├── model_backend.cpython-37.pyc │ ├── model_backend.cpython-39.pyc │ ├── typing.cpython-37.pyc │ ├── typing.cpython-39.pyc │ └── utils.cpython-39.pyc ├── agents │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── base.cpython-37.pyc │ │ ├── base.cpython-39.pyc │ │ ├── chat_agent.cpython-37.pyc │ │ ├── chat_agent.cpython-39.pyc │ │ ├── critic_agent.cpython-39.pyc │ │ ├── embodied_agent.cpython-39.pyc │ │ ├── role_playing.cpython-39.pyc │ │ └── task_agent.cpython-39.pyc │ ├── base.py │ ├── chat_agent.py │ ├── critic_agent.py │ ├── embodied_agent.py │ ├── role_playing.py │ ├── task_agent.py │ └── tool_agents │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── base.cpython-39.pyc │ │ └── hugging_face_tool_agent.cpython-39.pyc │ │ ├── base.py │ │ └── hugging_face_tool_agent.py ├── configs.py ├── generators.py ├── human.py ├── messages │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── base.cpython-37.pyc │ │ ├── base.cpython-39.pyc │ │ ├── chat_messages.cpython-37.pyc │ │ ├── chat_messages.cpython-39.pyc │ │ ├── system_messages.cpython-37.pyc │ │ └── system_messages.cpython-39.pyc │ ├── base.py │ ├── chat_messages.py │ └── system_messages.py ├── model_backend.py ├── prompts │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── base.cpython-37.pyc │ │ ├── base.cpython-39.pyc │ │ ├── prompt_templates.cpython-37.pyc │ │ ├── prompt_templates.cpython-39.pyc │ │ ├── task_prompt_template.cpython-37.pyc │ │ └── task_prompt_template.cpython-39.pyc │ ├── base.py │ ├── prompt_templates.py │ └── task_prompt_template.py ├── typing.py └── utils.py └── online_log ├── __pycache__ └── app.cpython-39.pyc ├── app.py └── static ├── avatars ├── Chief Creative Officer.png ├── Chief Executive Officer.png ├── Chief Human Resource Officer.png ├── Chief Product Officer.png ├── Chief Technology Officer.png ├── Code Reviewer.png ├── Counselor.png ├── Programmer.png ├── Prompt Engineer.png ├── Software Test Engineer.png ├── System.png └── User.png ├── css └── style.css ├── figures ├── background.png ├── ceo.png ├── chatdev.png ├── company.png ├── counselor.png ├── cpo.png ├── cto.png ├── designer.png ├── game.jpg ├── hr.png ├── left.png ├── pe.png ├── programmer.png ├── reviewer.png ├── right.png ├── tester.png ├── title.png └── user.png ├── index.html ├── js └── main.js ├── replay.html └── replay ├── css ├── github-markdown-dark.css └── use.css └── js ├── app.js └── highlight.js /Baselines/codeBERT.py: -------------------------------------------------------------------------------- 1 | import os 2 | from transformers import RobertaTokenizer, RobertaForSequenceClassification 3 | import torch 4 | 5 | # 加载 CodeBERT 模型和分词器 6 | model_name = "microsoft/codebert-base" 7 | tokenizer = RobertaTokenizer.from_pretrained(model_name) 8 | model = RobertaForSequenceClassification.from_pretrained(model_name, num_labels=1) # 用于二元分类 9 | model.eval() 10 | 11 | def classify_text(text): 12 | categories = ["vulnerable", "safe"] 13 | max_similarity = -1 14 | best_category = None 15 | for category in categories: 16 | input_text = f"文本:{text} [SEP] 类别:{category}" 17 | inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True) 18 | with torch.no_grad(): 19 | outputs = model(**inputs) 20 | logits = outputs.logits 21 | similarity = torch.sigmoid(logits) # 估计相似度 22 | if similarity > max_similarity: 23 | max_similarity = similarity 24 | best_category = category 25 | return best_category 26 | 27 | def extract_content(file_path): 28 | with open(file_path, 'r', encoding='utf-8') as file: 29 | content = file.read() 30 | start_keyword = "Security Analysis:" 31 | end_keyword = "Format Analysis:" 32 | start_index = content.find(start_keyword) 33 | end_index = content.find(end_keyword) 34 | if start_index != -1 and end_index != -1: 35 | return content[start_index+len(start_keyword):end_index].strip() 36 | return "" 37 | 38 | def main(directory): 39 | vulnerable_folders = [] 40 | for folder in os.listdir(directory): 41 | if folder.startswith('') and os.path.isdir(os.path.join(directory, folder)): 42 | file_path = os.path.join(directory, folder, 'manual.md') 43 | if os.path.exists(file_path): 44 | content = extract_content(file_path) 45 | if content and classify_text(content) == "vulnerable": 46 | vulnerable_folders.append(folder) 47 | 48 | print("Folders classified as vulnerable:") 49 | for folder in vulnerable_folders: 50 | address = directory+f'/{folder}' 51 | print(address) 52 | 53 | # 设定目录路径 54 | directory_path = "../WareHouse" 55 | main(directory_path) 56 | -------------------------------------------------------------------------------- /Baselines/codeT5.py: -------------------------------------------------------------------------------- 1 | from transformers import RobertaTokenizer, AutoModelForSeq2SeqLM 2 | 3 | # 加载预训练的 CodeT5 模型和分词器 4 | model_name = "Salesforce/codeT5-base" 5 | tokenizer = RobertaTokenizer.from_pretrained(model_name) 6 | model = AutoModelForSeq2SeqLM.from_pretrained(model_name) 7 | 8 | def zero_shot_classification(text, categories): 9 | # 构造输入 10 | input_text = f"这段文本是关于{'还是'.join(categories)}?文本:{text}" 11 | input_ids = tokenizer(input_text, return_tensors="pt").input_ids 12 | 13 | # 使用模型生成回答 14 | outputs = model.generate(input_ids, max_new_tokens=50) 15 | 16 | answer = tokenizer.decode(outputs[0], skip_special_tokens=True) 17 | 18 | return answer 19 | 20 | # 示例文本和分类 21 | text = "这是一个关于先进计算机技术的文章。" 22 | categories = ["科技", "文学"] 23 | predicted_category = zero_shot_classification(text, categories) 24 | print(predicted_category) 25 | -------------------------------------------------------------------------------- /CompanyConfig/Default/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /CompanyConfig/Default/RoleConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "Chief Executive Officer": [ 3 | "{codeagent_prompt}", 4 | "You are Chief Executive Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 5 | "Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.", 6 | "Here is a new customer's task: {task}.", 7 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 8 | ], 9 | "Chief Product Officer": [ 10 | "{codeagent_prompt}", 11 | "You are Chief Product Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 12 | "You are responsible for all product-related matters in CodeAgent. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.", 13 | "Here is a new customer's task: {task}.", 14 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 15 | ], 16 | "Counselor": [ 17 | "{codeagent_prompt}", 18 | "You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 19 | "Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ", 20 | "Here is a new customer's task: {task}.", 21 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 22 | ], 23 | "Chief Technology Officer": [ 24 | "{codeagent_prompt}", 25 | "You are Chief Technology Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 26 | "You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.", 27 | "Here is a new customer's task: {task}.", 28 | "To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 29 | ], 30 | "Chief Human Resource Officer": [ 31 | "{codeagent_prompt}", 32 | "You are Chief Human Resource Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 33 | "You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).", 34 | "Here is a new customer's task: {task}.", 35 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 36 | ], 37 | "Programmer": [ 38 | "{codeagent_prompt}", 39 | "You are Programmer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 40 | "You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.", 41 | "Here is a new customer's task: {task}.", 42 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 43 | ], 44 | "Code Reviewer": [ 45 | "{codeagent_prompt}", 46 | "You are Code Reviewer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 47 | "You can help programmers to assess source codes for software troubleshooting, do vulnerability analysis, do consistency between commit and commit message, do format analysis between commit and original file, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.", 48 | "Here is a new customer's task: {task}.", 49 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 50 | ], 51 | "Software Test Engineer": [ 52 | "{codeagent_prompt}", 53 | "You are Software Test Engineer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 54 | "You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.", 55 | "Here is a new customer's task: {task}.", 56 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 57 | ], 58 | "Chief Creative Officer": [ 59 | "{codeagent_prompt}", 60 | "You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 61 | "You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.", 62 | "Here is a new customer's task: {task}.", 63 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 64 | ] 65 | } -------------------------------------------------------------------------------- /Diff-CodeAgent4.0/6e3c6d17d943f5ac70b421653eb167e0c34b119f-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -403,7 +403,7 @@ public boolean canDismiss(Object token) { 2 | @Override 3 | public void onDismiss(View view, Object token) { 4 | if (view != null) { 5 | - finish(); 6 | + dismiss(false); 7 | } 8 | } 9 | 10 | @@ -512,6 +512,10 @@ private void startTimer(long duration) { 11 | } 12 | 13 | public void dismiss() { 14 | + dismiss(mAnimated); 15 | + } 16 | + 17 | + private void dismiss(boolean animate) { 18 | if (mIsDismissing) { 19 | return; 20 | } 21 | @@ -522,7 +526,7 @@ public void dismiss() { 22 | mEventListener.onDismiss(Snackbar.this); 23 | } 24 | 25 | - if (!mAnimated) { 26 | + if (!animate) { 27 | finish(); 28 | return; 29 | } -------------------------------------------------------------------------------- /Diff-CodeAgent4.0/6e3c6d17d943f5ac70b421653eb167e0c34b119f-message.txt: -------------------------------------------------------------------------------- 1 | Fixed issue where onDismiss() did not get called if Snackbar is swiped. -------------------------------------------------------------------------------- /Example/c#/0e231c7a81b318e9eade972f7b877e66128ed67d-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -148,7 +148,7 @@ private Kernel InitializeKernel() 2 | 3 | private readonly RedirectOutput _testOutputHelper; 4 | private readonly IConfigurationRoot _configuration; 5 | - private readonly ILoggerFactory _logger; 6 | + private readonly XunitLogger _logger; 7 | 8 | public void Dispose() 9 | { -------------------------------------------------------------------------------- /Example/c#/0e231c7a81b318e9eade972f7b877e66128ed67d-message.txt: -------------------------------------------------------------------------------- 1 | change logger to concrete type -------------------------------------------------------------------------------- /Example/c#/c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/c#/c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440/RoleConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "Chief Executive Officer": [ 3 | "{codeagent_prompt}", 4 | "You are Chief Executive Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 5 | "Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.", 6 | "Here is a new customer's task: {task}.", 7 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 8 | ], 9 | "Chief Product Officer": [ 10 | "{codeagent_prompt}", 11 | "You are Chief Product Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 12 | "You are responsible for all product-related matters in CodeAgent. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.", 13 | "Here is a new customer's task: {task}.", 14 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 15 | ], 16 | "Counselor": [ 17 | "{codeagent_prompt}", 18 | "You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 19 | "Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ", 20 | "Here is a new customer's task: {task}.", 21 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 22 | ], 23 | "Chief Technology Officer": [ 24 | "{codeagent_prompt}", 25 | "You are Chief Technology Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 26 | "You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.", 27 | "Here is a new customer's task: {task}.", 28 | "To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 29 | ], 30 | "Chief Human Resource Officer": [ 31 | "{codeagent_prompt}", 32 | "You are Chief Human Resource Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 33 | "You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).", 34 | "Here is a new customer's task: {task}.", 35 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 36 | ], 37 | "Programmer": [ 38 | "{codeagent_prompt}", 39 | "You are Programmer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 40 | "You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.", 41 | "Here is a new customer's task: {task}.", 42 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 43 | ], 44 | "Code Reviewer": [ 45 | "{codeagent_prompt}", 46 | "You are Code Reviewer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 47 | "You can help programmers to assess source codes for software troubleshooting, do vulnerability analysis, do consistency between commit and commit message, do format analysis between commit and original file, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.", 48 | "Here is a new customer's task: {task}.", 49 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 50 | ], 51 | "Software Test Engineer": [ 52 | "{codeagent_prompt}", 53 | "You are Software Test Engineer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 54 | "You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.", 55 | "Here is a new customer's task: {task}.", 56 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 57 | ], 58 | "Chief Creative Officer": [ 59 | "{codeagent_prompt}", 60 | "You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 61 | "You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.", 62 | "Here is a new customer's task: {task}.", 63 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 64 | ] 65 | } -------------------------------------------------------------------------------- /Example/c#/c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | The semantic consistency between the code changes and the commit message is generally good. The code changes accurately reflect the description provided in the commit message. However, there is one inconsistency in the code. In the `InitializeKernel` method, the `_logger` field is changed from `ILoggerFactory` to `XunitLogger`. The commit message does not mention this change, which could lead to confusion for other developers. It is recommended to update the commit message to include this change. 5 | 6 | Security Analysis: 7 | The security analysis of the provided code reveals several potential vulnerabilities. Firstly, there is no validation of user input to prevent SQL injection, XSS, and command injection risks. It is crucial to implement proper input validation and sanitization techniques to mitigate these risks. Additionally, the code does not handle errors and exceptions properly, which can lead to sensitive information leakage and service interruptions. It is recommended to implement robust error handling mechanisms. Furthermore, the code should be thoroughly reviewed for any deprecated functions, hardcoded sensitive data, or code leakages. It is also important to ensure that all dependencies, APIs, and configurations are secure and free from vulnerabilities. Finally, for mobile and cloud-based applications, additional focus should be given to mobile code security and cloud service configuration integrity. 8 | 9 | Format Analysis: 10 | The format of the code aligns well with the writing style and format of the original file. There are no significant formatting inconsistencies that impact the overall readability and maintainability of the project. 11 | 12 | Code Alignment/Revision Suggestions: 13 | 1. In the `InitializeKernel` method, the `_logger` field should be updated to use the concrete type `XunitLogger` instead of the abstract type `ILoggerFactory`. This change should be reflected in the commit message as well. 14 | 15 | Revised Code: 16 | ```csharp 17 | private readonly XunitLogger _logger; 18 | ``` 19 | 20 | Overall, the code review feedback highlights the need for improving security practices, specifically in terms of input validation, error handling, and dependency management. The formatting of the code is satisfactory, with only one minor inconsistency. The suggested code revision addresses the inconsistency in the `InitializeKernel` method. -------------------------------------------------------------------------------- /Example/c#/c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440/planner.executeasync: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/Example/c#/c#__merged__0e231c7a81b318e9eade972f7b877e66128ed67d__20240124023440/planner.executeasync -------------------------------------------------------------------------------- /Example/c++/09e88c7c20347cdf513323fa8c616aba0a1b9ea7-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -83,7 +83,6 @@ void master_server_routes() { 2 | //analytics events 3 | server->post("/analytics/events", post_create_event); 4 | server->post("/analytics/events/replicate", post_replicate_events); 5 | - server->get("/analytics/events/:name", get_analytics_events, false, true); 6 | server->get("/analytics/query_hits_counts", get_query_hits_counts); 7 | 8 | // meta -------------------------------------------------------------------------------- /Example/c++/09e88c7c20347cdf513323fa8c616aba0a1b9ea7-message.txt: -------------------------------------------------------------------------------- 1 | remove end-point to get events -------------------------------------------------------------------------------- /Example/c/5f93cf43dd6f809d7927abb79884285ad77e8a58-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -757,9 +757,9 @@

2 | 3 | 11 | 12 | -------------------------------------------------------------------------------- /Example/c/5f93cf43dd6f809d7927abb79884285ad77e8a58-message.txt: -------------------------------------------------------------------------------- 1 | remove ventoy.net in grub UI -------------------------------------------------------------------------------- /Example/c/c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/c/c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751/RoleConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "Chief Executive Officer": [ 3 | "{codeagent_prompt}", 4 | "You are Chief Executive Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 5 | "Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.", 6 | "Here is a new customer's task: {task}.", 7 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 8 | ], 9 | "Chief Product Officer": [ 10 | "{codeagent_prompt}", 11 | "You are Chief Product Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 12 | "You are responsible for all product-related matters in CodeAgent. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.", 13 | "Here is a new customer's task: {task}.", 14 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 15 | ], 16 | "Counselor": [ 17 | "{codeagent_prompt}", 18 | "You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 19 | "Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ", 20 | "Here is a new customer's task: {task}.", 21 | "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs." 22 | ], 23 | "Chief Technology Officer": [ 24 | "{codeagent_prompt}", 25 | "You are Chief Technology Officer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 26 | "You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.", 27 | "Here is a new customer's task: {task}.", 28 | "To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 29 | ], 30 | "Chief Human Resource Officer": [ 31 | "{codeagent_prompt}", 32 | "You are Chief Human Resource Officer. Now, we are both working at CodeAgent and we share a common interest in collaborating to successfully complete a task assigned by a new customer.", 33 | "You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).", 34 | "Here is a new customer's task: {task}.", 35 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 36 | ], 37 | "Programmer": [ 38 | "{codeagent_prompt}", 39 | "You are Programmer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 40 | "You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.", 41 | "Here is a new customer's task: {task}.", 42 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 43 | ], 44 | "Code Reviewer": [ 45 | "{codeagent_prompt}", 46 | "You are Code Reviewer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 47 | "You can help programmers to assess source codes for software troubleshooting, do vulnerability analysis, do consistency between commit and commit message, do format analysis between commit and original file, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.", 48 | "Here is a new customer's task: {task}.", 49 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 50 | ], 51 | "Software Test Engineer": [ 52 | "{codeagent_prompt}", 53 | "You are Software Test Engineer. we are both working at CodeAgent. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 54 | "You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.", 55 | "Here is a new customer's task: {task}.", 56 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 57 | ], 58 | "Chief Creative Officer": [ 59 | "{codeagent_prompt}", 60 | "You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.", 61 | "You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.", 62 | "Here is a new customer's task: {task}.", 63 | "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs." 64 | ] 65 | } -------------------------------------------------------------------------------- /Example/c/c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | Based on the provided code and commit message, the semantic consistency analysis reveals that the changes in the code accurately reflect the description provided in the commit message. There are no inconsistencies or potential hidden malicious code identified. 5 | 6 | Security Analysis: 7 | The security analysis of the provided code reveals several potential vulnerabilities. Firstly, there is no validation of user input, which can lead to SQL injection, XSS, and command injection risks. It is recommended to implement proper input validation and sanitization techniques to prevent these vulnerabilities. Additionally, the code does not handle errors and exceptions properly, which can result in sensitive information leakage and service interruptions. It is important to implement robust error handling mechanisms. Furthermore, the code should be reviewed for any deprecated functions, hardcoded sensitive data, or code leakages. It is also recommended to review all dependencies, APIs, and configurations, including third-party libraries, for potential vulnerabilities. Finally, for mobile and cloud-based applications, additional focus should be given to mobile code security and cloud service configuration integrity. 8 | 9 | Format Analysis: 10 | The format analysis reveals that the code formatting is inconsistent with the writing style and format of the original file. This inconsistency can impact the overall readability and maintainability of the project. It is recommended to align the code formatting with the original file's style and format to improve code quality. 11 | 12 | Code Alignment/Revision Suggestions: 13 | 1. Implement input validation and sanitization techniques to prevent SQL injection, XSS, and command injection risks. 14 | 2. Improve error handling mechanisms to avoid sensitive information leakage and service interruptions. 15 | 3. Review the code for any deprecated functions, hardcoded sensitive data, or code leakages. 16 | 4. Conduct a thorough review of all dependencies, APIs, and configurations, including third-party libraries, for potential vulnerabilities. 17 | 5. Align the code formatting with the writing style and format of the original file to improve code quality and maintainability. 18 | 19 | Revised Code: 20 | No revised code is provided in the task. 21 | 22 | Please let me know if you have any further questions or if there's anything else I can assist you with. -------------------------------------------------------------------------------- /Example/c/c__closed__5f93cf43dd6f809d7927abb79884285ad77e8a58__20240124084751/requirements.txt: -------------------------------------------------------------------------------- 1 | static/bootstrap/css/bootstrap.min.css 2 | static/css/font-awesome.min.css 3 | static/css/ionicons.min.css 4 | static/AdminLTE/css/AdminLTE.min.css 5 | static/AdminLTE/css/skins/skin-blue.min.css 6 | static/datatables/dataTables.bootstrap.css 7 | static/css/vtoy.css 8 | -------------------------------------------------------------------------------- /Example/java/6e3c6d17d943f5ac70b421653eb167e0c34b119f-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -403,7 +403,7 @@ public boolean canDismiss(Object token) { 2 | @Override 3 | public void onDismiss(View view, Object token) { 4 | if (view != null) { 5 | - finish(); 6 | + dismiss(false); 7 | } 8 | } 9 | 10 | @@ -512,6 +512,10 @@ private void startTimer(long duration) { 11 | } 12 | 13 | public void dismiss() { 14 | + dismiss(mAnimated); 15 | + } 16 | + 17 | + private void dismiss(boolean animate) { 18 | if (mIsDismissing) { 19 | return; 20 | } 21 | @@ -522,7 +526,7 @@ public void dismiss() { 22 | mEventListener.onDismiss(Snackbar.this); 23 | } 24 | 25 | - if (!mAnimated) { 26 | + if (!animate) { 27 | finish(); 28 | return; 29 | } -------------------------------------------------------------------------------- /Example/java/6e3c6d17d943f5ac70b421653eb167e0c34b119f-message.txt: -------------------------------------------------------------------------------- 1 | Fixed issue where onDismiss() did not get called if Snackbar is swiped. -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | The code changes in the provided code are consistent with the description provided in the commit message. There are no inconsistencies or potential hidden malicious code found in the code changes. 5 | 6 | Security Analysis: 7 | The security analysis of the provided code reveals several potential vulnerabilities. The code should be reviewed and updated to address these issues: 8 | 9 | 1. Validate User Input: The code should implement proper input validation to prevent SQL injection, XSS, and command injection risks. This can be achieved by using parameterized queries or prepared statements for database operations and sanitizing user input for HTML output. 10 | 11 | 2. Memory Management: The code should ensure robust memory management, especially in lower-level languages, to avoid buffer overflows and other memory-related vulnerabilities. This can be achieved by using safe memory allocation and deallocation practices and avoiding unsafe memory manipulation. 12 | 13 | 3. Authentication and Authorization: The code should have proper authentication and authorization processes in place to prevent unauthorized access and data breaches. This includes implementing secure password hashing, session management, and access control mechanisms. 14 | 15 | 4. Error Handling: The code should handle errors and exceptions properly to avoid leaking sensitive information and causing service interruptions. Error messages should not reveal sensitive information and should be logged securely. 16 | 17 | 5. Dependency and API Analysis: All dependencies, APIs, and configurations, including third-party libraries, should be examined for potential vulnerabilities. It is important to keep all dependencies up to date and apply security patches regularly. 18 | 19 | 6. Security Configurations: The code should have strong security configurations, avoiding weak defaults and ensuring encrypted communications. This includes using secure protocols and algorithms, enforcing secure communication channels, and protecting sensitive data in transit and at rest. 20 | 21 | 7. Vulnerability Types: Pay special attention to potential vulnerabilities such as CSRF attacks, code injection, race conditions, memory leaks, and poor resource management. Also, ensure protection against path traversal, file inclusion vulnerabilities, unsafe deserialization, XXE attacks, SSRF, and unsafe redirects. 22 | 23 | 8. Deprecated Functions and Hardcoded Sensitive Data: The code should not use deprecated functions or hardcode sensitive data. Deprecated functions may have known vulnerabilities, and hardcoded sensitive data can be easily exposed. 24 | 25 | 9. Mobile and Cloud Security: For mobile and cloud-based applications, additional focus should be on mobile code security and cloud service configuration integrity. This includes securing mobile app APIs, implementing secure authentication and authorization mechanisms, and securing cloud service configurations. 26 | 27 | Format Analysis: 28 | The format of the code aligns with the writing style and format of the original file. There are no formatting inconsistencies that impact the overall readability and maintainability of the project. 29 | 30 | Code Alignment/Revision Suggestions: 31 | Based on the analysis, the following suggestions are provided for code alignment and revisions: 32 | 33 | 1. In the `Snackbar` class, the `dismiss()` method can be simplified by calling the `dismiss(boolean animate)` method with the `mAnimated` parameter set to `false`. This will remove the duplicated code. 34 | 35 | ```java 36 | public void dismiss() { 37 | dismiss(false); 38 | } 39 | ``` 40 | 41 | 2. In the `Snackbar` class, the `dismiss(boolean animate)` method can be improved by removing the unnecessary `mIsDismissing` check. The check is already performed in the `dismiss()` method, so it can be removed from the `dismiss(boolean animate)` method. 42 | 43 | ```java 44 | private void dismiss(boolean animate) { 45 | if (mIsDismissing) { 46 | return; 47 | } 48 | // Rest of the code 49 | } 50 | ``` 51 | 52 | Revised Code: 53 | Here is the revised code with the suggested changes: 54 | 55 | ```java 56 | public void dismiss() { 57 | dismiss(false); 58 | } 59 | 60 | private void dismiss(boolean animate) { 61 | // Rest of the code 62 | } 63 | ``` 64 | 65 | Please review the suggested changes and make the necessary revisions to address the security vulnerabilities and improve the code alignment. -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316/requirements.txt: -------------------------------------------------------------------------------- 1 | com.nispok.snackbar==1.4.2 2 | -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124013316/snackbar.this: -------------------------------------------------------------------------------- 1 | {revised_code} -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/commit.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Semantic Consistency Analysis: The code changes in the commit do not accurately reflect the description provided in the commit message. The commit message mentions fixing an issue where onDismiss() did not get called if Snackbar is swiped, but the code changes do not address this issue. Instead, the code changes seem to be related to dismissing the Snackbar. 3 | Security Analysis: [No security analysis can be performed as the code is not provided] 4 | Format Analysis: The format of the code aligns with the writing style and format of the original file. There are no formatting inconsistencies that impact the overall readability and maintainability of the project. 5 | Code Alignment/Revision Suggestions: The highest priority comment is regarding the semantic consistency between the code changes and the commit message. The code changes should address the issue mentioned in the commit message, i.e., fixing the issue where onDismiss() did not get called if Snackbar is swiped. To fix this issue, the following changes can be made: 6 | 1. In the `Snackbar` class, modify the `dismiss()` method as follows: -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/i.e: -------------------------------------------------------------------------------- 1 | public void dismiss() { 2 | dismiss(mAnimated); 3 | } -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/manual.md: -------------------------------------------------------------------------------- 1 | Semantic Consistency Analysis: The code changes in the commit do not accurately reflect the description provided in the commit message. The commit message mentions fixing an issue where onDismiss() did not get called if Snackbar is swiped, but the code changes do not address this issue. Instead, the code changes seem to be related to dismissing the Snackbar. 2 | 3 | Security Analysis: No security analysis can be performed as the code is not provided. 4 | 5 | Format Analysis: The format of the code aligns with the writing style and format of the original file. There are no formatting inconsistencies that impact the overall readability and maintainability of the project. 6 | 7 | Code Alignment/Revision Suggestions: The highest priority comment is regarding the semantic consistency between the code changes and the commit message. The code changes should address the issue mentioned in the commit message, i.e., fixing the issue where onDismiss() did not get called if Snackbar is swiped. To fix this issue, the following changes can be made: 8 | 9 | 1. In the `Snackbar` class, modify the `dismiss()` method as follows: 10 | 11 | ```java 12 | public void dismiss() { 13 | dismiss(mAnimated); 14 | } 15 | 16 | private void dismiss(boolean animate) { 17 | if (mIsDismissing) { 18 | return; 19 | } 20 | mIsDismissing = true; 21 | if (mEventListener != null) { 22 | mEventListener.onDismiss(Snackbar.this); 23 | } 24 | if (!animate) { 25 | finish(); 26 | return; 27 | } 28 | // implementation 29 | } 30 | ``` 31 | 32 | Please make the above changes to ensure that the code aligns with the description provided in the commit message. 33 | 34 | Revised Code: 35 | 36 | ```java 37 | public boolean canDismiss(Object token) { 38 | return true; 39 | } 40 | 41 | @Override 42 | public void onDismiss(View view, Object token) { 43 | if (view != null) { 44 | dismiss(false); 45 | } 46 | } 47 | 48 | private void startTimer(long duration) { 49 | // implementation 50 | } 51 | 52 | public void dismiss() { 53 | dismiss(mAnimated); 54 | } 55 | 56 | private void dismiss(boolean animate) { 57 | if (mIsDismissing) { 58 | return; 59 | } 60 | mIsDismissing = true; 61 | if (mEventListener != null) { 62 | mEventListener.onDismiss(Snackbar.this); 63 | } 64 | if (!animate) { 65 | finish(); 66 | return; 67 | } 68 | // implementation 69 | } 70 | ``` 71 | 72 | Please review the revised code and make sure it addresses the issue mentioned in the commit message. -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/requirements.txt: -------------------------------------------------------------------------------- 1 | android==1.0.0 2 | -------------------------------------------------------------------------------- /Example/java/java__merged__6e3c6d17d943f5ac70b421653eb167e0c34b119f__20240124041718/snackbar.this: -------------------------------------------------------------------------------- 1 | Please make the above changes to ensure that the code aligns with the description provided in the commit message. 2 | ''' 3 | code 4 | ''' 5 | public boolean canDismiss(Object token) { 6 | return true; 7 | } 8 | @Override 9 | public void onDismiss(View view, Object token) { 10 | if (view != null) { 11 | dismiss(false); 12 | } 13 | } 14 | private void startTimer(long duration) { 15 | // implementation 16 | } 17 | public void dismiss() { 18 | dismiss(mAnimated); 19 | } 20 | private void dismiss(boolean animate) { 21 | if (mIsDismissing) { 22 | return; 23 | } 24 | mIsDismissing = true; 25 | if (mEventListener != null) { 26 | mEventListener.onDismiss(Snackbar.this); 27 | } 28 | if (!animate) { 29 | finish(); 30 | return; 31 | } 32 | // implementation 33 | } 34 | ''' -------------------------------------------------------------------------------- /Example/javascript/6e9a80d93b470aef4978677ed0b7c9996fddbe20-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -225,6 +225,22 @@ window['$'] = window['jquip'] = (function(){ 2 | } 3 | return this; 4 | }; 5 | + p['replaceWith'] = function(val){ 6 | + if (isF(val)) { 7 | + return this['each'](function(i) { 8 | + var self = $(this), old = self.html(); 9 | + self.replaceWith( val.call(this, i, old) ); 10 | + }); 11 | + } else if (isS(val)) { 12 | + val = $(val).detach(); 13 | + } 14 | + return this['each'](function() { 15 | + var next = this.nextSibling, 16 | + parent = this.parentNode; 17 | + parent.removeChild(this); 18 | + (next ? $(next).before(val) : $(parent).append(val)); 19 | + }); 20 | + }; 21 | p['hide'] = function(){ 22 | return this['each'](function(){ 23 | cache(this, "display", this.style.display); -------------------------------------------------------------------------------- /Example/javascript/6e9a80d93b470aef4978677ed0b7c9996fddbe20-message.txt: -------------------------------------------------------------------------------- 1 | Addeed .replaceWith() -------------------------------------------------------------------------------- /Example/javascript/javascript__closed__6e9a80d93b470aef4978677ed0b7c9996fddbe20__20240124080405/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/javascript/javascript__closed__6e9a80d93b470aef4978677ed0b7c9996fddbe20__20240124080405/requirements.txt: -------------------------------------------------------------------------------- 1 | jquip==1.4.4 2 | -------------------------------------------------------------------------------- /Example/php/6679f059b9a0972a90df198471188da652f5c547-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -2410,7 +2410,7 @@ function is_post_publicly_viewable( $post = null ) { 2 | * Is an alias of `$post__in` in WP_Query. Default empty array. 3 | * @type int[] $exclude An array of post IDs not to retrieve. Default empty array. 4 | * @type bool $suppress_filters Whether to suppress filters. Default true. 5 | - * } 6 | + * @type bool $get_post_meta Return All post meta data. Default false. 7 | * @return WP_Post[]|int[] Array of post objects or post IDs. 8 | */ 9 | function get_posts( $args = null ) { 10 | @@ -2425,6 +2425,7 @@ function get_posts( $args = null ) { 11 | 'meta_value' => '', 12 | 'post_type' => 'post', 13 | 'suppress_filters' => true, 14 | + 'get_post_meta' => false 15 | ); 16 | 17 | $parsed_args = wp_parse_args( $args, $defaults ); 18 | @@ -2449,7 +2450,20 @@ function get_posts( $args = null ) { 19 | $parsed_args['no_found_rows'] = true; 20 | 21 | $get_posts = new WP_Query(); 22 | - return $get_posts->query( $parsed_args ); 23 | + $get_posts = $get_posts->query($parsed_args); 24 | + 25 | + if (!empty($parsed_args['get_post_meta'])) { 26 | + foreach ($get_posts as $post) { 27 | + $post_meta = []; 28 | + foreach (get_post_meta($post->ID) as $key => $value) { 29 | + $post_meta[$key] = $value[0]; 30 | + } 31 | + $post->meta_data = $post_meta; 32 | + $get_posts[] = $post; 33 | + } 34 | + }; 35 | + 36 | + return $get_posts; 37 | } 38 | 39 | // -------------------------------------------------------------------------------- /Example/php/6679f059b9a0972a90df198471188da652f5c547-message.txt: -------------------------------------------------------------------------------- 1 | add get_post_meta args to get_posts() -------------------------------------------------------------------------------- /Example/php/php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/php/php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337/get_posts.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Core Post API 3 | @package WordPress 4 | @subpackage Post 5 | ''' 6 | # Post Type registration. 7 | def create_initial_post_types(): 8 | WP_Post_Type.reset_default_labels() 9 | register_post_type( 10 | 'post', 11 | { 12 | 'labels': { 13 | 'name_admin_bar': _x('Post', 'add new from admin bar'), 14 | }, 15 | 'public': True, 16 | '_builtin': True, # internal use only. don't use this when registering your own post type. 17 | '_edit_link': 'post.php?post=%d', # internal use only. don't use this when registering your own post type. 18 | 'capability_type': 'post', 19 | 'map_meta_cap': True, 20 | 'menu_position': 5, 21 | 'menu_icon': 'dashicons-admin-post', 22 | 'hierarchical': False, 23 | 'rewrite': False, 24 | 'query_var': False, 25 | 'delete_with_user': True, 26 | 'supports': ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats'], 27 | 'show_in_rest': True, 28 | 'rest_base': 'posts', 29 | 'rest_controller_class': 'WP_REST_Posts_Controller', 30 | } 31 | ) 32 | register_post_type( 33 | 'page', 34 | { 35 | 'labels': { 36 | 'name_admin_bar': _x('Page', 'add new from admin bar'), 37 | }, 38 | 'public': True, 39 | 'publicly_queryable': False, 40 | '_builtin': True, # internal use only. don't use this when registering your own post type. 41 | '_edit_link': 'post.php?post=%d', # internal use only. don't use this when registering your own post type. 42 | 'capability_type': 'page', 43 | 'map_meta_cap': True, 44 | 'menu_position': 20, 45 | 'menu_icon': 'dashicons-admin-page', 46 | 'hierarchical': True, 47 | 'rewrite': False, 48 | 'query_var': False, 49 | 'delete_with_user': True, 50 | 'supports': ['title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions'], 51 | 'show_in_rest': True, 52 | 'rest_base': 'pages', 53 | 'rest_controller_class': 'WP_REST_Posts_Controller', 54 | } 55 | ) 56 | register_post_type( 57 | 'attachment', 58 | { 59 | 'labels': { 60 | 'name': _x('Media', 'post type general name'), 61 | 'name_admin_bar': _x('Media', 'add new from admin bar'), 62 | 'add_new': __('Add New Media File'), 63 | 'edit_item': __('Edit Media'), 64 | 'view_item': ('1' === get_option('wp_attachment_pages_enabled')) ? __('View Attachment Page') : __('View Media File'), 65 | 'attributes': __('Attachment Attributes'), 66 | }, 67 | 'public': True, 68 | 'show_ui': True, 69 | '_builtin': True, # internal use only. don't use this when registering your own post type. 70 | '_edit_link': 'post.php?post=%d', # internal use only. don't use this when registering your own post type. 71 | 'capability_type': 'post', 72 | 'capabilities': { 73 | 'create_posts': 'upload_files', 74 | }, 75 | } 76 | ) 77 | ''' 78 | COMMIT -------------------------------------------------------------------------------- /Example/php/php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | The semantic consistency between the code changes and the commit message seems to be accurate. The changes made in the code align with the description provided in the commit message. There are no inconsistencies or potential hidden malicious code identified in this aspect. 5 | 6 | Security Analysis: 7 | The provided code requires a comprehensive security review to identify potential vulnerabilities. The analysis should focus on the following areas: 8 | 9 | 1. Validating user input: Ensure that user input is properly validated to prevent SQL injection, XSS, and command injection risks. Implement input sanitization and parameterized queries to mitigate these vulnerabilities. 10 | 11 | 2. Memory management: Since the code is written in Python, robust memory management is not a major concern. However, ensure that there are no buffer overflow vulnerabilities in any dependencies or libraries used. 12 | 13 | 3. Authentication and authorization: Review the code to ensure that proper authentication and authorization processes are in place. Check for any potential vulnerabilities that could lead to unauthorized access or data breaches. 14 | 15 | 4. Error handling: Verify that errors and exceptions are handled properly to avoid leaking sensitive information and causing service interruptions. Implement appropriate error logging and exception handling mechanisms. 16 | 17 | 5. Dependency and API analysis: Examine all dependencies, APIs, and configurations, including third-party libraries, for potential vulnerabilities. Ensure that all dependencies are up to date and do not have any known security issues. 18 | 19 | 6. Security configurations: Check if the security configurations are strong, avoiding weak defaults and ensuring encrypted communications. Pay special attention to path traversal, file inclusion vulnerabilities, unsafe deserialization, XXE attacks, SSRF, and unsafe redirects. 20 | 21 | 7. Deprecated functions and hardcoded sensitive data: Ensure that no deprecated functions are used and that there is no hardcoded sensitive data present in the code. 22 | 23 | Based on the provided code, it is difficult to perform a comprehensive security analysis. However, it is recommended to conduct a thorough security review considering the above points to identify any potential vulnerabilities. 24 | 25 | Format Analysis: 26 | The format of the code does not align with the writing style and format of the original file. There are inconsistencies in indentation, spacing, and line breaks. These formatting inconsistencies can impact the overall readability and maintainability of the project. It is recommended to follow a consistent coding style and use proper indentation and spacing throughout the codebase. 27 | 28 | Code Alignment/Revision Suggestions: 29 | 1. In the `get_posts` function, the `get_post_meta` argument is not aligned properly with the other arguments. It should be aligned with the other arguments for better readability. 30 | 31 | 2. In the `get_posts` function, the `get_posts` variable is overwritten with a new value. It is recommended to use a different variable name to avoid confusion. 32 | 33 | 3. In the `get_posts` function, the code block inside the `if` condition can be simplified by using a dictionary comprehension. Instead of manually iterating over `get_post_meta`, you can use a dictionary comprehension to create the `post_meta` dictionary. 34 | 35 | Revised Code: 36 | ```python 37 | def get_posts(args=None): 38 | defaults = { 39 | 'numberposts': -1, 40 | 'offset': 0, 41 | 'category': 0, 42 | 'orderby': 'date', 43 | 'order': 'DESC', 44 | 'include': [], 45 | 'exclude': [], 46 | 'suppress_filters': True, 47 | 'get_post_meta': False 48 | } 49 | 50 | parsed_args = wp_parse_args(args, defaults) 51 | 52 | query_args = { 53 | 'numberposts': parsed_args['numberposts'], 54 | 'offset': parsed_args['offset'], 55 | 'category': parsed_args['category'], 56 | 'orderby': parsed_args['orderby'], 57 | 'order': parsed_args['order'], 58 | 'include': parsed_args['include'], 59 | 'exclude': parsed_args['exclude'], 60 | 'suppress_filters': parsed_args['suppress_filters'] 61 | } 62 | 63 | get_posts_query = WP_Query() 64 | posts = get_posts_query.query(query_args) 65 | 66 | if parsed_args['get_post_meta']: 67 | for post in posts: 68 | post_meta = {key: value[0] for key, value in get_post_meta(post.ID).items()} 69 | post.meta_data = post_meta 70 | 71 | return posts 72 | ``` 73 | 74 | Please note that the revised code is based on the assumption that the code is part of a larger codebase and the required dependencies are properly imported. 75 | 76 | Summary: 77 | Based on the provided code, a comprehensive security analysis is recommended to identify potential vulnerabilities. The code formatting should be improved to ensure consistency and readability. The proposed code revisions aim to address the formatting inconsistencies and improve the readability of the code. -------------------------------------------------------------------------------- /Example/php/php__closed__6679f059b9a0972a90df198471188da652f5c547__20240124053337/requirements.txt: -------------------------------------------------------------------------------- 1 | WP_Query==1.0.0 2 | -------------------------------------------------------------------------------- /Example/ruby/584f72e7f4c65066ccbd2183af76bf380b6eb974-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -15,7 +15,7 @@ end 2 | # 3 | 4 | group :test do 5 | - gem "activesupport", "~> 7.0.0" 6 | + gem "activesupport", "< 7.1.0" 7 | gem "cucumber", RUBY_VERSION >= "2.5" ? "~> 5.1.2" : "~> 4.1" 8 | gem "httpclient" 9 | gem "jekyll_test_plugin" -------------------------------------------------------------------------------- /Example/ruby/584f72e7f4c65066ccbd2183af76bf380b6eb974-context.txt: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | gemspec :name => "jekyll" 5 | 6 | gem "rake", "~> 13.0" 7 | 8 | group :development do 9 | gem "launchy", "~> 2.3" 10 | gem "pry" 11 | 12 | gem "pry-byebug" unless RUBY_ENGINE == "jruby" 13 | end 14 | 15 | # 16 | 17 | group :test do 18 | gem "activesupport", "< 7.1.0" 19 | gem "cucumber", RUBY_VERSION >= "2.5" ? "~> 5.1.2" : "~> 4.1" 20 | gem "httpclient" 21 | gem "jekyll_test_plugin" 22 | gem "jekyll_test_plugin_malicious" 23 | gem "memory_profiler" 24 | gem "nokogiri", "~> 1.7" 25 | gem "rspec" 26 | gem "rspec-mocks" 27 | gem "rubocop", "~> 1.57.2" 28 | gem "rubocop-minitest" 29 | gem "rubocop-performance" 30 | gem "rubocop-rake" 31 | gem "rubocop-rspec" 32 | gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) 33 | gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) 34 | gem "test-theme-skinny", :path => File.expand_path("test/fixtures/test-theme-skinny", __dir__) 35 | gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__) 36 | gem "test-theme-w-empty-data", :path => File.expand_path("test/fixtures/test-theme-w-empty-data", __dir__) 37 | 38 | if RUBY_ENGINE == "jruby" 39 | gem "http_parser.rb", "~> 0.6.0" 40 | gem "jruby-openssl" 41 | end 42 | end 43 | 44 | # 45 | 46 | group :test_legacy do 47 | gem "test-unit" if RUBY_PLATFORM =~ %r!cygwin! 48 | 49 | gem "minitest" 50 | gem "minitest-profile" 51 | gem "minitest-reporters" 52 | gem "shoulda-context" 53 | gem "simplecov" 54 | end 55 | 56 | # 57 | 58 | group :benchmark do 59 | if ENV["BENCHMARK"] 60 | gem "benchmark-ips" 61 | gem "rbtrace" 62 | gem "ruby-prof" 63 | gem "stackprof" 64 | end 65 | end 66 | 67 | # 68 | 69 | group :jekyll_optional_dependencies do 70 | gem "jekyll-coffeescript" 71 | gem "jekyll-docs", :path => "../docs" if Dir.exist?("../docs") && ENV["JEKYLL_VERSION"] 72 | gem "jekyll-feed", "~> 0.9" 73 | gem "jekyll-gist" 74 | gem "jekyll-paginate" 75 | gem "jekyll-redirect-from" 76 | gem "kramdown-syntax-coderay" 77 | gem "matrix" 78 | gem "mime-types", "~> 3.0" 79 | # Psych 5 has stopped bundling `libyaml` and expects it to be installed on the host system prior 80 | # to being invoked. 81 | # Since we don't have a direct dependency on the Psych gem (it gets included in the gem bundle as 82 | # a dependency of the `rdoc` gem), lock psych gem to v4.x instead of installing `libyaml` in our 83 | # development / CI environment. 84 | gem "psych", "~> 4.0" 85 | gem "rdoc", "~> 6.0" 86 | gem "tomlrb" 87 | 88 | platforms :ruby, :mswin, :mingw, :x64_mingw do 89 | gem "classifier-reborn", "~> 2.2" 90 | gem "liquid-c", "~> 4.0" 91 | gem "yajl-ruby", "~> 1.4" 92 | end 93 | 94 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem 95 | # and associated library 96 | platforms :jruby, :mswin, :mingw, :x64_mingw do 97 | gem "tzinfo", ENV["TZINFO_VERSION"] if ENV["TZINFO_VERSION"] 98 | gem "tzinfo-data" 99 | end 100 | end 101 | 102 | # 103 | 104 | group :site do 105 | gem "html-proofer", "~> 3.4" if ENV["PROOF"] 106 | 107 | gem "jekyll-avatar" 108 | gem "jekyll-mentions" 109 | gem "jekyll-seo-tag" 110 | gem "jekyll-sitemap" 111 | gem "jemoji" 112 | end 113 | -------------------------------------------------------------------------------- /Example/ruby/584f72e7f4c65066ccbd2183af76bf380b6eb974-message.txt: -------------------------------------------------------------------------------- 1 | Allow activesupport v6 -------------------------------------------------------------------------------- /Example/ruby/ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950/6.0: -------------------------------------------------------------------------------- 1 | gem "activesupport", "~> 6.0.0" -------------------------------------------------------------------------------- /Example/ruby/ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/ruby/ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | The semantic consistency between the code changes and the commit message is generally good. However, there are a few inconsistencies that could lead to confusion. For example, in the commit message, it is mentioned that the gem "activesupport" should be limited to version "< 7.1.0", but in the code, it is set to "~> 6.0.0". This inconsistency should be addressed to accurately reflect the intended changes. 5 | 6 | Security Analysis: 7 | The provided code and recent code modifications should undergo a comprehensive security review. This review should focus on critical areas that could lead to vulnerabilities or other reasons that may cause vulnerabilities. It is important to validate user input to prevent SQL injection, XSS, and command injection risks. Additionally, robust memory management should be ensured in lower-level languages to avoid buffer overflows. The authentication and authorization processes should be carefully examined, along with how sensitive data is managed, to prevent unauthorized access and data breaches. Proper handling of errors and exceptions is vital to avoid leaking sensitive information and causing service interruptions. All dependencies, APIs, and configurations, including third-party libraries, should be examined for potential vulnerabilities. Special attention should be given to CSRF attacks, code injection, race conditions, memory leaks, and poor resource management. It is important to ensure that security configurations are strong, avoiding weak defaults and ensuring encrypted communications. Path traversal, file inclusion vulnerabilities, unsafe deserialization, XXE attacks, SSRF, and unsafe redirects should be thoroughly checked. Deprecated functions, hardcoded sensitive data, and code leakages should be eliminated. For mobile and cloud-based applications, additional focus should be on mobile code security and cloud service configuration integrity. After completing the analysis, a summarized paragraph of any vulnerabilities found should be provided. 8 | 9 | Format Analysis: 10 | The format of the code does not align with the writing style and format of the original file. There are inconsistencies in indentation, commented out code, and unnecessary comments. These formatting inconsistencies can impact the overall readability and maintainability of the project. It is recommended to adhere to a consistent coding style and remove unnecessary comments and code. 11 | 12 | Code Alignment/Revision Suggestions: 13 | Based on the analysis, the following suggestions are provided: 14 | 15 | 1. In the Semantic Consistency Analysis, the inconsistency between the commit message and the code regarding the gem "activesupport" should be resolved. The gem should be limited to version "< 7.1.0" as mentioned in the commit message. 16 | 17 | 2. In the Format Analysis, it is recommended to align the code with the writing style and format of the original file. This includes fixing indentation, removing commented out code, and unnecessary comments. 18 | 19 | Revised Code: 20 | 21 | ```ruby 22 | group :test do 23 | gem "activesupport", "< 7.1.0" 24 | gem "cucumber", RUBY_VERSION >= "2.5"? "~> 5.1.2" : "~> 4.1" 25 | gem "httpclient" 26 | gem "jekyll_test_plugin" 27 | gem "jekyll_test_plugin_malicious" 28 | gem "memory_profiler" 29 | gem "nokogiri", "~> 1.7" 30 | gem "rspec" 31 | gem "rspec-mocks" 32 | gem "rubocop", "~> 1.57.2" 33 | gem "rubocop-minitest" 34 | gem "rubocop-performance" 35 | gem "rubocop-rake" 36 | gem "rubocop-rspec" 37 | gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) 38 | gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) 39 | gem "test-theme-skinny", :path => File.expand_path("test/fixtures/test-theme-skinny", __dir__) 40 | gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__) 41 | gem "test-theme-w-empty-data", :path => File.expand_path("test/fixtures/test-theme-w-empty-data", __dir__) 42 | 43 | if RUBY_ENGINE == "jruby" 44 | gem "http_parser.rb", "~> 0.6.0" 45 | gem "jruby-openssl" 46 | end 47 | end 48 | 49 | group :test_legacy do 50 | gem "test-unit" if RUBY_PLATFORM =~ %r!cygwin! 51 | gem "minitest" 52 | gem "minitest-profile" 53 | gem "minitest-reporters" 54 | gem "shoulda-context" 55 | gem "simplecov" 56 | end 57 | 58 | group :benchmark do 59 | if ENV["BENCHMARK"] 60 | gem "benchmark-ips" 61 | gem "rbtrace" 62 | gem "ruby-prof" 63 | gem "stackprof" 64 | end 65 | end 66 | 67 | group :jekyll_optional_dependencies do 68 | gem "jekyll-coffeescript" 69 | gem "jekyll-docs", :path => "../docs" if Dir.exist?("../docs") && ENV["JEKYLL_VERSION"] 70 | gem "jekyll-feed", "~> 0.9" 71 | gem "jekyll-gist" 72 | gem "jekyll-paginate" 73 | gem "jekyll-redirect-from" 74 | gem "kramdown-syntax-coderay" 75 | gem "matrix" 76 | gem "mime-types", "~> 3.0" 77 | gem "psych", "~> 4.0" 78 | gem "rdoc", "~> 6.0" 79 | gem "tomlrb" 80 | 81 | platforms :ruby, :mswin, :mingw, :x64_mingw do 82 | gem "classifier-reborn", "~> 2.2" 83 | gem "liquid-c", "~> 4.0" 84 | gem "yajl-ruby", "~> 1.4" 85 | end 86 | 87 | platforms :jruby, :mswin, :mingw, :x64_mingw do 88 | gem "tzinfo", ENV["TZINFO_VERSION"] if ENV["TZINFO_VERSION"] 89 | gem "tzinfo-data" 90 | end 91 | end 92 | 93 | group :site do 94 | gem "html-proofer", "~> 3.4" if ENV["PROOF"] 95 | gem "jekyll-avatar" 96 | gem "jekyll-mentions" 97 | gem "jekyll-seo-tag" 98 | gem "jekyll-sitemap" 99 | gem "jemoji" 100 | end 101 | ``` 102 | 103 | Please note that the revised code is based on the provided information and may require further adjustments based on the specific requirements and context of the project. -------------------------------------------------------------------------------- /Example/ruby/ruby__merged__584f72e7f4c65066ccbd2183af76bf380b6eb974__20240124012950/requirements.txt: -------------------------------------------------------------------------------- 1 | activesupport==6.0.0 2 | cucumber~=5.1.2 3 | httpclient 4 | jekyll_test_plugin 5 | jekyll_test_plugin_malicious 6 | memory_profiler 7 | nokogiri~=1.7 8 | rspec 9 | rspec-mocks 10 | rubocop~=1.57.2 11 | rubocop-minitest 12 | rubocop-performance 13 | rubocop-rake 14 | rubocop-rspec 15 | test-dependency-theme 16 | test-theme 17 | test-theme-skinny 18 | test-theme-symlink 19 | test-theme-w-empty-data 20 | -------------------------------------------------------------------------------- /Example/video-example-1/42f249941b687a73c020c11779a511a90cbedb28-commit.txt: -------------------------------------------------------------------------------- 1 | @@ -19,7 +19,7 @@ android: 2 | - build-tools-21.1.0 3 | 4 | # The SDK version used to compile your project 5 | - - android-20 6 | + - android-21 7 | 8 | # Specify at least one system image, 9 | # if you need to run emulator(s) during your tests -------------------------------------------------------------------------------- /Example/video-example-1/42f249941b687a73c020c11779a511a90cbedb28-context.txt: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | env: 4 | matrix: 5 | - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a 6 | 7 | branches: 8 | only: 9 | - master 10 | 11 | android: 12 | components: 13 | # Uncomment the lines below if you want to 14 | # use the latest revision of Android SDK Tools 15 | - platform-tools 16 | - tools 17 | 18 | # The BuildTools version used by your project 19 | - build-tools-21.1.0 20 | 21 | # The SDK version used to compile your project 22 | - android-21 23 | 24 | # Specify at least one system image, 25 | # if you need to run emulator(s) during your tests 26 | - sys-img-armeabi-v7a-android-19 27 | - sys-img-x86-android-17 28 | 29 | # Emulator Management: Create, Start and Wait 30 | before_script: 31 | - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI 32 | - emulator -avd test -no-skin -no-audio -no-window & 33 | - android-wait-for-emulator 34 | - adb shell input keyevent 82 & 35 | 36 | script: 37 | - ./gradlew :lib:connectedAndroidTest -------------------------------------------------------------------------------- /Example/video-example-1/42f249941b687a73c020c11779a511a90cbedb28-message.txt: -------------------------------------------------------------------------------- 1 | Travis update -------------------------------------------------------------------------------- /Example/video-example-1/java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017/21.1: -------------------------------------------------------------------------------- 1 | android: 2 | - build-tools-21.1.0 3 | # The SDK version used to compile your project 4 | - android-21 5 | # Specify at least one system image, 6 | # if you need to run emulator(s) during your tests -------------------------------------------------------------------------------- /Example/video-example-1/java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/video-example-1/java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017/java__merged__42f249941b687a73c020c11779a511a90cbedb28.prompt: -------------------------------------------------------------------------------- 1 | 2 | I have a code, which includes the commit message, and the corresponding original file, these file are connected like this 3 | code commit message original file. 4 | If there is commit message is null, please don't do Semantic Consistency Analysis. if orignial file is null, please don't do Format Analysis. 5 | I would like a detailed code review based on the following three aspects: 6 | 7 | Semantic Consistency Analysis: 8 | Please analyze the semantic consistency between the code changes in side the code and the commit message. Check if the changes in the codes accurately reflect the description provided in the commit message. Highlight any inconsistencies that might lead to confusion or potential hidden malicious code. 9 | Security Analysis: 10 | Conduct a vulnerability analysis of the code. Identify if any modifications could potentially introduce security vulnerabilities, attacks, or bugs. Provide details of any such findings. 11 | Format Analysis: 12 | Assess if the format of the code aligns with the writing style and format of the original file. Evaluate the impact of any formatting inconsistencies on the overall readability and maintainability of the project. 13 | For each of the above aspects, please provide a clear analysis and any necessary suggestions for improvement. If you find any issues, especially in the code, provide specific suggestions or rewritten code snippets to guide the commit contributor on how to make the necessary revisions. 14 | 15 | 16 | 17 | The final feedback should be structured as follows: 18 | Semantic Consistency Analysis: [Your detailed analysis and suggestions] 19 | Security Analysis: [Your detailed analysis and suggestions] 20 | Format Analysis: [Your detailed analysis and suggestions] 21 | Code Alignment/Revision Suggestions: [Your proposed code revisions for the commit or suggestions, if any] 22 | revised code: [Your revised commit, if any] 23 | @@ -19,7 +19,7 @@ android: 24 | - build-tools-21.1.0 25 | 26 | # The SDK version used to compile your project 27 | - - android-20 28 | + - android-21 29 | 30 | # Specify at least one system image, 31 | # if you need to run emulator(s) during your tests Travis update language: android 32 | 33 | env: 34 | matrix: 35 | - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a 36 | 37 | branches: 38 | only: 39 | - master 40 | 41 | android: 42 | components: 43 | # Uncomment the lines below if you want to 44 | # use the latest revision of Android SDK Tools 45 | - platform-tools 46 | - tools 47 | 48 | # The BuildTools version used by your project 49 | - build-tools-21.1.0 50 | 51 | # The SDK version used to compile your project 52 | - android-21 53 | 54 | # Specify at least one system image, 55 | # if you need to run emulator(s) during your tests 56 | - sys-img-armeabi-v7a-android-19 57 | - sys-img-x86-android-17 58 | 59 | # Emulator Management: Create, Start and Wait 60 | before_script: 61 | - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI 62 | - emulator -avd test -no-skin -no-audio -no-window & 63 | - android-wait-for-emulator 64 | - adb shell input keyevent 82 & 65 | 66 | script: 67 | -./gradlew :lib:connectedAndroidTest -------------------------------------------------------------------------------- /Example/video-example-1/java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017/manual.md: -------------------------------------------------------------------------------- 1 | # Code Review Feedback 2 | 3 | Semantic Consistency Analysis: 4 | Based on the provided commit message and the code changes, there seems to be a semantic inconsistency. The commit message mentions "Travis update", but there are no code changes related to Travis or any update. This inconsistency might lead to confusion for other developers who are reviewing the commit or trying to understand the changes made. It is important to ensure that the commit message accurately reflects the changes made in the code. 5 | 6 | Security Analysis: 7 | No security vulnerabilities or potential attacks were identified in the code. 8 | 9 | Format Analysis: 10 | The format of the code seems to align with the writing style and format of the original file. There are no formatting inconsistencies that impact the overall readability and maintainability of the project. 11 | 12 | Code Alignment/Revision Suggestions: 13 | Based on the semantic inconsistency identified, I suggest revising the commit message to accurately reflect the changes made in the code. Instead of mentioning "Travis update", the commit message should provide a clear description of the actual changes made in the code. 14 | 15 | Revised commit message: "Update Android SDK version to 21.1.0" 16 | 17 | Revised code: 18 | ```python 19 | android: 20 | - build-tools-21.1.0 21 | # The SDK version used to compile your project 22 | - android-21 23 | # Specify at least one system image, 24 | # if you need to run emulator(s) during your tests 25 | ``` 26 | 27 | Please make the necessary revisions to the commit message and code snippet to ensure semantic consistency and clarity. -------------------------------------------------------------------------------- /Example/video-example-1/java__merged__42f249941b687a73c020c11779a511a90cbedb28__20240121005017/meta.txt: -------------------------------------------------------------------------------- 1 | Task: 2 | 3 | I have a code, which includes the commit message, and the corresponding original file, these file are connected like this 4 | code commit message original file. 5 | If there is commit message is null, please don't do Semantic Consistency Analysis. if orignial file is null, please don't do Format Analysis. 6 | I would like a detailed code review based on the following three aspects: 7 | 8 | Semantic Consistency Analysis: 9 | Please analyze the semantic consistency between the code changes in side the code and the commit message. Check if the changes in the codes accurately reflect the description provided in the commit message. Highlight any inconsistencies that might lead to confusion or potential hidden malicious code. 10 | Security Analysis: 11 | Conduct a vulnerability analysis of the code. Identify if any modifications could potentially introduce security vulnerabilities, attacks, or bugs. Provide details of any such findings. 12 | Format Analysis: 13 | Assess if the format of the code aligns with the writing style and format of the original file. Evaluate the impact of any formatting inconsistencies on the overall readability and maintainability of the project. 14 | For each of the above aspects, please provide a clear analysis and any necessary suggestions for improvement. If you find any issues, especially in the code, provide specific suggestions or rewritten code snippets to guide the commit contributor on how to make the necessary revisions. 15 | 16 | 17 | 18 | The final feedback should be structured as follows: 19 | Semantic Consistency Analysis: [Your detailed analysis and suggestions] 20 | Security Analysis: [Your detailed analysis and suggestions] 21 | Format Analysis: [Your detailed analysis and suggestions] 22 | Code Alignment/Revision Suggestions: [Your proposed code revisions for the commit or suggestions, if any] 23 | revised code: [Your revised commit, if any] 24 | @@ -19,7 +19,7 @@ android: 25 | - build-tools-21.1.0 26 | 27 | # The SDK version used to compile your project 28 | - - android-20 29 | + - android-21 30 | 31 | # Specify at least one system image, 32 | # if you need to run emulator(s) during your tests Travis update language: android 33 | 34 | env: 35 | matrix: 36 | - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a 37 | 38 | branches: 39 | only: 40 | - master 41 | 42 | android: 43 | components: 44 | # Uncomment the lines below if you want to 45 | # use the latest revision of Android SDK Tools 46 | - platform-tools 47 | - tools 48 | 49 | # The BuildTools version used by your project 50 | - build-tools-21.1.0 51 | 52 | # The SDK version used to compile your project 53 | - android-21 54 | 55 | # Specify at least one system image, 56 | # if you need to run emulator(s) during your tests 57 | - sys-img-armeabi-v7a-android-19 58 | - sys-img-x86-android-17 59 | 60 | # Emulator Management: Create, Start and Wait 61 | before_script: 62 | - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI 63 | - emulator -avd test -no-skin -no-audio -no-window & 64 | - android-wait-for-emulator 65 | - adb shell input keyevent 82 & 66 | 67 | script: 68 | -./gradlew :lib:connectedAndroidTest 69 | 70 | Config: 71 | ChatAgentConfig.clear_structure: True 72 | ChatAgentConfig.git_management: False 73 | ChatAgentConfig.gui_design: False 74 | ChatAgentConfig.incremental_develop: False 75 | 76 | 77 | Roster: 78 | Chief Executive Officer, Chief Product Officer, Code Reviewer, Recoder, Formator, Programmer, Security Analyst, Counselor, Chief Human Resource Officer, Chief Technology Officer, Software Test Engineer, Chief Creative Officer 79 | 80 | Modality: 81 | document 82 | 83 | Ideas: 84 | 85 | 86 | Language: 87 | Python 88 | 89 | Code_Version: 90 | 6.0 91 | 92 | Proposed_images: 93 | 0 94 | 95 | Incorporated_images: 96 | 0 97 | 98 | -------------------------------------------------------------------------------- /Example/video-example-2/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/video-example-2/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951/manual.md: -------------------------------------------------------------------------------- 1 | Semantic Consistency Analysis: 2 | 3 | In the provided code, the commit message states "Move logic out of ruby and into sql". However, upon analyzing the code changes, it seems that the logic has not been moved from Ruby to SQL as mentioned in the commit message. This inconsistency between the commit message and the actual code changes can lead to confusion for other developers who are reviewing or working on the code. 4 | 5 | To improve the semantic consistency, I suggest revising the code to actually move the logic from Ruby to SQL. This can be done by rewriting the code snippet as follows: 6 | 7 | ```ruby 8 | # Move logic from Ruby to SQL 9 | UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| 10 | # SQL query to update the user role accent 11 | execute("UPDATE user_roles SET user_role_accent = '#{role.color}' WHERE id = #{role.id};") 12 | end 13 | ``` 14 | 15 | By making this change, the code will accurately reflect the intention mentioned in the commit message, making it easier for other developers to understand and maintain the code. 16 | 17 | Security Analysis: 18 | 19 | Upon analyzing the code, I did not find any specific security vulnerabilities or potential attacks. However, it is always recommended to follow secure coding practices to minimize the risk of introducing security vulnerabilities. Some general suggestions for improving code security include: 20 | 21 | 1. Input Validation: Ensure that any user input or external data is properly validated and sanitized before using it in the code. This helps prevent common security vulnerabilities such as SQL injection or cross-site scripting (XSS) attacks. 22 | 23 | 2. Access Control: Implement proper access control mechanisms to restrict unauthorized access to sensitive data or functionalities. This includes enforcing authentication and authorization checks at appropriate points in the code. 24 | 25 | 3. Error Handling: Implement robust error handling mechanisms to handle unexpected situations gracefully and prevent information leakage or system crashes. 26 | 27 | 4. Secure Communication: Use secure protocols (e.g., HTTPS) for transmitting sensitive data over the network to protect against eavesdropping or data tampering. 28 | 29 | Format Analysis: 30 | 31 | The format of the code seems to be inconsistent with the writing style and format of the original file. Inconsistent formatting can make the code harder to read and maintain, especially when multiple developers are working on the same project. It is important to follow a consistent coding style to improve code readability and maintainability. 32 | 33 | To align the code format with the original file, I suggest the following formatting changes: 34 | 35 | ```ruby 36 | <%= raw Setting.custom_css %> 37 | 38 | <%- end %> 39 | 40 | <%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 41 | .user-role-<%= role.id %> { 42 | --user-role-accent: <%= role.color %>; 43 | } 44 | <%- end %> 45 | ``` 46 | 47 | By applying these formatting changes, the code will be more consistent with the original file, making it easier for developers to understand and work with the code. 48 | 49 | Code Alignment/Revision Suggestions: 50 | 51 | Based on the analysis, the following code revisions are proposed: 52 | 53 | ```ruby 54 | # Move logic from Ruby to SQL 55 | UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| 56 | # SQL query to update the user role accent 57 | execute("UPDATE user_roles SET user_role_accent = '#{role.color}' WHERE id = #{role.id};") 58 | end 59 | ``` 60 | 61 | This revised code snippet accurately reflects the intention mentioned in the commit message and aligns with the desired logic change. 62 | 63 | Revised Code: 64 | 65 | ``` 66 | @@ -2,7 +2,7 @@ 67 | <%= raw Setting.custom_css %> 68 | 69 | <%- end %> 70 | -<%- UserRole.where(highlighted: true).select { |role| role.color.present? }.each do |role| %> 71 | +<%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 72 | .user-role-<%= role.id %> { 73 | --user-role-accent: <%= role.color %>; 74 | } 75 | ``` 76 | 77 | The revised code snippet reflects the suggested code revision and aligns with the desired logic change mentioned in the commit message. -------------------------------------------------------------------------------- /Example/video-example-2/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951/meta.txt: -------------------------------------------------------------------------------- 1 | Task: 2 | 3 | I have a code, which includes the commit message, and the corresponding original file, these file are connected like this 4 | code commit message original file. 5 | If there is commit message is null, please don't do Semantic Consistency Analysis. if orignial file is null, please don't do Format Analysis. 6 | I would like a detailed code review based on the following three aspects: 7 | 8 | Semantic Consistency Analysis: 9 | Please analyze the semantic consistency between the code changes in side the code and the commit message. Check if the changes in the codes accurately reflect the description provided in the commit message. Highlight any inconsistencies that might lead to confusion or potential hidden malicious code. 10 | Security Analysis: 11 | Conduct a vulnerability analysis of the code. Identify if any modifications could potentially introduce security vulnerabilities, attacks, or bugs. Provide details of any such findings. 12 | Format Analysis: 13 | Assess if the format of the code aligns with the writing style and format of the original file. Evaluate the impact of any formatting inconsistencies on the overall readability and maintainability of the project. 14 | For each of the above aspects, please provide a clear analysis and any necessary suggestions for improvement. If you find any issues, especially in the code, provide specific suggestions or rewritten code snippets to guide the commit contributor on how to make the necessary revisions. 15 | 16 | 17 | 18 | The final feedback should be structured as follows: 19 | Semantic Consistency Analysis: [Your detailed analysis and suggestions] 20 | Security Analysis: [Your detailed analysis and suggestions] 21 | Format Analysis: [Your detailed analysis and suggestions] 22 | Code Alignment/Revision Suggestions: [Your proposed code revisions for the commit or suggestions, if any] 23 | revised code: [Your revised commit, if any] 24 | @@ -2,7 +2,7 @@ 25 | <%= raw Setting.custom_css %> 26 | 27 | <%- end %> 28 | -<%- UserRole.where(highlighted: true).select { |role| role.color.present? }.each do |role| %> 29 | +<%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 30 | .user-role-<%= role.id %> { 31 | --user-role-accent: <%= role.color %>; 32 | } Move logic out of ruby and into sql <%- if Setting.custom_css.present? %> 33 | <%= raw Setting.custom_css %> 34 | 35 | <%- end %> 36 | <%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 37 | .user-role-<%= role.id %> { 38 | --user-role-accent: <%= role.color %>; 39 | } 40 | 41 | <%- end %> 42 | 43 | 44 | Config: 45 | ChatAgentConfig.clear_structure: True 46 | ChatAgentConfig.git_management: False 47 | ChatAgentConfig.gui_design: False 48 | ChatAgentConfig.incremental_develop: False 49 | 50 | 51 | Roster: 52 | Chief Executive Officer, Chief Product Officer, Code Reviewer, Recoder, Formator, Programmer, Security Analyst, Counselor, Chief Human Resource Officer, Chief Technology Officer, Software Test Engineer, Chief Creative Officer 53 | 54 | Modality: 55 | document 56 | 57 | Ideas: 58 | 59 | 60 | Language: 61 | Python 62 | 63 | Code_Version: 64 | 3.0 65 | 66 | Proposed_images: 67 | 0 68 | 69 | Incorporated_images: 70 | 0 71 | 72 | -------------------------------------------------------------------------------- /Example/video-example-2/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c.prompt: -------------------------------------------------------------------------------- 1 | 2 | I have a code, which includes the commit message, and the corresponding original file, these file are connected like this 3 | code commit message original file. 4 | If there is commit message is null, please don't do Semantic Consistency Analysis. if orignial file is null, please don't do Format Analysis. 5 | I would like a detailed code review based on the following three aspects: 6 | 7 | Semantic Consistency Analysis: 8 | Please analyze the semantic consistency between the code changes in side the code and the commit message. Check if the changes in the codes accurately reflect the description provided in the commit message. Highlight any inconsistencies that might lead to confusion or potential hidden malicious code. 9 | Security Analysis: 10 | Conduct a vulnerability analysis of the code. Identify if any modifications could potentially introduce security vulnerabilities, attacks, or bugs. Provide details of any such findings. 11 | Format Analysis: 12 | Assess if the format of the code aligns with the writing style and format of the original file. Evaluate the impact of any formatting inconsistencies on the overall readability and maintainability of the project. 13 | For each of the above aspects, please provide a clear analysis and any necessary suggestions for improvement. If you find any issues, especially in the code, provide specific suggestions or rewritten code snippets to guide the commit contributor on how to make the necessary revisions. 14 | 15 | 16 | 17 | The final feedback should be structured as follows: 18 | Semantic Consistency Analysis: [Your detailed analysis and suggestions] 19 | Security Analysis: [Your detailed analysis and suggestions] 20 | Format Analysis: [Your detailed analysis and suggestions] 21 | Code Alignment/Revision Suggestions: [Your proposed code revisions for the commit or suggestions, if any] 22 | revised code: [Your revised commit, if any] 23 | @@ -2,7 +2,7 @@ 24 | <%= raw Setting.custom_css %> 25 | 26 | <%- end %> 27 | -<%- UserRole.where(highlighted: true).select { |role| role.color.present? }.each do |role| %> 28 | +<%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 29 | .user-role-<%= role.id %> { 30 | --user-role-accent: <%= role.color %>; 31 | } Move logic out of ruby and into sql <%- if Setting.custom_css.present? %> 32 | <%= raw Setting.custom_css %> 33 | 34 | <%- end %> 35 | <%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 36 | .user-role-<%= role.id %> { 37 | --user-role-accent: <%= role.color %>; 38 | } 39 | 40 | <%- end %> 41 | -------------------------------------------------------------------------------- /Example/video-example-2/ruby__merged__a8dc7cda3f909542374d4fe80afa0d9f3a8dc00c__20240121030951/where.not: -------------------------------------------------------------------------------- 1 | <%= raw Setting.custom_css %> 2 | <%- end %> 3 | <%- UserRole.where(highlighted: true).where.not(color: [nil,'']).each do |role| %> 4 | .user-role-<%= role.id %> { 5 | --user-role-accent: <%= role.color %>; 6 | } -------------------------------------------------------------------------------- /Example/video-exmple-3-security/javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af__20240124011600/ChatChainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": [ 3 | { 4 | "phase": "DemandAnalysis", 5 | "phaseType": "SimplePhase", 6 | "max_turn_step": -1, 7 | "need_reflect": "True" 8 | }, 9 | { 10 | "phase": "LanguageChoose", 11 | "phaseType": "SimplePhase", 12 | "max_turn_step": -1, 13 | "need_reflect": "True" 14 | }, 15 | { 16 | "phase": "CodeCompleteAll", 17 | "phaseType": "ComposedPhase", 18 | "cycleNum": 10, 19 | "Composition": [ 20 | { 21 | "phase": "CodeComplete", 22 | "phaseType": "SimplePhase", 23 | "max_turn_step": 1, 24 | "need_reflect": "False" 25 | } 26 | ] 27 | }, 28 | { 29 | "phase": "CodeReview", 30 | "phaseType": "ComposedPhase", 31 | "cycleNum": 3, 32 | "Composition": [ 33 | { 34 | "phase": "CodeReviewComment", 35 | "phaseType": "SimplePhase", 36 | "max_turn_step": 1, 37 | "need_reflect": "False" 38 | }, 39 | { 40 | "phase": "CodeReviewModification", 41 | "phaseType": "SimplePhase", 42 | "max_turn_step": 1, 43 | "need_reflect": "False" 44 | } 45 | ] 46 | }, 47 | { 48 | "phase": "FormatAnalysis", 49 | "phaseType": "ComposedPhase", 50 | "cycleNum": 3, 51 | "Composition": [ 52 | { 53 | "phase": "FormatSummary", 54 | "phaseType": "SimplePhase", 55 | "max_turn_step": 1, 56 | "need_reflect": "False" 57 | }, 58 | { 59 | "phase": "FormatModification", 60 | "phaseType": "SimplePhase", 61 | "max_turn_step": 1, 62 | "need_reflect": "False" 63 | } 64 | ] 65 | }, 66 | { 67 | "phase": "SecurityTest", 68 | "phaseType": "ComposedPhase", 69 | "cycleNum": 3, 70 | "Composition": [ 71 | { 72 | "phase": "TestVulnerabilitySummary", 73 | "phaseType": "SimplePhase", 74 | "max_turn_step": 1, 75 | "need_reflect": "False" 76 | }, 77 | { 78 | "phase": "TestVunlnerabilityModification", 79 | "phaseType": "SimplePhase", 80 | "max_turn_step": 1, 81 | "need_reflect": "False" 82 | } 83 | ] 84 | }, 85 | { 86 | "phase": "EnvironmentDoc", 87 | "phaseType": "SimplePhase", 88 | "max_turn_step": 1, 89 | "need_reflect": "True" 90 | }, 91 | { 92 | "phase": "Manual", 93 | "phaseType": "SimplePhase", 94 | "max_turn_step": 1, 95 | "need_reflect": "False" 96 | } 97 | ], 98 | "recruitments": [ 99 | "Chief Executive Officer", 100 | "Chief Product Officer", 101 | "Code Reviewer", 102 | "Recoder", 103 | "Formator", 104 | "Programmer", 105 | "Security Analyst", 106 | "Counselor", 107 | "Chief Human Resource Officer", 108 | "Chief Technology Officer", 109 | "Software Test Engineer", 110 | "Chief Creative Officer" 111 | ], 112 | "clear_structure": "True", 113 | "brainstorming": "False", 114 | "gui_design": "False", 115 | "git_management": "False", 116 | "self_improve": "False", 117 | "incremental_develop": "False" 118 | } 119 | -------------------------------------------------------------------------------- /Example/video-exmple-3-security/javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af__20240124011600/client.py: -------------------------------------------------------------------------------- 1 | """ 2 | knox - Client 3 | Copyright(c) 2010 LearnBoost 4 | MIT Licensed 5 | """ 6 | import utils 7 | import auth 8 | import http 9 | import https 10 | import url 11 | import mime 12 | import fs 13 | import crypto 14 | # The max for multi-object delete, bucket listings, etc. 15 | BUCKET_OPS_MAX = 1000 16 | def registerReqListeners(req, fn): 17 | req.on('response', lambda res: fn(None, res)) 18 | req.on('error', fn) 19 | def ensureLeadingSlash(filename): 20 | return '/' + filename if filename[0] != '/' else filename 21 | class Client: 22 | def __init__(self, options): 23 | if 'key' not in options: 24 | raise ValueError('aws "key" required') 25 | if 'secret' not in options: 26 | raise ValueError('aws "secret" required') 27 | if 'bucket' not in options: 28 | raise ValueError('aws "bucket" required') 29 | if options['bucket'] != options['bucket'].lower(): 30 | raise ValueError('AWS bucket names must be all lower case.') 31 | self.endpoint = options['bucket'] + '.s3.amazonaws.com' 32 | self.secure = True 33 | utils.merge(self, options) 34 | self.url = self.https if self.secure else self.http 35 | def request(self, method, filename, headers=None): 36 | options = {'host': self.endpoint} 37 | date = utils.Date() 38 | headers = headers or {} 39 | filename = ensureLeadingSlash(filename) 40 | # Default headers 41 | utils.merge(headers, { 42 | 'Date': date.toUTCString(), 43 | 'Host': self.endpoint 44 | }) 45 | # Authorization header 46 | headers['Authorization'] = auth.authorization({ 47 | 'key': self.key, 48 | 'secret': self.secret, 49 | 'verb': method, 50 | 'date': date, 51 | 'resource': auth.canonicalizeResource('/' + self.bucket + filename), 52 | 'contentType': headers['Content-Type'], 53 | 'md5': headers['Content-MD5'] or '', 54 | 'amazonHeaders': auth.canonicalizeHeaders(headers) 55 | }) 56 | # Issue request 57 | options['method'] = method 58 | options['path'] = filename 59 | options['headers'] = headers 60 | req = (https if self.secure else http).request(options) 61 | req.url = self.url(filename) 62 | return req 63 | def put(self, filename, headers=None): 64 | headers = utils.merge({ 65 | 'Expect': '100-continue', 66 | 'x-amz-acl': 'public-read' 67 | }, headers or {}) 68 | return self.request('PUT', filename, headers) 69 | def putFile(self, src, filename, headers=None, fn=None): 70 | if callable(headers): 71 | fn = headers 72 | headers = {} 73 | stat = fs.stat(src) 74 | headers = utils.merge({ 75 | 'Content-Length': stat.size, 76 | 'Content-Type': mime.lookup(src) 77 | }, headers) 78 | fileStream = fs.createReadStream(src) 79 | self.putStream(fileStream, filename, headers, fn) 80 | def putStream(self, stream, filename, headers=None, fn=None): 81 | req = self.put(filename, headers) 82 | registerReqListeners(req, fn) 83 | stream.on('error', fn) 84 | stream.pipe(req) 85 | def copyFiles(self, sourceFilename, destFilename, headers=None): 86 | headers = headers or {} 87 | # Copy files logic here 88 | # Instantiate the Client class 89 | client = Client({ 90 | 'key': 'your_aws_key', 91 | 'secret': 'your_aws_secret', 92 | 'bucket': 'your_bucket_name' 93 | }) 94 | # Example usage 95 | fs.stat('Readme.md', lambda err, stat: 96 | client.putFile('Readme.md', '/test/Readme.md', { 97 | 'Content-Length': stat.size, 98 | 'Content-Type': 'text/plain' 99 | }, lambda err, res: 100 | print(res.statusCode) 101 | print(res.headers) 102 | ) 103 | ) -------------------------------------------------------------------------------- /Example/video-exmple-3-security/javascript__merged__de00740e21aa6c5371e4a274dd433128bc9aa5af__20240124011600/requirements.txt: -------------------------------------------------------------------------------- 1 | function registerReqListeners(req, fn){ 2 | req.on('response', function(res){ fn(null, res); }); 3 | req.on('error', fn); 4 | } 5 | -------------------------------------------------------------------------------- /PR/README.md: -------------------------------------------------------------------------------- 1 | you can visit data at: https://zenodo.org/records/10607925 -------------------------------------------------------------------------------- /PR/requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # CodeAgent 3 | 4 | ## Full version of source codes, 5 | please visit: https://zenodo.org/records/11666403 6 | 7 | ## Source Code 8 | please visit: https://zenodo.org/records/10607925 9 | 10 | ## Overview 11 | 12 | CodeAgent is a project aimed at demonstrating language-specific functionalities and logging activities for educational or research purposes. This repository contains various scripts and data files organized by programming languages and logs of online activities. 13 | 14 | ## Repository Structure 15 | 16 | ``` 17 | CodeAgent/ 18 | ├── EMNLP-CodeAgent 2/ 19 | │ ├── Languages/ 20 | │ │ ├── c/ 21 | │ │ ├── c#/ 22 | │ │ ├── c++/ 23 | │ │ ├── go/ 24 | │ │ ├── java/ 25 | │ │ ├── javascript/ 26 | │ │ ├── php/ 27 | │ │ ├── python/ 28 | │ │ └── ruby/ 29 | │ ├── online_log/ 30 | │ │ ├── static/ 31 | │ │ │ ├── avatars/ 32 | │ │ │ ├── replay/ 33 | │ │ │ │ ├── css/ 34 | │ │ │ │ └── js/ 35 | │ │ │ └── other files 36 | │ └── ScriptTest/ 37 | │ ├── top_Perl_repos.json 38 | │ ├── codeagent_data.py 39 | │ ├── config.json 40 | │ └── codeagent.log 41 | └── __MACOSX/ 42 | ``` 43 | 44 | ### Languages 45 | This directory contains folders for various programming languages. Each folder includes scripts and examples written in the respective language. 46 | 47 | ### online_log 48 | This directory contains logs of online activities, including static assets such as avatars and replay files. 49 | 50 | ### ScriptTest 51 | This directory contains scripts and data for testing purposes, including a configuration file, a Python data script, and a log file. 52 | 53 | ## Setup 54 | 55 | Before running the scripts, ensure you have the required environment and dependencies set up. 56 | 57 | 1. **Activate Conda Environment**: 58 | ```bash 59 | conda activate CodeAgent_conda_env 60 | ``` 61 | 62 | 2. **Set OpenAI API Key**: 63 | ```bash 64 | export OPENAI_API_KEY="your_openai_api_key" 65 | ``` 66 | 67 | Replace `"your_openai_api_key"` with your actual OpenAI API key. 68 | 69 | ## Usage 70 | 71 | ### Example Command 72 | 73 | To run a script with specific parameters, you can use the following command. This example is shown in `runcopy.sh`. 74 | 75 | ```bash 76 | python3 run.py --ifcode "commit" --name "eccl-codereview" --commit "Diff-CodeAgent4.0/6e3c6d17d943f5ac70b421653eb167e0c34b119f-commit.txt" --commitmessage "Diff-CodeAgent4.0/6e3c6d17d943f5ac70b421653eb167e0c34b119f-message.txt" --originalfile "Diff-CodeAgent4.0/6e3c6d17d943f5ac70b421653eb167e0c34b119f-context.txt" 77 | ``` 78 | 79 | ### Parameters 80 | 81 | - `--ifcode`: Specifies the operation type. In this case, "commit". 82 | - `--name`: Name of the operation or task. 83 | - `--commit`: Path to the commit file. 84 | - `--commitmessage`: Path to the commit message file. 85 | - `--originalfile`: Path to the original file for context. 86 | 87 | ## Requirements 88 | 89 | To run the Python scripts in the `ScriptTest` directory, you need Python installed on your system. Other languages have their respective requirements. 90 | 91 | ## Contributing 92 | 93 | If you would like to contribute to this project, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change. 94 | 95 | ## License 96 | 97 | This project is licensed under the MIT License. See the `LICENSE` file for more details. 98 | -------------------------------------------------------------------------------- /camel/__init__.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | import camel.agents 15 | import camel.configs 16 | import camel.generators 17 | import camel.messages 18 | import camel.prompts 19 | import camel.typing 20 | import camel.utils 21 | 22 | __version__ = '0.1.0' 23 | 24 | __all__ = [ 25 | '__version__', 26 | 'camel', 27 | ] 28 | -------------------------------------------------------------------------------- /camel/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /camel/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /camel/__pycache__/configs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/configs.cpython-37.pyc -------------------------------------------------------------------------------- /camel/__pycache__/configs.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/configs.cpython-39.pyc -------------------------------------------------------------------------------- /camel/__pycache__/generators.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/generators.cpython-39.pyc -------------------------------------------------------------------------------- /camel/__pycache__/model_backend.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/model_backend.cpython-37.pyc -------------------------------------------------------------------------------- /camel/__pycache__/model_backend.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/model_backend.cpython-39.pyc -------------------------------------------------------------------------------- /camel/__pycache__/typing.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/typing.cpython-37.pyc -------------------------------------------------------------------------------- /camel/__pycache__/typing.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/typing.cpython-39.pyc -------------------------------------------------------------------------------- /camel/__pycache__/utils.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/__pycache__/utils.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__init__.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from .base import BaseAgent 15 | from .chat_agent import ChatAgent 16 | from .task_agent import TaskPlannerAgent, TaskSpecifyAgent 17 | from .critic_agent import CriticAgent 18 | from .tool_agents.base import BaseToolAgent 19 | from .tool_agents.hugging_face_tool_agent import HuggingFaceToolAgent 20 | from .embodied_agent import EmbodiedAgent 21 | from .role_playing import RolePlaying 22 | 23 | __all__ = [ 24 | 'BaseAgent', 25 | 'ChatAgent', 26 | 'TaskSpecifyAgent', 27 | 'TaskPlannerAgent', 28 | 'CriticAgent', 29 | 'BaseToolAgent', 30 | 'HuggingFaceToolAgent', 31 | 'EmbodiedAgent', 32 | 'RolePlaying', 33 | ] 34 | -------------------------------------------------------------------------------- /camel/agents/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/base.cpython-37.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/base.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/base.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/chat_agent.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/chat_agent.cpython-37.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/chat_agent.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/chat_agent.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/critic_agent.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/critic_agent.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/embodied_agent.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/embodied_agent.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/role_playing.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/role_playing.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/__pycache__/task_agent.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/__pycache__/task_agent.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/base.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from abc import ABC, abstractmethod 15 | 16 | 17 | class BaseAgent(ABC): 18 | r"""An abstract base class for all CAMEL agents.""" 19 | 20 | @abstractmethod 21 | def reset(self) -> None: 22 | r"""Resets the agent to its initial state.""" 23 | pass 24 | 25 | @abstractmethod 26 | def step(self) -> None: 27 | r"""Performs a single step of the agent.""" 28 | pass 29 | -------------------------------------------------------------------------------- /camel/agents/embodied_agent.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from typing import Any, Dict, List, Optional, Tuple 15 | 16 | from colorama import Fore 17 | 18 | from camel.agents import BaseToolAgent, ChatAgent, HuggingFaceToolAgent 19 | from camel.messages import ChatMessage, SystemMessage 20 | from camel.typing import ModelType 21 | from camel.utils import print_text_animated 22 | 23 | 24 | class EmbodiedAgent(ChatAgent): 25 | r"""Class for managing conversations of CAMEL Embodied Agents. 26 | 27 | Args: 28 | system_message (SystemMessage): The system message for the chat agent. 29 | model (ModelType, optional): The LLM model to use for generating 30 | responses. (default :obj:`ModelType.GPT_4`) 31 | model_config (Any, optional): Configuration options for the LLM model. 32 | (default: :obj:`None`) 33 | message_window_size (int, optional): The maximum number of previous 34 | messages to include in the context window. If `None`, no windowing 35 | is performed. (default: :obj:`None`) 36 | action_space (List[Any], optional): The action space for the embodied 37 | agent. (default: :obj:`None`) 38 | verbose (bool, optional): Whether to print the critic's messages. 39 | logger_color (Any): The color of the logger displayed to the user. 40 | (default: :obj:`Fore.MAGENTA`) 41 | """ 42 | 43 | def __init__( 44 | self, 45 | system_message: SystemMessage, 46 | model: ModelType = ModelType.GPT_4, 47 | model_config: Optional[Any] = None, 48 | message_window_size: Optional[int] = None, 49 | action_space: Optional[List[BaseToolAgent]] = None, 50 | verbose: bool = False, 51 | logger_color: Any = Fore.MAGENTA, 52 | ) -> None: 53 | default_action_space = [ 54 | HuggingFaceToolAgent('hugging_face_tool_agent', model=model.value), 55 | ] 56 | self.action_space = action_space or default_action_space 57 | action_space_prompt = self.get_action_space_prompt() 58 | system_message.content = system_message.content.format( 59 | action_space=action_space_prompt) 60 | self.verbose = verbose 61 | self.logger_color = logger_color 62 | super().__init__( 63 | system_message=system_message, 64 | model=model, 65 | model_config=model_config, 66 | message_window_size=message_window_size, 67 | ) 68 | 69 | def get_action_space_prompt(self) -> str: 70 | r"""Returns the action space prompt. 71 | 72 | Returns: 73 | str: The action space prompt. 74 | """ 75 | return "\n".join([ 76 | f"*** {action.name} ***:\n {action.description}" 77 | for action in self.action_space 78 | ]) 79 | 80 | def step( 81 | self, 82 | input_message: ChatMessage, 83 | ) -> Tuple[ChatMessage, bool, Dict[str, Any]]: 84 | r"""Performs a step in the conversation. 85 | 86 | Args: 87 | input_message (ChatMessage): The input message. 88 | 89 | Returns: 90 | Tuple[ChatMessage, bool, Dict[str, Any]]: A tuple 91 | containing the output messages, termination status, and 92 | additional information. 93 | """ 94 | response = super().step(input_message) 95 | 96 | if response.msgs is None or len(response.msgs) == 0: 97 | raise RuntimeError("Got None output messages.") 98 | if response.terminated: 99 | raise RuntimeError(f"{self.__class__.__name__} step failed.") 100 | 101 | # NOTE: Only single output messages are supported 102 | explanations, codes = response.msg.extract_text_and_code_prompts() 103 | 104 | if self.verbose: 105 | for explanation, code in zip(explanations, codes): 106 | print_text_animated(self.logger_color + 107 | f"> Explanation:\n{explanation}") 108 | print_text_animated(self.logger_color + f"> Code:\n{code}") 109 | 110 | if len(explanations) > len(codes): 111 | print_text_animated(self.logger_color + 112 | f"> Explanation:\n{explanations}") 113 | 114 | content = response.msg.content 115 | 116 | if codes is not None: 117 | content = "\n> Executed Results:" 118 | global_vars = {action.name: action for action in self.action_space} 119 | for code in codes: 120 | executed_outputs = code.execute(global_vars) 121 | content += ( 122 | f"- Python standard output:\n{executed_outputs[0]}\n" 123 | f"- Local variables:\n{executed_outputs[1]}\n") 124 | content += "*" * 50 + "\n" 125 | 126 | # TODO: Handle errors 127 | content = input_message.content + (Fore.RESET + 128 | f"\n> Embodied Actions:\n{content}") 129 | message = ChatMessage(input_message.role_name, input_message.role_type, 130 | input_message.meta_dict, input_message.role, 131 | content) 132 | return message, response.terminated, response.info 133 | -------------------------------------------------------------------------------- /camel/agents/tool_agents/__init__.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from .base import BaseToolAgent 15 | from .hugging_face_tool_agent import HuggingFaceToolAgent 16 | 17 | __all__ = [ 18 | 'BaseToolAgent', 19 | 'HuggingFaceToolAgent', 20 | ] 21 | -------------------------------------------------------------------------------- /camel/agents/tool_agents/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/tool_agents/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/tool_agents/__pycache__/base.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/tool_agents/__pycache__/base.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/tool_agents/__pycache__/hugging_face_tool_agent.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/agents/tool_agents/__pycache__/hugging_face_tool_agent.cpython-39.pyc -------------------------------------------------------------------------------- /camel/agents/tool_agents/base.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from camel.agents import BaseAgent 15 | 16 | 17 | class BaseToolAgent(BaseAgent): 18 | r"""Creates a :obj:`BaseToolAgent` object with the specified name and 19 | description. 20 | 21 | Args: 22 | name (str): The name of the tool agent. 23 | description (str): The description of the tool agent. 24 | """ 25 | 26 | def __init__(self, name: str, description: str) -> None: 27 | 28 | self.name = name 29 | self.description = description 30 | 31 | def __str__(self) -> str: 32 | return f"{self.name}: {self.description}" 33 | -------------------------------------------------------------------------------- /camel/configs.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from dataclasses import dataclass, field 15 | from typing import Dict, Optional, Sequence, Union 16 | 17 | 18 | @dataclass(frozen=True) 19 | class ChatGPTConfig: 20 | r"""Defines the parameters for generating chat completions using the 21 | OpenAI API. 22 | 23 | Args: 24 | temperature (float, optional): Sampling temperature to use, between 25 | :obj:`0` and :obj:`2`. Higher values make the output more random, 26 | while lower values make it more focused and deterministic. 27 | (default: :obj:`0.2`) 28 | top_p (float, optional): An alternative to sampling with temperature, 29 | called nucleus sampling, where the model considers the results of 30 | the tokens with top_p probability mass. So :obj:`0.1` means only 31 | the tokens comprising the top 10% probability mass are considered. 32 | (default: :obj:`1.0`) 33 | n (int, optional): How many chat completion choices to generate for 34 | each input message. ()default: :obj:`1`) 35 | stream (bool, optional): If True, partial message deltas will be sent 36 | as data-only server-sent events as they become available. 37 | (default: :obj:`False`) 38 | stop (str or list, optional): Up to :obj:`4` sequences where the API 39 | will stop generating further tokens. (default: :obj:`None`) 40 | max_tokens (int, optional): The maximum number of tokens to generate 41 | in the chat completion. The total length of input tokens and 42 | generated tokens is limited by the model's context length. 43 | (default: :obj:`None`) 44 | presence_penalty (float, optional): Number between :obj:`-2.0` and 45 | :obj:`2.0`. Positive values penalize new tokens based on whether 46 | they appear in the text so far, increasing the model's likelihood 47 | to talk about new topics. See more information about frequency and 48 | presence penalties. (default: :obj:`0.0`) 49 | frequency_penalty (float, optional): Number between :obj:`-2.0` and 50 | :obj:`2.0`. Positive values penalize new tokens based on their 51 | existing frequency in the text so far, decreasing the model's 52 | likelihood to repeat the same line verbatim. See more information 53 | about frequency and presence penalties. (default: :obj:`0.0`) 54 | logit_bias (dict, optional): Modify the likelihood of specified tokens 55 | appearing in the completion. Accepts a json object that maps tokens 56 | (specified by their token ID in the tokenizer) to an associated 57 | bias value from :obj:`-100` to :obj:`100`. Mathematically, the bias 58 | is added to the logits generated by the model prior to sampling. 59 | The exact effect will vary per model, but values between:obj:` -1` 60 | and :obj:`1` should decrease or increase likelihood of selection; 61 | values like :obj:`-100` or :obj:`100` should result in a ban or 62 | exclusive selection of the relevant token. (default: :obj:`{}`) 63 | user (str, optional): A unique identifier representing your end-user, 64 | which can help OpenAI to monitor and detect abuse. 65 | (default: :obj:`""`) 66 | """ 67 | temperature: float = 0.2 # openai default: 1.0 68 | top_p: float = 1.0 69 | n: int = 1 70 | stream: bool = False 71 | stop: Optional[Union[str, Sequence[str]]] = None 72 | max_tokens: Optional[int] = None 73 | presence_penalty: float = 0.0 74 | frequency_penalty: float = 0.0 75 | logit_bias: Dict = field(default_factory=dict) 76 | user: str = "" 77 | -------------------------------------------------------------------------------- /camel/human.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from typing import Any, Dict, Sequence 15 | 16 | from colorama import Fore 17 | 18 | from camel.messages import ChatMessage 19 | from camel.utils import print_text_animated 20 | 21 | 22 | class Human: 23 | r"""A class representing a human user. 24 | 25 | Args: 26 | name (str): The name of the human user. 27 | (default: :obj:`"Kill Switch Engineer"`). 28 | logger_color (Any): The color of the menu options displayed to the 29 | user. (default: :obj:`Fore.MAGENTA`) 30 | 31 | Attributes: 32 | name (str): The name of the human user. 33 | logger_color (Any): The color of the menu options displayed to the 34 | user. 35 | input_button (str): The text displayed for the input button. 36 | kill_button (str): The text displayed for the kill button. 37 | options_dict (Dict[str, str]): A dictionary containing the options 38 | displayed to the user. 39 | """ 40 | 41 | def __init__(self, name: str = "Kill Switch Engineer", 42 | logger_color: Any = Fore.MAGENTA) -> None: 43 | self.name = name 44 | self.logger_color = logger_color 45 | self.input_button = f"Input by {self.name}." 46 | self.kill_button = "Stop!!!" 47 | self.options_dict: Dict[str, str] = dict() 48 | 49 | def display_options(self, messages: Sequence[ChatMessage]) -> None: 50 | r"""Displays the options to the user. 51 | 52 | Args: 53 | messages (Sequence[ChatMessage]): A list of `ChatMessage` objects. 54 | 55 | Returns: 56 | None 57 | """ 58 | options = [message.content for message in messages] 59 | options.append(self.input_button) 60 | options.append(self.kill_button) 61 | print_text_animated( 62 | self.logger_color + "\n> Proposals from " 63 | f"{messages[0].role_name} ({messages[0].role_type}). " 64 | "Please choose an option:\n") 65 | for index, option in enumerate(options): 66 | print_text_animated( 67 | self.logger_color + 68 | f"\x1b[3mOption {index + 1}:\n{option}\x1b[0m\n") 69 | self.options_dict[str(index + 1)] = option 70 | 71 | def get_input(self) -> str: 72 | r"""Gets the input from the user. 73 | 74 | Returns: 75 | str: The user's input. 76 | """ 77 | while True: 78 | human_input = input( 79 | self.logger_color + 80 | f"Please enter your choice ([1-{len(self.options_dict)}]): ") 81 | print("\n") 82 | if human_input in self.options_dict: 83 | break 84 | print_text_animated(self.logger_color + 85 | "\n> Invalid choice. Please try again.\n") 86 | 87 | return human_input 88 | 89 | def parse_input(self, human_input: str, 90 | meta_chat_message: ChatMessage) -> ChatMessage: 91 | r"""Parses the user's input and returns a `ChatMessage` object. 92 | 93 | Args: 94 | human_input (str): The user's input. 95 | meta_chat_message (ChatMessage): A `ChatMessage` object. 96 | 97 | Returns: 98 | ChatMessage: A `ChatMessage` object. 99 | """ 100 | if self.options_dict[human_input] == self.input_button: 101 | meta_chat_message.content = input(self.logger_color + 102 | "Please enter your message: ") 103 | return meta_chat_message 104 | elif self.options_dict[human_input] == self.kill_button: 105 | exit(self.logger_color + f"Killed by {self.name}.") 106 | else: 107 | meta_chat_message.content = self.options_dict[human_input] 108 | return meta_chat_message 109 | 110 | def step(self, messages: Sequence[ChatMessage]) -> ChatMessage: 111 | r"""Performs one step of the conversation by displaying options to the 112 | user, getting their input, and parsing their choice. 113 | 114 | Args: 115 | messages (Sequence[ChatMessage]): A list of ChatMessage objects. 116 | 117 | Returns: 118 | ChatMessage: A `ChatMessage` object representing the user's choice. 119 | """ 120 | meta_chat_message = ChatMessage( 121 | role_name=messages[0].role_name, 122 | role_type=messages[0].role_type, 123 | meta_dict=messages[0].meta_dict, 124 | role=messages[0].role, 125 | content="", 126 | ) 127 | self.display_options(messages) 128 | human_input = self.get_input() 129 | return self.parse_input(human_input, meta_chat_message) 130 | -------------------------------------------------------------------------------- /camel/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from typing import Dict, Union 15 | 16 | OpenAISystemMessage = Dict[str, str] 17 | OpenAIAssistantMessage = Dict[str, str] 18 | OpenAIUserMessage = Dict[str, str] 19 | OpenAIChatMessage = Union[OpenAIUserMessage, OpenAIAssistantMessage] 20 | OpenAIMessage = Union[OpenAISystemMessage, OpenAIChatMessage] 21 | 22 | from .base import BaseMessage # noqa: E402 23 | from .system_messages import ( # noqa: E402 24 | SystemMessage, AssistantSystemMessage, UserSystemMessage, 25 | ) 26 | from .chat_messages import ( # noqa: E402 27 | ChatMessage, AssistantChatMessage, UserChatMessage, 28 | ) 29 | 30 | MessageType = Union[BaseMessage, SystemMessage, AssistantSystemMessage, 31 | UserSystemMessage, ChatMessage, AssistantChatMessage, 32 | UserChatMessage] 33 | SystemMessageType = Union[SystemMessage, AssistantSystemMessage, 34 | UserSystemMessage] 35 | ChatMessageType = Union[ChatMessage, AssistantChatMessage, UserChatMessage] 36 | 37 | __all__ = [ 38 | 'OpenAISystemMessage', 39 | 'OpenAIAssistantMessage', 40 | 'OpenAIUserMessage', 41 | 'OpenAIChatMessage', 42 | 'OpenAIMessage', 43 | 'BaseMessage', 44 | 'SystemMessage', 45 | 'AssistantSystemMessage', 46 | 'UserSystemMessage', 47 | 'ChatMessage', 48 | 'AssistantChatMessage', 49 | 'UserChatMessage', 50 | 'MessageType', 51 | 'SystemMessageType', 52 | 'ChatMessageType', 53 | ] 54 | -------------------------------------------------------------------------------- /camel/messages/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/base.cpython-37.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/base.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/base.cpython-39.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/chat_messages.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/chat_messages.cpython-37.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/chat_messages.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/chat_messages.cpython-39.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/system_messages.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/system_messages.cpython-37.pyc -------------------------------------------------------------------------------- /camel/messages/__pycache__/system_messages.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/messages/__pycache__/system_messages.cpython-39.pyc -------------------------------------------------------------------------------- /camel/messages/chat_messages.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from dataclasses import dataclass 15 | from typing import Dict, Optional 16 | 17 | from camel.messages import BaseMessage 18 | from camel.typing import RoleType 19 | 20 | 21 | @dataclass 22 | class ChatMessage(BaseMessage): 23 | r"""Base class for chat messages used in CAMEL chat system. 24 | 25 | Args: 26 | role_name (str): The name of the user or assistant role. 27 | role_type (RoleType): The type of role, either 28 | :obj:`RoleType.ASSISTANT` or :obj:`RoleType.USER`. 29 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 30 | for the message. 31 | role (str): The role of the message in OpenAI chat system. 32 | content (str): The content of the message. (default: :obj:`""`) 33 | """ 34 | role_name: str 35 | role_type: RoleType 36 | meta_dict: Optional[Dict[str, str]] 37 | role: str 38 | content: str = "" 39 | 40 | def set_user_role_at_backend(self: BaseMessage): 41 | return self.__class__( 42 | role_name=self.role_name, 43 | role_type=self.role_type, 44 | meta_dict=self.meta_dict, 45 | role="user", 46 | content=self.content, 47 | ) 48 | 49 | 50 | @dataclass 51 | class AssistantChatMessage(ChatMessage): 52 | r"""Class for chat messages from the assistant role used in CAMEL chat 53 | system. 54 | 55 | Attributes: 56 | role_name (str): The name of the assistant role. 57 | role_type (RoleType): The type of role, always 58 | :obj:`RoleType.ASSISTANT`. 59 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 60 | for the message. 61 | role (str): The role of the message in OpenAI chat system. 62 | (default: :obj:`"assistant"`) 63 | content (str): The content of the message. (default: :obj:`""`) 64 | """ 65 | role_name: str 66 | role_type: RoleType = RoleType.ASSISTANT 67 | meta_dict: Optional[Dict[str, str]] = None 68 | role: str = "user" 69 | content: str = "" 70 | 71 | 72 | @dataclass 73 | class UserChatMessage(ChatMessage): 74 | r"""Class for chat messages from the user role used in CAMEL chat system. 75 | 76 | Args: 77 | role_name (str): The name of the user role. 78 | role_type (RoleType): The type of role, always :obj:`RoleType.USER`. 79 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 80 | for the message. 81 | role (str): The role of the message in OpenAI chat system. 82 | (default: :obj:`"user"`) 83 | content (str): The content of the message. (default: :obj:`""`) 84 | """ 85 | role_name: str 86 | role_type: RoleType = RoleType.USER 87 | meta_dict: Optional[Dict[str, str]] = None 88 | role: str = "user" 89 | content: str = "" 90 | -------------------------------------------------------------------------------- /camel/messages/system_messages.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from dataclasses import dataclass 15 | from typing import Dict, Optional 16 | 17 | from camel.messages import BaseMessage 18 | from camel.typing import RoleType 19 | 20 | 21 | @dataclass 22 | class SystemMessage(BaseMessage): 23 | r"""Class for system messages used in CAMEL chat system. 24 | 25 | Args: 26 | role_name (str): The name of the user or assistant role. 27 | role_type (RoleType): The type of role, either 28 | :obj:`RoleType.ASSISTANT` or :obj:`RoleType.USER`. 29 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 30 | for the message. 31 | role (str): The role of the message in OpenAI chat system. 32 | (default: :obj:`"system"`) 33 | content (str): The content of the message. (default: :obj:`""`) 34 | """ 35 | role_name: str 36 | role_type: RoleType 37 | meta_dict: Optional[Dict[str, str]] = None 38 | role: str = "system" 39 | content: str = "" 40 | 41 | 42 | @dataclass 43 | class AssistantSystemMessage(SystemMessage): 44 | r"""Class for system messages from the assistant used in the CAMEL chat 45 | system. 46 | 47 | Args: 48 | role_name (str): The name of the assistant role. 49 | role_type (RoleType): The type of role, always 50 | :obj:`RoleType.ASSISTANT`. 51 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 52 | for the message. 53 | role (str): The role of the message in OpenAI chat system. 54 | (default: :obj:`"system"`) 55 | content (str): The content of the message. (default: :obj:`""`) 56 | """ 57 | role_name: str 58 | role_type: RoleType = RoleType.ASSISTANT 59 | meta_dict: Optional[Dict[str, str]] = None 60 | role: str = "system" 61 | content: str = "" 62 | 63 | 64 | @dataclass 65 | class UserSystemMessage(SystemMessage): 66 | r"""Class for system messages from the user used in the CAMEL chat system. 67 | 68 | Args: 69 | role_name (str): The name of the user role. 70 | role_type (RoleType): The type of role, always :obj:`RoleType.USER`. 71 | meta_dict (Optional[Dict[str, str]]): Additional metadata dictionary 72 | for the message. 73 | role (str): The role of the message in OpenAI chat system. 74 | (default: :obj:`"system"`) 75 | content (str): The content of the message. (default: :obj:`""`) 76 | """ 77 | role_name: str 78 | role_type: RoleType = RoleType.USER 79 | meta_dict: Optional[Dict[str, str]] = None 80 | role: str = "system" 81 | content: str = "" 82 | -------------------------------------------------------------------------------- /camel/model_backend.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from abc import ABC, abstractmethod 15 | from typing import Any, Dict 16 | 17 | import openai 18 | import tiktoken 19 | 20 | from camel.typing import ModelType 21 | # from chatdev.statistics import prompt_cost 22 | # from chatdev.utils import log_and_print_online 23 | from codeagent.statistics import prompt_cost 24 | from codeagent.utils import log_and_print_online 25 | 26 | 27 | class ModelBackend(ABC): 28 | r"""Base class for different model backends. 29 | May be OpenAI API, a local LLM, a stub for unit tests, etc.""" 30 | 31 | @abstractmethod 32 | def run(self, *args, **kwargs) -> Dict[str, Any]: 33 | r"""Runs the query to the backend model. 34 | 35 | Raises: 36 | RuntimeError: if the return value from OpenAI API 37 | is not a dict that is expected. 38 | 39 | Returns: 40 | Dict[str, Any]: All backends must return a dict in OpenAI format. 41 | """ 42 | pass 43 | 44 | 45 | class OpenAIModel(ModelBackend): 46 | r"""OpenAI API in a unified ModelBackend interface.""" 47 | 48 | def __init__(self, model_type: ModelType, model_config_dict: Dict) -> None: 49 | super().__init__() 50 | self.model_type = model_type 51 | self.model_config_dict = model_config_dict 52 | 53 | def run(self, *args, **kwargs) -> Dict[str, Any]: 54 | string = "\n".join([message["content"] for message in kwargs["messages"]]) 55 | encoding = tiktoken.encoding_for_model(self.model_type.value) 56 | num_prompt_tokens = len(encoding.encode(string)) 57 | gap_between_send_receive = 15 * len(kwargs["messages"]) 58 | num_prompt_tokens += gap_between_send_receive 59 | 60 | num_max_token_map = { 61 | "gpt-3.5-turbo": 4096, 62 | "gpt-3.5-turbo-16k": 16384, 63 | "gpt-3.5-turbo-0613": 4096, 64 | "gpt-3.5-turbo-16k-0613": 16384, 65 | "gpt-4": 8192, 66 | "gpt-4-0613": 8192, 67 | "gpt-4-32k": 32768, 68 | } 69 | num_max_token = num_max_token_map[self.model_type.value] 70 | num_max_completion_tokens = num_max_token - num_prompt_tokens 71 | self.model_config_dict['max_tokens'] = num_max_completion_tokens 72 | 73 | try: 74 | response = openai.ChatCompletion.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict) 75 | except AttributeError: 76 | response = openai.chat.completions.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict) 77 | 78 | cost = prompt_cost( 79 | self.model_type.value, 80 | num_prompt_tokens=response["usage"]["prompt_tokens"], 81 | num_completion_tokens=response["usage"]["completion_tokens"] 82 | ) 83 | 84 | log_and_print_online( 85 | "**[OpenAI_Usage_Info Receive]**\nprompt_tokens: {}\ncompletion_tokens: {}\ntotal_tokens: {}\ncost: ${:.6f}\n".format( 86 | response["usage"]["prompt_tokens"], response["usage"]["completion_tokens"], 87 | response["usage"]["total_tokens"], cost)) 88 | if not isinstance(response, Dict): 89 | raise RuntimeError("Unexpected return from OpenAI API") 90 | return response 91 | 92 | 93 | class StubModel(ModelBackend): 94 | r"""A dummy model used for unit tests.""" 95 | 96 | def __init__(self, *args, **kwargs) -> None: 97 | super().__init__() 98 | 99 | def run(self, *args, **kwargs) -> Dict[str, Any]: 100 | ARBITRARY_STRING = "Lorem Ipsum" 101 | 102 | return dict( 103 | id="stub_model_id", 104 | usage=dict(), 105 | choices=[ 106 | dict(finish_reason="stop", 107 | message=dict(content=ARBITRARY_STRING, role="assistant")) 108 | ], 109 | ) 110 | 111 | 112 | class ModelFactory: 113 | r"""Factory of backend models. 114 | 115 | Raises: 116 | ValueError: in case the provided model type is unknown. 117 | """ 118 | 119 | @staticmethod 120 | def create(model_type: ModelType, model_config_dict: Dict) -> ModelBackend: 121 | default_model_type = ModelType.GPT_3_5_TURBO 122 | 123 | if model_type in { 124 | ModelType.GPT_3_5_TURBO, ModelType.GPT_4, ModelType.GPT_4_32k, 125 | None 126 | }: 127 | model_class = OpenAIModel 128 | elif model_type == ModelType.STUB: 129 | model_class = StubModel 130 | else: 131 | raise ValueError("Unknown model") 132 | 133 | if model_type is None: 134 | model_type = default_model_type 135 | 136 | # log_and_print_online("Model Type: {}".format(model_type)) 137 | inst = model_class(model_type, model_config_dict) 138 | return inst 139 | -------------------------------------------------------------------------------- /camel/prompts/__init__.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from .base import TextPrompt, CodePrompt, TextPromptDict 15 | from .task_prompt_template import TaskPromptTemplateDict 16 | from .prompt_templates import PromptTemplateGenerator 17 | 18 | __all__ = [ 19 | 'TextPrompt', 20 | 'TextPromptDict', 21 | 'TaskPromptTemplateDict', 22 | 'PromptTemplateGenerator', 23 | ] 24 | -------------------------------------------------------------------------------- /camel/prompts/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/base.cpython-37.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/base.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/base.cpython-39.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/prompt_templates.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/prompt_templates.cpython-37.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/prompt_templates.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/prompt_templates.cpython-39.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/task_prompt_template.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/task_prompt_template.cpython-37.pyc -------------------------------------------------------------------------------- /camel/prompts/__pycache__/task_prompt_template.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/camel/prompts/__pycache__/task_prompt_template.cpython-39.pyc -------------------------------------------------------------------------------- /camel/prompts/prompt_templates.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | import warnings 15 | from typing import Any, Optional 16 | 17 | from camel.prompts import TaskPromptTemplateDict, TextPrompt 18 | from camel.typing import RoleType, TaskType 19 | 20 | 21 | class PromptTemplateGenerator: 22 | r"""A class for generating prompt templates for tasks. 23 | 24 | Args: 25 | task_prompt_template_dict (TaskPromptTemplateDict, optional): 26 | A dictionary of task prompt templates for each task type. If not 27 | provided, an empty dictionary is used as default. 28 | """ 29 | 30 | def __init__( 31 | self, 32 | task_prompt_template_dict: Optional[TaskPromptTemplateDict] = None, 33 | ) -> None: 34 | self.task_prompt_template_dict = (task_prompt_template_dict or TaskPromptTemplateDict()) 35 | 36 | def get_prompt_from_key(self, task_type: TaskType, key: Any) -> TextPrompt: 37 | r"""Generates a text prompt using the specified :obj:`task_type` and 38 | :obj:`key`. 39 | 40 | Args: 41 | task_type (TaskType): The type of task. 42 | key (Any): The key used to generate the prompt. 43 | 44 | Returns: 45 | TextPrompt: The generated text prompt. 46 | 47 | Raises: 48 | KeyError: If failed to generate prompt using the specified 49 | :obj:`task_type` and :obj:`key`. 50 | """ 51 | try: 52 | print(task_type, key) 53 | return self.task_prompt_template_dict[task_type][key] 54 | 55 | except KeyError: 56 | raise KeyError("Failed to get generate prompt template for " 57 | f"task: {task_type.value} from key: {key}.") 58 | 59 | def get_system_prompt( 60 | self, 61 | task_type: TaskType, 62 | role_type: RoleType, 63 | ) -> TextPrompt: 64 | r"""Generates a text prompt for the system role, using the specified 65 | :obj:`task_type` and :obj:`role_type`. 66 | 67 | Args: 68 | task_type (TaskType): The type of task. 69 | role_type (RoleType): The type of role, either "USER" or 70 | "ASSISTANT". 71 | 72 | Returns: 73 | TextPrompt: The generated text prompt. 74 | 75 | Raises: 76 | KeyError: If failed to generate prompt using the specified 77 | :obj:`task_type` and :obj:`role_type`. 78 | """ 79 | try: 80 | return self.get_prompt_from_key(task_type, role_type) 81 | 82 | except KeyError: 83 | prompt = "You are a helpful assistant." 84 | 85 | warnings.warn("Failed to get system prompt template for " 86 | f"task: {task_type.value}, role: {role_type.value}. " 87 | f"Set template to: {prompt}") 88 | 89 | return TextPrompt(prompt) 90 | 91 | def get_generate_tasks_prompt( 92 | self, 93 | task_type: TaskType, 94 | ) -> TextPrompt: 95 | r"""Gets the prompt for generating tasks for a given task type. 96 | 97 | Args: 98 | task_type (TaskType): The type of the task. 99 | 100 | Returns: 101 | TextPrompt: The generated prompt for generating tasks. 102 | """ 103 | return self.get_prompt_from_key(task_type, "generate_tasks") 104 | 105 | def get_task_specify_prompt( 106 | self, 107 | task_type: TaskType, 108 | ) -> TextPrompt: 109 | r"""Gets the prompt for specifying a task for a given task type. 110 | 111 | Args: 112 | task_type (TaskType): The type of the task. 113 | 114 | Returns: 115 | TextPrompt: The generated prompt for specifying a task. 116 | """ 117 | return self.get_prompt_from_key(task_type, "task_specify_prompt") 118 | -------------------------------------------------------------------------------- /camel/prompts/task_prompt_template.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from typing import Any, Dict 15 | 16 | from camel.prompts import ( 17 | TextPromptDict, 18 | ) 19 | from camel.typing import TaskType 20 | 21 | 22 | class TaskPromptTemplateDict(Dict[Any, TextPromptDict]): 23 | r"""A dictionary (:obj:`Dict[Any, TextPromptDict]`) of task prompt 24 | templates keyed by task type. This dictionary is used to map from 25 | a task type to its corresponding prompt template dictionary. 26 | 27 | Args: 28 | *args: Positional arguments passed to the :obj:`dict` constructor. 29 | **kwargs: Keyword arguments passed to the :obj:`dict` constructor. 30 | """ 31 | 32 | def __init__(self, *args: Any, **kwargs: Any) -> None: 33 | super().__init__(*args, **kwargs) 34 | self.update({ 35 | TaskType.AI_SOCIETY: AISocietyPromptTemplateDict(), 36 | TaskType.CODE: CodePromptTemplateDict(), 37 | TaskType.MISALIGNMENT: MisalignmentPromptTemplateDict(), 38 | TaskType.TRANSLATION: TranslationPromptTemplateDict(), 39 | TaskType.EVALUATION: EvaluationPromptTemplateDict(), 40 | TaskType.SOLUTION_EXTRACTION: SolutionExtractionPromptTemplateDict(), 41 | }) 42 | -------------------------------------------------------------------------------- /camel/typing.py: -------------------------------------------------------------------------------- 1 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 2 | # Licensed under the Apache License, Version 2.0 (the “License”); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an “AS IS” BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== 14 | from enum import Enum 15 | 16 | 17 | class TaskType(Enum): 18 | AI_SOCIETY = "ai_society" 19 | CODE = "code" 20 | MISALIGNMENT = "misalignment" 21 | TRANSLATION = "translation" 22 | EVALUATION = "evaluation" 23 | SOLUTION_EXTRACTION = "solution_extraction" 24 | CHATDEV = "chat_agent" 25 | DEFAULT = "default" 26 | 27 | 28 | class RoleType(Enum): 29 | ASSISTANT = "assistant" 30 | USER = "user" 31 | CRITIC = "critic" 32 | EMBODIMENT = "embodiment" 33 | DEFAULT = "default" 34 | CHATDEV = "AgentTech" 35 | CHATDEV_COUNSELOR = "counselor" 36 | CHATDEV_CEO = "chief executive officer (CEO)" 37 | CHATDEV_CPO = "chief product officer (CPO)" 38 | CHATDEV_RECODER = "recorder" 39 | CHATDEV_PROGRAMMER = "programmer" 40 | CHATDEV_REVIEWER = "code reviewer" 41 | CHATDEV_SECURITY = "vulnerability analyst" 42 | CHATDEV_FORMAT = "code format analyst" 43 | CHATDEV_CHRO = "chief human resource officer (CHRO)" 44 | CHATDEV_CTO = "chief technology officer (CTO)" 45 | CHATDEV_TESTER = "software test engineer" 46 | CHATDEV_CCO = "chief creative officer (CCO)" 47 | 48 | 49 | class ModelType(Enum): 50 | GPT_3_5_TURBO = "gpt-3.5-turbo-16k-0613" 51 | GPT_4 = "gpt-4" 52 | GPT_4_32k = "gpt-4-32k" 53 | STUB = "stub" 54 | 55 | @property 56 | def value_for_tiktoken(self): 57 | return self.value if self.name != "STUB" else "gpt-3.5-turbo-16k-0613" 58 | 59 | 60 | class PhaseType(Enum): 61 | REFLECTION = "reflection" 62 | RECRUITING_CHRO = "recruiting CHRO" 63 | RECRUITING_CPO = "recruiting CPO" 64 | RECRUITING_CTO = "recruiting CTO" 65 | DEMAND_ANALYSIS = "demand analysis" 66 | CHOOSING_LANGUAGE = "choosing language" 67 | RECRUITING_PROGRAMMER = "recruiting programmer" 68 | RECRUITING_REVIEWER = "recruiting reviewer" 69 | RECRUITING_TESTER = "recruiting software test engineer" 70 | RECRUITING_CCO = "recruiting chief creative officer" 71 | CODING = "coding" 72 | CODING_COMPLETION = "coding completion" 73 | CODING_AUTOMODE = "coding auto mode" 74 | REVIEWING_COMMENT = "review comment" 75 | REVIEWING_MODIFICATION = "code modification after reviewing" 76 | ERROR_SUMMARY = "error summary" 77 | MODIFICATION = "code modification" 78 | ART_ELEMENT_ABSTRACTION = "art element abstraction" 79 | ART_ELEMENT_INTEGRATION = "art element integration" 80 | CREATING_ENVIRONMENT_DOCUMENT = "environment document" 81 | CREATING_USER_MANUAL = "user manual" 82 | 83 | 84 | __all__ = ["TaskType", "RoleType", "ModelType", "PhaseType"] 85 | -------------------------------------------------------------------------------- /online_log/__pycache__/app.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/__pycache__/app.cpython-39.pyc -------------------------------------------------------------------------------- /online_log/app.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import requests 3 | import os 4 | from flask import Flask 5 | from flask import send_from_directory 6 | from flask import request 7 | from flask import jsonify 8 | import argparse 9 | 10 | app = Flask(__name__, static_folder='static') 11 | app.logger.setLevel(logging.ERROR) 12 | log = logging.getLogger('werkzeug') 13 | log.setLevel(logging.ERROR) 14 | messages = [] 15 | port = [8000] 16 | 17 | def send_msg(role, text): 18 | try: 19 | data = {"role": role, "text": text} 20 | response = requests.post(f"http://127.0.0.1:{port[-1]}/send_message", json=data) 21 | except: 22 | logging.info("flask app.py did not start for online log") 23 | 24 | 25 | @app.route("/") 26 | def index(): 27 | return send_from_directory("static", "index.html") 28 | 29 | 30 | @app.route("/chain_visualizer") 31 | def chain_visualizer(): 32 | return send_from_directory("static", "chain_visualizer.html") 33 | 34 | 35 | @app.route("/replay") 36 | def replay(): 37 | return send_from_directory("static", "replay.html") 38 | 39 | 40 | @app.route("/get_messages") 41 | def get_messages(): 42 | return jsonify(messages) 43 | 44 | 45 | @app.route("/send_message", methods=["POST"]) 46 | def send_message(): 47 | data = request.get_json() 48 | role = data.get("role") 49 | text = data.get("text") 50 | 51 | avatarUrl = find_avatar_url(role) 52 | 53 | message = {"role": role, "text": text, "avatarUrl": avatarUrl} 54 | messages.append(message) 55 | return jsonify(message) 56 | 57 | 58 | def find_avatar_url(role): 59 | role = role.replace(" ", "%20") 60 | avatar_filename = f"avatars/{role}.png" 61 | avatar_url = f"/static/{avatar_filename}" 62 | return avatar_url 63 | 64 | 65 | if __name__ == "__main__": 66 | parser = argparse.ArgumentParser(description='argparse') 67 | parser.add_argument('--port', type=int, default=8000, help="port") 68 | args = parser.parse_args() 69 | port.append(args.port) 70 | print(f"Please visit http://127.0.0.1:{port[-1]}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).") 71 | app.run(host='0.0.0.0', debug=False, port=port[-1]) 72 | -------------------------------------------------------------------------------- /online_log/static/avatars/Chief Creative Officer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Chief Creative Officer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Chief Executive Officer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Chief Executive Officer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Chief Human Resource Officer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Chief Human Resource Officer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Chief Product Officer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Chief Product Officer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Chief Technology Officer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Chief Technology Officer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Code Reviewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Code Reviewer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Counselor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Counselor.png -------------------------------------------------------------------------------- /online_log/static/avatars/Programmer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Programmer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Prompt Engineer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Prompt Engineer.png -------------------------------------------------------------------------------- /online_log/static/avatars/Software Test Engineer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/Software Test Engineer.png -------------------------------------------------------------------------------- /online_log/static/avatars/System.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/System.png -------------------------------------------------------------------------------- /online_log/static/avatars/User.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/avatars/User.png -------------------------------------------------------------------------------- /online_log/static/css/style.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 20px; 3 | margin-bottom: 20px; 4 | width: 2500px; 5 | height: 700px; 6 | border: 1px solid black; 7 | overflow-y: scroll; 8 | background-color: white; 9 | position: relative; 10 | } 11 | 12 | .message-container { 13 | position: relative; 14 | display: flex; 15 | margin: 20px; 16 | max-width: 95%; 17 | word-wrap: break-word; 18 | padding-top: 0px; /* Add space for the button */ 19 | } 20 | 21 | 22 | .message-text { 23 | background-color: #D2D4D3; 24 | border-radius: 10px; 25 | padding: 8px; 26 | margin-left: 40px; 27 | font-size: 10px; 28 | width: 100%; 29 | } 30 | 31 | .avatar { 32 | width: 40px; 33 | height: 40px; 34 | border-radius: 50%; 35 | position: absolute; 36 | top: 0px; 37 | left: -30px; 38 | margin-left: 20px; 39 | background-color: green; 40 | background-size: cover; 41 | } 42 | 43 | .role { 44 | font-size: 12px; 45 | font-weight: bold; 46 | position: absolute; 47 | bottom: 0; 48 | top: -30px; 49 | margin-top: 10px; 50 | margin-left: 40px; 51 | } 52 | 53 | .code-block pre { 54 | margin: 0; 55 | } 56 | 57 | .dark { 58 | color: #000000; 59 | } 60 | 61 | .line-numbers .line-numbers-rows { 62 | border-right-color: #44475a; 63 | display: block; /* Add this to ensure line numbers are displayed */ 64 | } 65 | 66 | .code-block-header { 67 | background-color: #5b5656; 68 | color: #ffffff; 69 | padding: 5px; 70 | font-size: 14px; 71 | font-weight: bold; 72 | } 73 | 74 | 75 | .code-block { 76 | background-color: #000000 !important; 77 | border-radius: 4px; 78 | margin-top: 10px; 79 | position: relative; 80 | overflow: hidden; 81 | color: #000000; /* Add text color for syntax highlighting */ 82 | } 83 | 84 | table { 85 | border-collapse: collapse; 86 | width: 100%; 87 | } 88 | 89 | th, td { 90 | border: 1px solid black; 91 | padding: 8px; 92 | text-align: left; 93 | white-space: pre-line; 94 | } 95 | 96 | .expand-button { 97 | position: absolute; 98 | top: 3px; 99 | right: 65px; 100 | border-radius: 4px; 101 | background-color: #95A1A1; 102 | color: #f8f8f2; 103 | border: none; 104 | padding: 5px; 105 | cursor: pointer; 106 | font-size: 8px; 107 | width: 50px; 108 | height: 20px; 109 | line-height: 10px; 110 | font-weight: bold; 111 | } 112 | 113 | .expand-button:hover { 114 | background-color: #6B9297; 115 | } 116 | 117 | .copy-button { 118 | position: absolute; 119 | top: 3px; 120 | right: 3px; 121 | background-color: #A9A9A7; 122 | color: #f8f8f2; 123 | border: none; 124 | padding: 5px 10px; 125 | border-radius: 4px; 126 | cursor: pointer; 127 | width: 55px; 128 | height: 20px; 129 | line-height: 10px; 130 | font-size: 8px; 131 | font-weight: bold; 132 | transition: background-color 0.3s ease; 133 | } 134 | 135 | 136 | #filebutton { 137 | background-image: linear-gradient(to right, #a18cd1, #fbc2eb); /* 从左到右的紫色渐变 */ 138 | color: white; /* 按钮文字颜色 */ 139 | border: none; /* 移除边框 */ 140 | padding: 10px 20px; /* 内边距 */ 141 | border-radius: 5px; /* 圆角效果 */ 142 | cursor: pointer; /* 鼠标悬停时的手形指针 */ 143 | transition: background-color 0.3s; /* 平滑过渡效果 */ 144 | } 145 | 146 | #filebutton:hover { 147 | background-image: linear-gradient(to left, #a18cd1, #fbc2eb); /* 鼠标悬停时改变渐变方向 */ 148 | } 149 | .file-and-progress-container { 150 | position: relative; 151 | top: 140px; 152 | display: flex; 153 | flex-direction: column; 154 | align-items: center; 155 | } 156 | .copy-button:hover { 157 | background-color: #866753; 158 | } 159 | 160 | .upload-and-progress-buttons { 161 | /* 样式以保持按钮组整洁 */ 162 | display: flex; 163 | justify-content: space-around; 164 | padding-bottom: 20px; /* 或根据需要调整 */ 165 | } 166 | 167 | #humanRequest, #dialogBody { 168 | /* 样式以适应新位置 */ 169 | margin-top: 20px; /* 或根据需要调整 */ 170 | } 171 | -------------------------------------------------------------------------------- /online_log/static/figures/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/background.png -------------------------------------------------------------------------------- /online_log/static/figures/ceo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/ceo.png -------------------------------------------------------------------------------- /online_log/static/figures/chatdev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/chatdev.png -------------------------------------------------------------------------------- /online_log/static/figures/company.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/company.png -------------------------------------------------------------------------------- /online_log/static/figures/counselor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/counselor.png -------------------------------------------------------------------------------- /online_log/static/figures/cpo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/cpo.png -------------------------------------------------------------------------------- /online_log/static/figures/cto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/cto.png -------------------------------------------------------------------------------- /online_log/static/figures/designer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/designer.png -------------------------------------------------------------------------------- /online_log/static/figures/game.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/game.jpg -------------------------------------------------------------------------------- /online_log/static/figures/hr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/hr.png -------------------------------------------------------------------------------- /online_log/static/figures/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/left.png -------------------------------------------------------------------------------- /online_log/static/figures/pe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/pe.png -------------------------------------------------------------------------------- /online_log/static/figures/programmer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/programmer.png -------------------------------------------------------------------------------- /online_log/static/figures/reviewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/reviewer.png -------------------------------------------------------------------------------- /online_log/static/figures/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/right.png -------------------------------------------------------------------------------- /online_log/static/figures/tester.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/tester.png -------------------------------------------------------------------------------- /online_log/static/figures/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/title.png -------------------------------------------------------------------------------- /online_log/static/figures/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Code4Agent/codeagent/e61f419affcaec6ccde63d63e894bcb06bedcc60/online_log/static/figures/user.png -------------------------------------------------------------------------------- /online_log/static/js/main.js: -------------------------------------------------------------------------------- 1 | function append_message(role, text, avatarUrl) { 2 | 3 | var message_container = $("
").addClass("message-container"); 4 | var avatar_element = $("").addClass("avatar"); 5 | var role_element = $("

").addClass("role").text(role); 6 | 7 | if (avatarUrl) { 8 | avatar_element.css("background-image", `url(${avatarUrl})`); 9 | } else { 10 | avatar_element.css("background-color", "green"); 11 | } 12 | 13 | message_container.append(role_element); 14 | message_container.append(avatar_element); 15 | 16 | 17 | var parsedText = role === 'System' ? parseSystemMessage(text) : parseCodeBlocks(text, role); 18 | 19 | message_container.append(parsedText); 20 | 21 | var copyButton = $("") 22 | .addClass("copy-button") 23 | .text("Copy") 24 | .click(function () { 25 | copyToClipboard(parsedText); // Call the copyToClipboard function 26 | }); 27 | 28 | copyButton.click(function () { 29 | copyToClipboard(parsedText); 30 | copyButton.text("Copied"); 31 | setTimeout(function () { 32 | copyButton.text("Copy"); 33 | }, 5000); 34 | }); 35 | 36 | message_container.append(copyButton); // Append the copy button 37 | 38 | $("#chat-box").append(message_container); 39 | } 40 | 41 | function parseCodeBlocks(text, role) { 42 | var parts = text.split(/(```[\s\S]*?```)/g); 43 | var parsedText = $("
").addClass("message-text"); 44 | parts.forEach(part => { 45 | if (part.startsWith("```") && role != "System") { 46 | var trimmedBlock = part.trim(); 47 | var language = trimmedBlock.match(/^```(\w+)/); 48 | if (language) { 49 | language = language[1]; 50 | var codeContent = trimmedBlock.replace(/^```(\w+)/, '').replace(/```$/, ''); 51 | var codeBlockHTML = ` 52 |
53 |
${role} - ${language}
54 |
${hljs.highlightAuto(codeContent, [language]).value}
55 |
56 | `; 57 | parsedText.append(codeBlockHTML); 58 | } 59 | } else { 60 | parsedText.append(marked(_.escape(part), {breaks: true})); 61 | } 62 | }); 63 | return parsedText; 64 | } 65 | 66 | 67 | function get_new_messages() { 68 | 69 | $.getJSON("/get_messages", function (data) { 70 | var lastDisplayedMessageIndex = $("#chat-box .message-container").length; 71 | 72 | for (var i = lastDisplayedMessageIndex; i < data.length; i++) { 73 | var role = data[i].role; 74 | var text = data[i].text; 75 | var avatarUrl = data[i].avatarUrl; 76 | 77 | append_message(role, text, avatarUrl); 78 | 79 | } 80 | }); 81 | } 82 | 83 | function parseSystemMessage(text) { 84 | var message = $("
").addClass("message-text").addClass("system-message"); 85 | var firstLine = text.split('\n')[0]; 86 | var collapsed = true; 87 | 88 | var messageContent = $("
").html(marked(firstLine, { breaks: true })).addClass("original-markdown"); 89 | var originalMarkdown = $("
").html(marked(text, { breaks: true })).addClass("original-markdown"); 90 | 91 | var expandButton = $("") 92 | .addClass("expand-button") 93 | .text("Expand") 94 | .click(function () { 95 | if (collapsed) { 96 | messageContent.hide(); 97 | originalMarkdown.show(); 98 | expandButton.text("Collapse"); 99 | } else { 100 | messageContent.show(); 101 | originalMarkdown.hide(); 102 | expandButton.text("Expand"); 103 | } 104 | collapsed = !collapsed; 105 | }); 106 | 107 | message.append(messageContent); 108 | message.append(originalMarkdown); 109 | message.append(expandButton); 110 | 111 | originalMarkdown.hide(); 112 | 113 | return message; 114 | } 115 | 116 | function copyToClipboard(element) { 117 | // Create a temporary textarea element to hold the text 118 | var tempTextArea = document.createElement("textarea"); 119 | tempTextArea.value = element.text(); 120 | document.body.appendChild(tempTextArea); 121 | 122 | // Select and copy the text from the textarea 123 | tempTextArea.select(); 124 | document.execCommand("copy"); 125 | 126 | // Remove the temporary textarea 127 | document.body.removeChild(tempTextArea); 128 | } 129 | 130 | 131 | 132 | $(document).ready(function () { 133 | get_new_messages(); 134 | setInterval(function () { 135 | get_new_messages(); 136 | }, 1000); 137 | }); 138 | 139 | 140 | -------------------------------------------------------------------------------- /online_log/static/replay.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | CodeAgent 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 20 |

21 | Autonomous Communicative Code Agents for Code Review

22 |
23 |
24 | 25 |
26 | 27 |
28 |
29 | 30 |
31 |
32 |
33 | 34 |
35 |

Progress:

36 |
37 |
39 |
40 | 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /online_log/static/replay/css/use.css: -------------------------------------------------------------------------------- 1 | p, 2 | div, 3 | label { 4 | font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; 5 | } 6 | 7 | body { 8 | background-color: #23252c; 9 | } 10 | 11 | .button { 12 | padding: 16px 15px; 13 | background: #e2edf0; 14 | color: #0b0c0c; 15 | font-weight: 800; 16 | font-size: 16px; 17 | cursor: pointer; 18 | height: 80px; 19 | box-shadow: 1px 2px 2px #505757; 20 | border-radius: 20px; 21 | border: #020202; 22 | margin: 10px 0; 23 | } 24 | 25 | .blinking-animation { 26 | width: 25px; 27 | height: 25px; 28 | animation: blink 1s ease infinite; 29 | } 30 | 31 | @keyframes blink { 32 | 0%, 33 | 100% { 34 | opacity: 1; 35 | } 36 | 50% { 37 | opacity: 0; 38 | } 39 | } 40 | 41 | #filebutton { 42 | position: relative; 43 | left: 50px; 44 | } 45 | 46 | .file-and-progress-container { 47 | position: relative; 48 | top: 140px; 49 | display: flex; 50 | flex-direction: column; 51 | align-items: center; 52 | } 53 | 54 | #filebutton, #replay { 55 | width: 100%; /* 确保按钮宽度一致 */ 56 | margin: 10px 0; /* 为按钮添加上下间距 */ 57 | /* 移除特定位置样式 */ 58 | } 59 | 60 | 61 | #title>p { 62 | font-size: 30px; 63 | color: #fefefe; 64 | text-shadow: 0 0 0.5em #0ae642, 0 0 0.2em #5c5c5c; 65 | } 66 | 67 | #replay { 68 | position: relative; 69 | left: 340px; 70 | width: 100px; 71 | } 72 | 73 | #successupload { 74 | position: absolute; 75 | top: 730px; 76 | left: 200px; 77 | color: antiquewhite; 78 | display: none; 79 | } 80 | 81 | #successupload>p { 82 | position: relative; 83 | left: 20px; 84 | } 85 | 86 | #fileInput { 87 | display: none; 88 | } 89 | 90 | #humanRequest { 91 | background-color: rgb(30, 39, 46); 92 | border: 1px solid #ffffff; 93 | border-radius: 10px; 94 | box-shadow: 3px 3px 4px black; 95 | } 96 | 97 | #dialogBody, 98 | #dialogStatistic { 99 | width: 790px; 100 | height: 570px; 101 | background-color: rgb(255, 255, 255); 102 | border: 1px solid #ccc; 103 | border-radius: 10px; 104 | box-shadow: 3px 3px 4px black; 105 | overflow: auto; 106 | padding: 20px; 107 | float: right; 108 | position: relative; 109 | margin-left: auto; 110 | top: 10px; 111 | } 112 | 113 | #speed { 114 | position: relative; 115 | width: 600px; 116 | top: 35px; 117 | right: -150px; 118 | } 119 | 120 | #speedcontrol>label { 121 | display: block; 122 | position: relative; 123 | top: 15px; 124 | width: 200px; 125 | color: aliceblue; 126 | font-size: medium; 127 | font-weight: bold; 128 | } 129 | 130 | [type="range"] { 131 | -webkit-appearance: none; 132 | appearance: none; 133 | margin: 0; 134 | outline: 0; 135 | background-color: transparent; 136 | width: 600px; 137 | } 138 | 139 | [type="range"]::-webkit-slider-runnable-track { 140 | height: 4px; 141 | background: #eee; 142 | } 143 | 144 | [type="range" i]::-webkit-slider-container { 145 | height: 25px; 146 | overflow: hidden; 147 | } 148 | 149 | [type="range"]::-webkit-slider-thumb { 150 | -webkit-appearance: none; 151 | appearance: none; 152 | width: 20px; 153 | height: 20px; 154 | border-radius: 30%; 155 | background-color: #ffffff; 156 | border: 1px solid transparent; 157 | margin-top: -8px; 158 | border-image: linear-gradient(#133163, #133163) 0 fill / 8 20 8 0 / 0px 0px 0 2000px; 159 | } 160 | 161 | #dialogStatistic { 162 | height: 52px; 163 | top: 30px; 164 | position: relative; 165 | } 166 | 167 | .message { 168 | margin: 10px; 169 | } 170 | 171 | #test { 172 | border: 1px solid rgba(130, 133, 186, 0.3); 173 | border-radius: 10px; 174 | box-shadow: 1px 2px 2px black; 175 | width: 100px; 176 | font-size: 18px; 177 | display: none; 178 | font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; 179 | } 180 | 181 | img { 182 | height: 100%; 183 | width: 100%; 184 | } 185 | 186 | #imgShow { 187 | height: 450px; 188 | width: 600px; 189 | position: relative; 190 | top: 120px; 191 | } 192 | 193 | #successupload { 194 | width: 200px; 195 | } 196 | 197 | #show { 198 | display: flex; 199 | float: right; 200 | position: relative; 201 | right: -50px; 202 | } 203 | 204 | .info>p { 205 | font-size: large; 206 | font-weight: 900; 207 | position: relative; 208 | font-style: inherit; 209 | color: rgb(12, 13, 13); 210 | } 211 | 212 | .info>label { 213 | height: 17px; 214 | position: relative; 215 | align-items: center; 216 | } 217 | 218 | .info { 219 | display: block; 220 | height: 25px; 221 | position: relative; 222 | width: 200px; 223 | color: rgb(30, 39, 46); 224 | border-radius: 10px; 225 | font-size: small; 226 | font-weight: bold; 227 | font-style: inherit; 228 | display: block; 229 | font-weight: 900; 230 | } 231 | 232 | 233 | /* Optional styles for the text container */ 234 | 235 | #text-container { 236 | font-size: 24px; 237 | line-height: 1.5; 238 | } 239 | 240 | 241 | /* Animation styles */ 242 | 243 | @keyframes revealText { 244 | 0% { 245 | visibility: hidden; 246 | } 247 | 100% { 248 | visibility: visible; 249 | } 250 | } --------------------------------------------------------------------------------