You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

agilecoder

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agilecoder - pypi Package Compare versions

Comparing version
0.1.2
to
0.1.3
agilecoder/online_log/__init__.py
+166
import sys
import base64
sys.path.append('..')
import logging
import base64
from flask import send_file
from io import BytesIO
import zipfile
from zipfile import ZipFile
import requests
import subprocess
import os
import argparse
import concurrent.futures
from flask import Flask, send_from_directory, request, jsonify, redirect, render_template, url_for, make_response
app = Flask(__name__, static_folder='static')
app.logger.setLevel(logging.ERROR)
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
messages = []
logs = []
folder_name = None
def send_msg(role, text):
try:
data = {"role": role, "text": text}
response = requests.post("http://127.0.0.1:8000/send_message", json=data)
# if response.status_code == 200:
# print("Message sent successfully!")
# else:
# print("Failed to send message.")
except:
logging.info("flask app.py did not start for online log")
def send_online_log(log):
try:
data = {"log": log}
response = requests.post("http://127.0.0.1:8000/send_log", json=data)
# if response.status_code == 200:
# print("LOGGG sent successfully!")
# else:
# print("Failed to send message.")
except:
logging.info("flask app.py did not start for online log")
@app.route("/")
def index():
return render_template('index.html')
# return send_from_directory("static", "index.html")
@app.route("/chain_visualizer")
def chain_visualizer():
return render_template("chain_visualizer.html")
@app.route("/replay")
def replay():
return render_template("replay.html", file = None, folder_name = None)
@app.route("/get_messages")
def get_messages():
return jsonify(messages)
@app.route("/get_logs")
def get_logs():
return jsonify(logs)
@app.route('/process-task', methods = ['POST'])
def process_task():
global messages, logs, folder_name
if request.method == 'POST':
logs, messages = [], []
# print(request.get_json())
task = request.get_json().get('task')
project = request.get_json().get('project')
parser = argparse.ArgumentParser(description='argparse')
parser.add_argument('--config', type=str, default="Agile",
help="Name of config, which is used to load configuration under CompanyConfig/")
parser.add_argument('--org', type=str, default="DefaultOrganization",
help="Name of organization, your software will be generated in WareHouse/name_org_timestamp")
parser.add_argument('--task', type=str, default="Develop a basic Gomoku game.",
help="Prompt of software")
parser.add_argument('--name', type=str, default="Gomoku",
help="Name of software, your software will be generated in WareHouse/name_org_timestamp")
parser.add_argument('--model', type=str, default="GPT_3_5_AZURE",
help="GPT Model, choose from {'GPT_3_5_TURBO','GPT_4','GPT_4_32K', 'GPT_3_5_AZURE'}")
args = parser.parse_args()
args.task = task
args.org = project
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(run_task, args)
return_value = future.result()
folder_name = return_value
# folder_name = os.path.basename(dir_path)
# full_path = os.path.join(dir_path, folder_name + '.log')
# with open(full_path) as f:
# content = f.read().encode()
# content = base64.b64encode(content).decode('utf-8')
# return render_template("replay.html", file = content, folder_name = dir_path)
# else:
return 'Form data received successfully!'
@app.route('/download')
def download():
# folder_name = request.args.get('folder_name')
all_files = os.listdir(folder_name)
stream = BytesIO()
with ZipFile(stream, 'w') as zf:
for file in all_files:
zf.write(os.path.join(folder_name, file), os.path.basename(file))
stream.seek(0)
return send_file(
stream,
download_name='downloaded.zip',
as_attachment=True,
mimetype='application/zip'
)
@app.route("/send_message", methods=["POST"])
def send_message():
data = request.get_json()
role = data.get("role")
text = data.get("text")
avatarUrl = find_avatar_url(role)
message = {"role": role, "text": text, "avatarUrl": avatarUrl}
messages.append(message)
return jsonify(message)
@app.route('/refresh-detected')
def refresh_detected():
# folder_name = request.args.get('folder_name')
global messages, logs
messages, logs = [], []
return "delete cache"
@app.route("/send_log", methods=["POST"])
def send_log():
data = request.get_json()
log = data.get("log")
log = {"log": log}
logs.append(log)
return jsonify(log)
def find_avatar_url(role):
role = role.replace(" ", "%20")
avatar_filename = f"avatars/{role}.png"
avatar_url = f"/static/{avatar_filename}"
return avatar_url
if __name__ == "__main__":
from run_api import run_task
print("please visit http://127.0.0.1:8000/ for demo")
app.run(debug=True, port=8000)
+1
-1
Metadata-Version: 2.1
Name: agilecoder
Version: 0.1.2
Version: 0.1.3
Summary: AgileCoder

@@ -5,0 +5,0 @@ Home-page: https://github.com/FSoft-AI4Code/AgileCoder

@@ -56,2 +56,4 @@ README.md

agilecoder/components/statistics.py
agilecoder/components/utils.py
agilecoder/components/utils.py
agilecoder/online_log/__init__.py
agilecoder/online_log/app.py

@@ -134,4 +134,5 @@ # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========

agilecoder_prompt_template = "AgileCoder is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of \"changing the digital world through programming\"."
agilecoder_prompt_template = """
AgileCoder, a software enterprise, employs Agile Scrum methodology for its software development endeavors. Its operations are fueled by a multiple of intelligent agents, comprising a Product Owner, a Development Team consisting of Programmers, Code Reviewers, and Software Test Engineers. With a multi-agent organizational framework, AgileCoder is dedicated to the mission of "revolutionizing the digital realm through programming."
""".strip()
sys_msg_meta_dicts = [dict(agilecoder_prompt=agilecoder_prompt_template, task=task_prompt)] * 2

@@ -138,0 +139,0 @@ if (extend_sys_msg_meta_dicts is None and self.task_type in [TaskType.AI_SOCIETY, TaskType.MISALIGNMENT,

@@ -17,2 +17,2 @@ import argparse

args = parser.parse_args()
run_task(args)
run_task(args)

@@ -101,6 +101,19 @@ {

{
"phase": "CodeReviewModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
"phase": "CodeAndFormat",
"phaseType": "ComposedPhase",
"cycleNum": 1,
"Composition": [
{
"phase": "CodeReviewModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeFormatting",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
}

@@ -115,3 +128,3 @@ ]

{
"phase": "TestErrorSummary",
"phase": "TestingPlan",
"phaseType": "SimplePhase",

@@ -122,6 +135,25 @@ "max_turn_step": 1,

{
"phase": "TestModification",
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeAndFormat",
"phaseType": "ComposedPhase",
"cycleNum": 1,
"Composition": [
{
"phase": "TestModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeFormatting",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
}

@@ -131,2 +163,8 @@ ]

{
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "SprintReview",

@@ -213,3 +251,3 @@ "phaseType": "SimplePhase",

{
"phase": "TestErrorSummary",
"phase": "TestingPlan",
"phaseType": "SimplePhase",

@@ -220,6 +258,25 @@ "max_turn_step": 1,

{
"phase": "TestModification",
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeAndFormat",
"phaseType": "ComposedPhase",
"cycleNum": 1,
"Composition": [
{
"phase": "TestModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeFormatting",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
}

@@ -229,2 +286,8 @@ ]

{
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "SprintReview",

@@ -231,0 +294,0 @@ "phaseType": "SimplePhase",

@@ -45,6 +45,6 @@ {

"Product Backlog:",
"PRODUCT_BACKLOG",
"$PRODUCT_BACKLOG",
"Acceptance Criteria:",
"ACCEPTANCE_CRITERIA",
"where PRODUCT_BACKLOG is the product backlog for the user's task and ACCEPTANCE_CRITERIA is the corresponding acceptance criteria of the product backlog.",
"$ACCEPTANCE_CRITERIA",
"where $PRODUCT_BACKLOG is the product backlog for the user's task and $ACCEPTANCE_CRITERIA is the corresponding acceptance criteria of the product backlog.",
"Importantly, you must consider the skills of the development team to write the feasible product backlog. Advanced features like AI and sounds can not be implemented properly."

@@ -119,6 +119,6 @@ ]

"Sprint Goals:",
"SPRINT_GOALS",
"$SPRINT_GOALS",
"Sprint Backlog:",
"BACKLOG_DETAILS",
"where SPRINT_GOALS are the goals of the sprint, and BACKLOG_DETAILS is the sprint backlog"
"$SPRINT_BACKLOG",
"where $SPRINT_GOALS are the goals of the sprint, and $SPRINT_BACKLOG is the sprint backlog"
]

@@ -139,7 +139,7 @@ },

"Sprint Goals:",
"SPRINT_GOALS",
"$SPRINT_GOALS",
"Sprint Backlog:",
"BACKLOG_DETAILS",
"where SPRINT_GOALS are the goals of the sprint, and BACKLOG_DETAILS is the sprint backlog whose items are from the product backlog.",
"You must ensure that SPRINT_GOALS and BACKLOG_DETAILS must not be empty and BACKLOG_DETAILS aligns with SPRINT_GOALS.",
"$SPRINT_BACKLOG",
"where $SPRINT_GOALS are the goals of the sprint, and $SPRINT_BACKLOG is the sprint backlog whose items are from the product backlog.",
"You must ensure that $SPRINT_GOALS and $SPRINT_BACKLOG must not be empty and $SPRINT_BACKLOG aligns with $SPRINT_GOALS.",
"As the Product Owner, you must create the first sprint and adhere to the following regulations:",

@@ -172,7 +172,7 @@ "1) considering the proficiency of the members, all the tasks are feasible and finished by at least one member,",

"Sprint Goals:",
"SPRINT_GOALS",
"$SPRINT_GOALS",
"Sprint Backlog:",
"BACKLOG_DETAILS",
"where SPRINT_GOALS are the goals of the sprint, and BACKLOG_DETAILS is the sprint backlog whose items are from the product backlog, meaning that you must not devise new tasks or non-practical features.",
"You must ensure that SPRINT_GOALS and BACKLOG_DETAILS must not be empty and BACKLOG_DETAILS aligns with SPRINT_GOALS.",
"$SPRINT_BACKLOG",
"where $SPRINT_GOALS are the goals of the sprint, and $SPRINT_BACKLOG is the sprint backlog whose items are from the product backlog, meaning that you must not devise new tasks or non-practical features.",
"You must ensure that $SPRINT_GOALS and $SPRINT_BACKLOG must not be empty and $SPRINT_BACKLOG aligns with $SPRINT_GOALS.",
"As the Product Owner, you must adhere to the following regulations:",

@@ -206,6 +206,6 @@ "1) considering the proficiency of the members, all the tasks are feasible and finished by at least one member,",

"Done Work:",
"DONE_WORK",
"$DONE_WORK",
"Undone Work:",
"UNDONE_WORK",
"where DONE_WORK are carefully completed and tested works, UNDONE_WORK includes unfinished works or existing bugs."
"$UNDONE_WORK",
"where $DONE_WORK are carefully completed and tested works, $UNDONE_WORK includes unfinished works or existing bugs."
]

@@ -245,9 +245,9 @@ },

"You will first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose.",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -266,12 +266,12 @@ "You will start with the \"main\" file, then go to the ones that are imported by that file, and so on.",

"Required Code Format:",
"FILENAME",
"```LANGUAGE",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",
"where \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code.",
"where \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code.",
"Comments:",
"The code above contains enough values for the required fields: \"FILENAME\", \"LANGUAGE\", \"DOCSTRING\" and \"CODE\". However, they are not written to follow the format properly. You should rearrange them to satisfy the requirement.",
"The code above contains enough values for the required fields: \"$FILENAME\", \"$LANGUAGE\", \"$DOCSTRING\" and \"$CODE\". However, they are not written to follow the format properly. You should rearrange them to satisfy the requirement.",
"Example:",

@@ -304,9 +304,9 @@ "a.py",

"You will first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose.",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -327,8 +327,8 @@ "You will start with the \"main\" file, then go to the ones that are imported by that file, and so on.",

"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -383,9 +383,9 @@ "As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), we will discuss and design many decorative images for GUI decoration. Now, we keep discussing the GUI beautification by listing some functionally independent elements in GUI that are being considered to be decorated by different pictures. For example, ten digits (0-9) in a calculator are functionally independent.",

"\"{unimplemented_file}\"",
"In our software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"In our software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -427,3 +427,3 @@ "As the {assistant_role}, to satisfy the complete function of our developed software, you have to implement all methods in the {unimplemented_file} file which contains a unimplemented class. Now, implement all methods of the {unimplemented_file} and all other codes needed, then output the fully implemented codes, strictly following the required format."

"phase_prompt": [
"According to the user's task, our designed product modality, languages, and the sprint backlog, our developed first-edition source codes are listed below: ",
"According to the user's task, our designed product modality, languages, the sprint goals and the sprint backlog, our developed first-edition source codes are listed below: ",
"User's task: \"{task}\".",

@@ -438,9 +438,9 @@ "Modality: \"{modality}\".",

"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code. Format:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -464,9 +464,9 @@ "As the {assistant_role}, to satisfy the user's demand and the sprint goals, make the software creative, executive and robust, and ensure that the code resolves the sprint backlog, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."

"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code. Format:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",

@@ -489,2 +489,21 @@ "As the {assistant_role}, to satisfy new user's demand and the sprint goals, make the software creative, executive and robust, and ensure that the code resolves the sprint backlog, you should modify corresponding codes according to the comments. Then, output the fixed codes strictly following the required format."

},
"TestingPlan": {
"assistant_role_name": "Software Test Engineer",
"user_role_name": "Programmer",
"phase_prompt": [
"According to the user's task, our designed product modality, the sprint goals and the sprint backlog, our developed first-edition source codes are listed below: ",
"User's task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Sprint goals:\n\"{current_sprint_goals}\"",
"Sprint backlog:\n\"{current_programming_task}\"",
"Codes:",
"\"{codes}\"",
"As the {assistant_role}, to make that the code above satisfies the sprint goals and backlog and runs flawlessly, you must write commands to start the UI of the software and test the correctness of the code above.",
"Also, you strictly follow the format:",
"Commands:",
"$COMMANDS",
"Here, $COMMANDS are necessary commands for starting the software and testing the code above."
]
},
"TestModification": {

@@ -502,12 +521,12 @@ "assistant_role_name": "Programmer",

"\"{error_summary}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"$FILENAME\" is the lowercase file name including the file extension, \"$LANGUAGE\" in the programming language, \"$DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"$CODE\" is the original code:",
"$FILENAME",
"```$LANGUAGE",
"'''",
"DOCSTRING",
"$DOCSTRING",
"'''",
"CODE",
"$CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software execute smoothly and robustly, you should modify the codes based on the error summary.",
"Now, use the format exemplified above and modify the problematic codes based on the error summary. If you cannot find the assets from the existing paths, you should consider remove relevant code and features. Output the codes that you fixed based on the test reported and corresponding explanations (strictly follow the format defined above, including FILENAME, LANGUAGE, DOCSTRING and CODE; incomplete \"TODO\" codes are strictly prohibited). If no bugs are reported, please return only one line like \"<INFO> Finished\"."
"Now, use the format exemplified above and modify the problematic codes based on the error summary. If you cannot find the assets from the existing paths, you should consider remove relevant code and features. Output the codes that you fixed based on the test reported and corresponding explanations (strictly follow the format defined above, including $FILENAME, $LANGUAGE, $DOCSTRING and $CODE; incomplete \"TODO\" codes are strictly prohibited). If no bugs are reported, please return only one line like \"<INFO> Finished\"."
]

@@ -514,0 +533,0 @@ },

@@ -74,3 +74,3 @@ {

"User": [
"You are a user, and you hire AgileCoder to create a product with the description: {task}.",
"You are a client. You employ AgileCoder, a software development company, to develop a product based on the following task description: {task}.",
"You also require AgileCoder to obey the following requirements:",

@@ -77,0 +77,0 @@ "1. The proposed features can be implementable,",

@@ -291,3 +291,3 @@ import importlib

"""
self_task_improve_prompt = """I will give you a short description of a software design requirement,
self_task_improve_promptgit = """I will give you a short description of a software design requirement,
please rewrite it into a detailed prompt that can make large language model know how to make this software better based this prompt,

@@ -294,0 +294,0 @@ the prompt should ensure LLMs build a software that can be run correctly, which is the most import part you need to consider.

@@ -45,3 +45,3 @@ import os

for node in ast.iter_child_nodes(tree):
if not isinstance(node, (ast.Module, ast.FunctionDef, ast.ClassDef)):
if not isinstance(node, (ast.Expr, ast.Import, ast.ImportFrom, ast.Module, ast.FunctionDef, ast.ClassDef)):
return True

@@ -104,2 +104,3 @@

directory = self.env_dict['directory']
print('DIRECTORY:', directory)

@@ -121,49 +122,99 @@ success_info = "The software run successfully without errors."

all_files = os.listdir(directory)
if 'main.py' in all_files:
command = "cd {}; ls -l; python3 main.py;".format(directory)
testing_commands = self.env_dict['commands']
return_flag = False
error_contents = ''
runnable_files = []
is_python = False
for file in all_files:
if not file.endswith('.py'): continue
is_python = True
with open(os.path.join(directory, file)) as f:
code = f.read()
if has_entry_point(code):
runnable_files.append(file)
if is_python and len(runnable_files) == 0:
return True, "[Error] the software lacks an entry point to start"
testing_commands.extend(runnable_files)
for testing_command in set(testing_commands):
if testing_command not in runnable_files:
errs = "[Error] the software lacks an entry point to start"
error_contents += """\nError Traceback for Running {testing_command}:\n{errs}""".format(testing_command = testing_command, errs = errs)
return_flag = True
continue
if 'main.py' in all_files and testing_command == 'main.py':
command = "cd {}; ls -l; python3 main.py;".format(directory)
# process = subprocess.Popen(command,
# shell=True,
# preexec_fn=os.setsid,
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE
# )
else:
# flag = False
# for file in all_files:
# if not file.endswith('.py'): continue
# with open(os.path.join(directory, file)) as f:
# code = f.read()
# if has_entry_point(code):
# command = "cd {}; ls -l; python3 ".format(directory) + file
# flag = True
# process = subprocess.Popen(command,
# shell=True,
# preexec_fn=os.setsid,
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE
# )
# break
command = "cd {}; ls -l; python3 ".format(directory) + testing_command
print('COMMAND:', command)
process = subprocess.Popen(command,
shell=True,
preexec_fn=os.setsid,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
else:
flag = False
for file in all_files:
if not file.endswith('.py'): continue
with open(os.path.join(directory, file)) as f:
code = f.read()
if has_entry_point(code):
command = "cd {}; ls -l; python3 ".format(directory) + file
flag = True
process = subprocess.Popen(command,
shell=True,
preexec_fn=os.setsid,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
break
# if len(process.stderr.read().decode('utf-8')) > 0: break
if not flag:
return False, "Error: the software lacks the entry point to start"
time.sleep(3)
return_code = process.returncode
# Check if the software is still running
if process.poll() is None:
if "killpg" in dir(os):
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
else:
os.kill(process.pid, signal.SIGTERM)
shell=True,
preexec_fn=os.setsid,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
# if len(process.stderr.read().decode('utf-8')) > 0: break
# if not flag:
# return False, "Error: the software lacks the entry point to start"
time.sleep(3)
return_code = process.returncode
# Check if the software is still running
if process.poll() is None:
os.kill(process.pid,signal.CTRL_BREAK_EVENT)
if "killpg" in dir(os):
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
else:
os.kill(process.pid, signal.SIGTERM)
if process.poll() is None:
os.kill(process.pid,signal.CTRL_BREAK_EVENT)
if return_code == 0:
return False, success_info
else:
error_output = process.stderr.read().decode('utf-8')
if error_output:
if "Traceback".lower() in error_output.lower():
errs = error_output.replace(directory + "/", "")
return True, errs
# if return_code == 0:
# return False, success_info
# else:
# error_output = process.stderr.read().decode('utf-8')
# if error_output:
# if "Traceback".lower() in error_output.lower():
# errs = error_output.replace(directory + "/", "")
# return True, errs
# else:
# return False, success_info
error_output = process.stderr.read().decode('utf-8')
if error_output:
if return_code != 0:
if "Traceback".lower() in error_output.lower():
errs = error_output.replace(directory + "/", "")
# return True, errs
error_contents += """\nError Traceback for Running {testing_command}:\n{errs}""".format(testing_command = testing_command, errs = errs)
return_flag = True
# else:
# return False, success_info
else:
if 'error' in error_output.lower():
return_flag = True
error_contents += """\nError Traceback for Running {testing_command}:\n{errs}""".format(testing_command = testing_command, errs = errs)
if return_flag:
return return_flag, error_contents
else:

@@ -170,0 +221,0 @@ return False, success_info

@@ -294,3 +294,3 @@ import importlib

def break_cycle(self, phase_env) -> bool:
if not phase_env['exist_bugs_flag']:
if not phase_env.get('exist_bugs_flag', True):
log_and_print_online(f"**[Test Info]**\n\nAI User (Software Test Engineer):\nTest Pass!\n")

@@ -311,3 +311,3 @@ return True

def break_cycle(self, phase_env) -> bool:
print('phase_env', 'has_correct_format' in phase_env, phase_env.get('has_correct_format', False))
# print('phase_env', 'has_correct_format' in phase_env, phase_env.get('has_correct_format', False))
if 'has_correct_format' in phase_env and phase_env['has_correct_format']:

@@ -314,0 +314,0 @@ return True

@@ -7,3 +7,3 @@ import os

def get_info(dir, log_filepath):
print("dir:", dir)
# print("dir:", dir)

@@ -10,0 +10,0 @@ version_updates = -1

@@ -9,3 +9,3 @@ import html

from agilecoder.camel.messages.system_messages import SystemMessage
# from online_log.app import send_msg
from agilecoder.online_log.app import send_msg, send_online_log

@@ -50,7 +50,9 @@

logging.info(role + "\n")
# send_msg("System", role)
print(role + "\n")
send_online_log(logging.root.handlers[-1].buffer[-1])
send_msg("System", role)
# print(role + "\n")
else:
print(str(role) + ": " + str(content) + "\n")
# print(str(role) + ": " + str(content) + "\n")
logging.info(str(role) + ": " + str(content) + "\n")
send_online_log(logging.root.handlers[-1].buffer[-1])
if isinstance(content, SystemMessage):

@@ -61,3 +63,3 @@ records_kv = []

value = content.meta_dict[key]
value = str(value)
value = str(value)
value = html.unescape(value)

@@ -72,3 +74,3 @@ value = markdown.markdown(value)

content = str(content)
# send_msg(role, content)
send_msg(role, content)

@@ -109,3 +111,3 @@

records = f"**[{func.__name__}]**\n\n" + convert_to_markdown_table(records_kv)
log_and_print_online("System", records)
# log_and_print_online("System", records)

@@ -112,0 +114,0 @@ return func(*args, **kwargs)

@@ -11,5 +11,23 @@ import logging

from agilecoder.components.chat_chain import ChatChain
from agilecoder.online_log.app import send_online_log
from dotenv import load_dotenv
load_dotenv()
class BufferHandler(logging.Handler):
def __init__(self, level=logging.NOTSET, format=None, datefmt=None, encoding=None):
logging.Handler.__init__(self)
self.buffer = []
if format:
formatter = logging.Formatter(format, datefmt)
self.setFormatter(formatter)
if level:
self.setLevel(level)
if encoding:
self.encoding = encoding
def emit(self, record):
self.buffer.append(self.format(record))
def get_config(company):

@@ -73,2 +91,8 @@ """

datefmt='%Y-%d-%m %H:%M:%S', encoding="utf-8")
buffer_handler = BufferHandler(level=logging.INFO,
format='[%(asctime)s %(levelname)s] %(message)s',
datefmt='%Y-%d-%m %H:%M:%S', encoding="utf-8")
buffer_handler.setLevel(logging.INFO) # Set the handler level to DEBUG
# logger.addHandler(buffer_handler)
logging.root.addHandler(buffer_handler)

@@ -98,1 +122,3 @@ # ----------------------------------------

chat_chain.post_processing()
send_online_log("<FINISH>")
return chat_chain.chat_env.env_dict['directory']

@@ -26,4 +26,21 @@ # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========

from dotenv import load_dotenv
load_dotenv()
current_dir = os.getcwd()
env_path = os.path.join(current_dir, '.env')
load_dotenv(env_path)
class BufferHandler(logging.Handler):
def __init__(self, level=logging.NOTSET, format=None, datefmt=None, encoding=None):
logging.Handler.__init__(self)
self.buffer = []
if format:
formatter = logging.Formatter(format, datefmt)
self.setFormatter(formatter)
if level:
self.setLevel(level)
if encoding:
self.encoding = encoding
def emit(self, record):
self.buffer.append(self.format(record))
def get_config(company):

@@ -97,3 +114,8 @@ """

datefmt='%Y-%d-%m %H:%M:%S', encoding="utf-8")
buffer_handler = BufferHandler(level=logging.INFO,
format='[%(asctime)s %(levelname)s] %(message)s',
datefmt='%Y-%d-%m %H:%M:%S', encoding="utf-8")
buffer_handler.setLevel(logging.INFO) # Set the handler level to DEBUG
# logger.addHandler(buffer_handler)
logging.root.addHandler(buffer_handler)
# ----------------------------------------

@@ -100,0 +122,0 @@ # Pre Processing

@@ -454,12 +454,4 @@ import os

code = """
gameoverscreen.py
```python
'''
This file contains the game over screen class and its methods.
'''
import pygame
class GameOverScreen:
'''
Represents the game over screen
main.py

@@ -466,0 +458,0 @@ """

Metadata-Version: 2.1
Name: agilecoder
Version: 0.1.2
Version: 0.1.3
Summary: AgileCoder

@@ -5,0 +5,0 @@ Home-page: https://github.com/FSoft-AI4Code/AgileCoder

@@ -44,2 +44,8 @@

## Installation
To install the latest version, please clone this repository and then run the command
``
pip install -e AgileCoder
``
Our library is now available on Pypi, so it can be easily installed by

@@ -51,2 +57,4 @@

Note: The current version available on PyPI does not support the demonstration
We currently supports Azure OpenAI service, so please set following environment variables:

@@ -74,2 +82,8 @@

agilecoder --task "create a caro game in python"
``
## Demo
To begin showcasing the Flask app, navigate to the directory `agilecoder/online_log` and execute the following command:
``
python app.py
``
from setuptools import setup, find_packages
setup(name='agilecoder',
version='0.1.2',
version='0.1.3',
description='AgileCoder',

@@ -5,0 +5,0 @@ url='https://github.com/FSoft-AI4Code/AgileCoder',

Sorry, the diff of this file is too big to display