# AutoGen

[AutoGen](https://microsoft.github.io/autogen/) is another AI framework that allows you to create custom agent crews designed to perform several tasks using a LLM. Autogen Agent are also able to run code and test the output to be able to do modifications if needed.

## Installation

```{code-block} bash
pip install autogen-agentchat~=0.2
```


## Basic example

In this example we ask two agents to code a quicksort function. We have two agents here, one coding the function and the other executing the code.

```{literalinclude} ../../examples/autogen/basic.py
```

This would generate an output similar to:

````text
Here is an example of a Python implementation of the quicksort algorithm:
```
def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[0]
    less = [x for x in arr[1:] if x <= pivot]
    greater = [x for x in arr[1:] if x > pivot]
    return quicksort(less) + [pivot] + quicksort(greater)
```
This implementation uses the "Lomuto" partition scheme, which is a variation of the standard "Hoare" partition scheme that is slightly faster and more efficient.

Here's an explanation of how the code works:

1. If the length of the input array is 0 or 1, return the original array (since it is already sorted).
2. Choose the first element of the array as the pivot.
3. Create two lists: `less` and `greater`. `less` contains all elements in the array that are less than or equal to the pivot, and `greater` contains all elements that are greater than the pivot.
4. Recursively call the `quicksort` function on the `less` and `greater` lists.
5. Concatenate the results of the recursive calls
````
