-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add MagenticOne CLI script for task execution with OpenAI GPT-4o integration * Fix argument parsing in MagenticOne CLI to require a single task input * Add docstring to main function in MagenticOne CLI for improved usage clarity * Fix example usage in docstring of MagenticOne CLI for correct argument order * Refactor argument parsing in MagenticOne CLI for improved clarity and consistency
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
python/packages/autogen-ext/src/autogen_ext/teams/magentic_one_cli.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import argparse | ||
import asyncio | ||
|
||
from autogen_agentchat.ui import Console | ||
|
||
from autogen_ext.models.openai import OpenAIChatCompletionClient | ||
from autogen_ext.teams.magentic_one import MagenticOne | ||
|
||
|
||
def main(): | ||
""" | ||
Command-line interface for running a complex task using MagenticOne. | ||
This script accepts a single task string and an optional flag to disable | ||
human-in-the-loop mode. It initializes the necessary clients and runs the | ||
task using the MagenticOne class. | ||
Arguments: | ||
task (str): The task to be executed by MagenticOne. | ||
--no-hil: Optional flag to disable human-in-the-loop mode. | ||
Example usage: | ||
python magentic_one_cli.py "example task" | ||
python magentic_one_cli.py --no-hil "example task" | ||
""" | ||
parser = argparse.ArgumentParser( | ||
description=( | ||
"Run a complex task using MagenticOne.\n\n" | ||
"For more information, refer to the following paper: https://arxiv.org/abs/2411.04468" | ||
) | ||
) | ||
parser.add_argument("task", type=str, nargs=1, help="The task to be executed by MagenticOne.") | ||
parser.add_argument("--no-hil", action="store_true", help="Disable human-in-the-loop mode.") | ||
args = parser.parse_args() | ||
|
||
async def run_task(task, hil_mode): | ||
client = OpenAIChatCompletionClient(model="gpt-4o") | ||
m1 = MagenticOne(client=client, hil_mode=hil_mode) | ||
await Console(m1.run_stream(task=task)) | ||
|
||
task = args.task[0] | ||
asyncio.run(run_task(task, not args.no_hil)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |