()
| 389 | container.execute(config.start[1]) |
| 390 | |
| 391 | def get_answer(): |
| 392 | oneshot = True |
| 393 | session.inject({ |
| 394 | "role": "user", |
| 395 | "content": """You are an assistant that will act like a person, I'will play the role of linux(ubuntu) operating system. Your goal is to implement the operations required by me or answer to the question proposed by me. For each of your turn, you should first think what you should do, and then take exact one of the three actions: "bash", "finish" or "answer". |
| 396 | |
| 397 | 1. If you think you should execute some bash code, take bash action, and you should print like this: |
| 398 | |
| 399 | Think: put your thought here. |
| 400 | |
| 401 | Act: bash |
| 402 | |
| 403 | ```bash |
| 404 | # put your bash code here |
| 405 | ``` |
| 406 | |
| 407 | 2. If you think you have finished the task, take finish action, and you should print like this: |
| 408 | |
| 409 | Think: put your thought here. |
| 410 | |
| 411 | Act: finish |
| 412 | |
| 413 | 3. If you think you have got the answer to the question, take answer action, and you should print like this: |
| 414 | |
| 415 | Think: put your thought here. |
| 416 | |
| 417 | Act: answer(Your answer to the question should be put in this pair of parentheses) |
| 418 | |
| 419 | If the output is too long, I will truncate it. The truncated output is not complete. You have to deal with the truncating problem by yourself. Attention, your bash code should not contain any input operation. Once again, you should take only exact one of the three actions in each turn.\n\n""" |
| 420 | }) |
| 421 | |
| 422 | if not oneshot: |
| 423 | session.history[-1]["content"] += "Now, my problem is:\n\n" + config.description |
| 424 | else: |
| 425 | session.history[-1]["content"] += "Now, my problem is:\n\n" + ONE_SHOT[0]["content"] |
| 426 | session.history.extend(ONE_SHOT[1:]) |
| 427 | session.inject({"role": "user", "content": "Now, I will start a new problem in a new OS. My problem is:\n\n" + config.description}) |
| 428 | |
| 429 | for _ in range(self.round_limit): |
| 430 | try: |
| 431 | root = session.action() |
| 432 | root = self.extract_action(root) |
| 433 | # print(root) |
| 434 | except Exception as e: |
| 435 | # print("Error", str(e), traceback.format_exc(), sep=" | ") |
| 436 | return |
| 437 | if "action" not in root or root["action"] not in ["bash", "commit"]: |
| 438 | # print("Error", "Invalid Action Field", traceback.format_exc(), sep=" | ") |
| 439 | return |
| 440 | |
| 441 | action = root["action"] |
| 442 | content = root["content"] |
| 443 | if action == "commit": |
| 444 | return content |
| 445 | elif action == "bash": |
| 446 | result = container.execute(content).output.decode('utf-8') |
| 447 | if len(result) > 800: |
| 448 | result = result[:780] + "\n[truncated because the output is too long]" |
nothing calls this directly
no test coverage detected