You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # MagenticOne Interface
  2. This repository contains a preview interface for interacting with the MagenticOne system. It includes helper classes, and example usage.
  3. ## Usage
  4. ### MagenticOneHelper
  5. The MagenticOneHelper class provides an interface to interact with the MagenticOne system. It saves logs to a user-specified directory and provides methods to run tasks, stream logs, and retrieve the final answer.
  6. The class provides the following methods:
  7. - async initialize(self) -> None: Initializes the MagenticOne system, setting up agents and runtime.
  8. - async run_task(self, task: str) -> None: Runs a specific task through the MagenticOne system.
  9. - get_final_answer(self) -> Optional[str]: Retrieves the final answer from the Orchestrator.
  10. - async stream_logs(self) -> AsyncGenerator[Dict[str, Any], None]: Streams logs from the system as they are generated.
  11. - get_all_logs(self) -> List[Dict[str, Any]]: Retrieves all logs that have been collected so far.
  12. We show an example of how to use the MagenticOneHelper class to in [example_magentic_one_helper.py](example_magentic_one_helper.py).
  13. ```python
  14. from magentic_one_helper import MagenticOneHelper
  15. import asyncio
  16. import json
  17. async def magentic_one_example():
  18. # Create and initialize MagenticOne
  19. magnetic_one = MagenticOneHelper(logs_dir="./logs")
  20. await magnetic_one.initialize()
  21. print("MagenticOne initialized.")
  22. # Start a task and stream logs
  23. task = "How many members are in the MSR HAX Team"
  24. task_future = asyncio.create_task(magnetic_one.run_task(task))
  25. # Stream and process logs
  26. async for log_entry in magnetic_one.stream_logs():
  27. print(json.dumps(log_entry, indent=2))
  28. # Wait for task to complete
  29. await task_future
  30. # Get the final answer
  31. final_answer = magnetic_one.get_final_answer()
  32. if final_answer is not None:
  33. print(f"Final answer: {final_answer}")
  34. else:
  35. print("No final answer found in logs.")
  36. ```