Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge new features into dev-v1 #88

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ AgentVerse is on a mission to revolutionize the multi-agent environment for larg


## How Can You Contribute?
- **Issue and Pull-Request**: If you encounter any problems when use AgentVerse, you can propose the issue. Beisdes, you can also autonomously ask us to assign issue to you and send the PR (Please follow the [PULL_REQUEST_TEMPLATE](https://github.com/OpenBMB/AgentVerse/blob/main/PULL_REQUEST_TEMPLATE.md)) after you solve it.
- **Issue and Pull-Request**: If you encounter any problems when use AgentVerse, you can propose the issue in English. Beisdes, you can also autonomously ask us to assign issue to you and send the PR (Please follow the [PULL_REQUEST_TEMPLATE](https://github.com/OpenBMB/AgentVerse/blob/main/PULL_REQUEST_TEMPLATE.md)) after you solve it.

- **Code Development**: If you're an engineer, help us refine, optimize, and expand the current framework. We're always looking for talented developers to enhance our existing features and develop new modules.

Expand Down
26 changes: 14 additions & 12 deletions agentverse/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, task: str, tasks_dir: str, ui_kwargs: Dict[str, str]):
self.messages = []
self.task = task
self.ui_kwargs = ui_kwargs
if task == "pipeline_brainstorming":
if task == "tasksolving/brainstorming":
self.backend = TaskSolving.from_task(task, tasks_dir)
else:
self.backend = Simulation.from_task(task, tasks_dir)
Expand All @@ -60,9 +60,9 @@ def __init__(self, task: str, tasks_dir: str, ui_kwargs: Dict[str, str]):
def get_avatar(self, idx):
if idx == -1:
img = cv2.imread(f"{IMG_PATH}/db_diag/-1.png")
elif self.task == "prisoner_dilemma":
elif self.task == "simulation/prisoner_dilemma":
img = cv2.imread(f"{IMG_PATH}/prison/{idx}.png")
elif self.task == "db_diag":
elif self.task == "simulation/db_diag":
img = cv2.imread(f"{IMG_PATH}/db_diag/{idx}.png")
elif "sde" in self.task:
img = cv2.imread(f"{IMG_PATH}/sde/{idx}.png")
Expand Down Expand Up @@ -164,9 +164,9 @@ def reset(self, stu_num=0):
self.backend.reset()
self.turns_remain = self.backend.environment.max_turns

if self.task == "prisoner_dilemma":
if self.task == "simulation/prisoner_dilemma":
background = cv2.imread(f"{IMG_PATH}/prison/case_1.png")
elif self.task == "db_diag":
elif self.task == "simulation/db_diag":
background = cv2.imread(f"{IMG_PATH}/db_diag/background.png")
elif "sde" in self.task:
background = cv2.imread(f"{IMG_PATH}/sde/background.png")
Expand Down Expand Up @@ -201,7 +201,7 @@ def gen_img(self, data: List[Dict]):
# if len(data) != self.stu_num:
if len(data) != self.stu_num + 1:
raise gr.Error("data length is not equal to the total number of students.")
if self.task == "prisoner_dilemma":
if self.task == "simulation/prisoner_dilemma":
img = cv2.imread(f"{IMG_PATH}/speaking.png", cv2.IMREAD_UNCHANGED)
if (
len(self.messages) < 2
Expand All @@ -219,7 +219,7 @@ def gen_img(self, data: List[Dict]):
cover_img(background, img, (550, 480))
if data[2]["message"] != "":
cover_img(background, img, (550, 880))
elif self.task == "db_diag":
elif self.task == "simulation/db_diag":
background = cv2.imread(f"{IMG_PATH}/db_diag/background.png")
img = cv2.imread(f"{IMG_PATH}/db_diag/speaking.png", cv2.IMREAD_UNCHANGED)
if data[0]["message"] != "":
Expand Down Expand Up @@ -262,7 +262,9 @@ def gen_img(self, data: List[Dict]):
img = cv2.imread(f"{IMG_PATH}/hand.png", cv2.IMREAD_UNCHANGED)
cover_img(background, img, (h_begin - 90, w_begin + 10))
elif data[stu_cnt]["message"] not in ["", "[RaiseHand]"]:
img = cv2.imread(f"{IMG_PATH}/speaking.png", cv2.IMREAD_UNCHANGED)
img = cv2.imread(
f"{IMG_PATH}/speaking.png", cv2.IMREAD_UNCHANGED
)
cover_img(background, img, (h_begin - 90, w_begin + 10))

else:
Expand All @@ -274,7 +276,7 @@ def return_format(self, messages: List[Message]):
_format = [{"message": "", "sender": idx} for idx in range(len(self.agent_id))]

for message in messages:
if self.task == "db_diag":
if self.task == "simulation/db_diag":
content_json: dict = message.content
content_json[
"diagnose"
Expand Down Expand Up @@ -342,7 +344,7 @@ def gen_message(self):
avatar = self.get_avatar(-1)
else:
avatar = self.get_avatar((sender - 1) % 11 + 1)
if self.task == "db_diag":
if self.task == "simulation/db_diag":
msg_json = json.loads(msg)
self.solution_status = [False] * self.tot_solutions
msg = msg_json["diagnose"]
Expand Down Expand Up @@ -421,7 +423,7 @@ def submit(self, message: str):
return self.gen_img([{"message": ""}] * len(self.agent_id)), self.gen_message()

def launch(self, single_agent=False, discussion_mode=False):
if self.task == "pipeline_brainstorming":
if self.task == "tasksolving/brainstorming":
with gr.Blocks() as demo:
chatbot = gr.Chatbot(height=800, show_label=False)
msg = gr.Textbox(label="Input")
Expand Down Expand Up @@ -478,7 +480,7 @@ def respond(message, chat_history):
# stu_num = gr.Number(label="Student Number", precision=0)
# stu_num = self.stu_num

if self.task == "db_diag":
if self.task == "simulation/db_diag":
user_msg = gr.Textbox()
submit_btn = gr.Button("Submit", variant="primary")

Expand Down