Skip to content

Instantly share code, notes, and snippets.

@hideojoho
Last active November 10, 2024 16:16
Show Gist options
  • Select an option

  • Save hideojoho/edd7ed027f0aaab4728ee68a2d488f80 to your computer and use it in GitHub Desktop.

Select an option

Save hideojoho/edd7ed027f0aaab4728ee68a2d488f80 to your computer and use it in GitHub Desktop.

Revisions

  1. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@

    - Windows 11
    - Python 3.12.3
    - Git
    - OpenAI API Key

    ## Steps
  2. hideojoho revised this gist Nov 10, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -49,8 +49,8 @@
    # AutoGen Test
    ```
    - Type `Ctrl+Enter` to run the Markdown cell
    - Add a Code cell to the notebook
    - Select `+ Code` button from the notebook to create a Code cell and add the content
    - Add a Code cell below the previous cell
    - Select `+ Code` button below the previous cell to create a new Code cell and add the content
    ```python
    import os
    from dotenv import load_dotenv
    @@ -69,7 +69,7 @@
    config_list_joe["temperature"] = 0.7
    ```
    - Type `Ctrl+Enter` to run the cell
    - Add another Code cell to notebook and run
    - Add another Code cell below the previous cell and run
    ```python
    def start_chat(cathy_setting, joe_setting, initial_message, max_turns=2):
    cathy = ConversableAgent(
  3. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@

    - Windows 11
    - Python 3.12.3
    - OpenAI API Key

    ## Steps

  4. hideojoho revised this gist Nov 10, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -38,11 +38,11 @@
    (venv) > python -m pip install -U pip
    (venv) > python -m pip install -r requirements.txt
    ```
    - Create a new file called `autogen_test.ipynb`, then do the following
    - Create a new (notebook) file called `autogen_test.ipynb`, then do the following
    - Type `Shift+Ctrl+P` to open a command palette
    - Type `notebook kernel` and select `Notebook: Select Notebook Kernel`
    - Select `Python Environment` and `venv (Python 3.xx.x) venv\Scripts\python.exe`
    - Add a Markdown cell to the notebook
    - Add a Markdown cell to the notebook file
    - Select `+ Markdown` button from the top menu of the notebook to create a Markdown cell and add the content
    ```markdown
    # AutoGen Test
  5. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@
    (venv) > python -m pip install -U pip
    (venv) > python -m pip install -r requirements.txt
    ```
    - Create a new file called `autogen_test.ipynb`
    - Create a new file called `autogen_test.ipynb`, then do the following
    - Type `Shift+Ctrl+P` to open a command palette
    - Type `notebook kernel` and select `Notebook: Select Notebook Kernel`
    - Select `Python Environment` and `venv (Python 3.xx.x) venv\Scripts\python.exe`
  6. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@
    (venv) > python -m pip install -U pip
    (venv) > python -m pip install -r requirements.txt
    ```
    - Create a new notebook called `autogen_test.ipynb`
    - Create a new file called `autogen_test.ipynb`
    - Type `Shift+Ctrl+P` to open a command palette
    - Type `notebook kernel` and select `Notebook: Select Notebook Kernel`
    - Select `Python Environment` and `venv (Python 3.xx.x) venv\Scripts\python.exe`
  7. hideojoho revised this gist Nov 10, 2024. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,12 @@
    # How to get started with AutoGen 0.2

    ## Environment

    - Windows 11
    - Python 3.12.3

    ## Steps

    - Create a new repository called `autogen_test` in GitHub
    - Type: `Private`
    - [x] Add a README file
  8. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    - Type `clone` and select `Git: Clone` from the command menu
    - Paste the Clone URL
    - Select a folder to save the repository folder
    - Create a new file called `.env`, add the following lines, and save
    - In VSCode, create a new file called `.env`, add the following lines, and save
    ```
    OPENAI_MODEL='gpt-4o-mini'
    OPENAI_API_KEY='[your open api key]'
  9. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    - Start VSCode and type `Shift+Ctrl+P` to open a command palette
    - Type `clone` and select `Git: Clone` from the command menu
    - Paste the Clone URL
    - Select a folder to clone the repository folder
    - Select a folder to save the repository folder
    - Create a new file called `.env`, add the following lines, and save
    ```
    OPENAI_MODEL='gpt-4o-mini'
  10. hideojoho revised this gist Nov 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    - Clone the repository to VSCode
    - Copy Clone URL from the `<> Code` button at the top page of the repository on GitHub
    - Start VSCode and type `Shift+Ctrl+P` to open a command palette
    - Select `Git: Clone` from the command menu
    - Type `clone` and select `Git: Clone` from the command menu
    - Paste the Clone URL
    - Select a folder to clone the repository folder
    - Create a new file called `.env`, add the following lines, and save
  11. hideojoho revised this gist Nov 9, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -128,4 +128,5 @@
    - Change `initial_message` to change the topic of conversations.
    - What do you think about X?
    - Let's discuss the topic of X.
    - Increase the `max_turns` to 4 to change the length of conversations.
    - Increase the `max_turns` to 4 to change the length of conversations.
    - Commit your changes to the repository from VSCode.
  12. hideojoho revised this gist Nov 9, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -123,9 +123,9 @@

    ## What's next?

    - Change the setting of Cathy and Joe and re-run the cell to see how conversations change.
    - Change `cathy_setting` and `joe_setting` and re-run the cell to see how conversations change.
    - Change the age, location, job, hobby, etc.
    - Change the `initial_message` to change the topic of conversations
    - Change `initial_message` to change the topic of conversations.
    - What do you think about X?
    - Let's discuss the topic of X.
    - Increase the `max_turns` to 4, and see how conversations develop.
    - Increase the `max_turns` to 4 to change the length of conversations.
  13. hideojoho revised this gist Nov 9, 2024. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -124,5 +124,8 @@
    ## What's next?

    - Change the setting of Cathy and Joe and re-run the cell to see how conversations change.
    - Change the `initial_message` to change the topic of conversations.
    - Change the age, location, job, hobby, etc.
    - Change the `initial_message` to change the topic of conversations
    - What do you think about X?
    - Let's discuss the topic of X.
    - Increase the `max_turns` to 4, and see how conversations develop.
  14. hideojoho revised this gist Nov 9, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -123,6 +123,6 @@

    ## What's next?

    - Change the setting of Cathy and Joe and re-run `start_chat` to see how conversations change.
    - Change the setting of Cathy and Joe and re-run the cell to see how conversations change.
    - Change the `initial_message` to change the topic of conversations.
    - Increase the `max_turns` to 4, and see how conversations develop.
  15. hideojoho revised this gist Nov 9, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@
    - Create a new file called `requirements.txt` and add the following lines
    ```
    ipykernel
    autogen-agentchat~=0.2
    pyautogen
    ```
    - Open a new terminal at VSCode, create a virtual environment
    ```ps
  16. hideojoho revised this gist Nov 9, 2024. 1 changed file with 65 additions and 20 deletions.
    85 changes: 65 additions & 20 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -54,30 +54,75 @@
    "model": os.getenv('OPENAI_MODEL'),
    "api_key": os.getenv('OPENAI_API_KEY')
    }
    ```
    - Type `Ctrl+Enter` to run the cell
    - Add another Code cell to notebook and run
    ```python

    config_list_cathy = config_list.copy()
    config_list_cathy["temperature"] = 0.9
    config_list_joe = config_list.copy()
    config_list_joe["temperature"] = 0.7

    cathy = ConversableAgent(
    "cathy",
    system_message="Your name is Cathy and you are a part of a duo of comedians.",
    llm_config=config_list_cathy,
    human_input_mode="NEVER",
    )

    joe = ConversableAgent(
    "joe",
    system_message="Your name is Joe and you are a part of a duo of comedians.",
    llm_config=config_list_joe,
    human_input_mode="NEVER",
    )
    ```
    - Type `Ctrl+Enter` to run the cell
    - Add another Code cell to notebook and run
    ```python
    def start_chat(cathy_setting, joe_setting, initial_message, max_turns=2):
    cathy = ConversableAgent(
    "cathy",
    system_message=cathy_setting,
    llm_config=config_list_cathy
    )
    joe = ConversableAgent(
    "joe",
    system_message=joe_setting,
    llm_config=config_list_joe
    )
    joe.initiate_chat(cathy, message=f"{initial_message}", max_turns=max_turns)
    ```
    - Add another Code cell and run
    ```python
    result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.", max_turns=2)
    ```
    cathy_setting = "Your name is Cathy and you are a part of a duo of comedians."
    joe_setting = "Your name is Joe and you are a part of a duo of comedians."
    initial_message = "Cathy, tell me a joke."
    max_turns = 2

    start_chat(cathy_setting, joe_setting, initial_message, max_turns)
    ```
    - You will see something like this (not exactly the same).
    ```
    joe (to cathy):
    Cathy, tell me a joke.
    --------------------------------------------------------------------------------
    >>>>>>>> USING AUTO REPLY...
    cathy (to joe):
    Sure, Joe! Why did the scarecrow win an award?
    Because he was outstanding in his field! 🌾😄
    --------------------------------------------------------------------------------
    >>>>>>>> USING AUTO REPLY...
    joe (to cathy):
    That's a classic, Cathy! Alright, here’s one for you: Why don’t scientists trust atoms?
    Because they make up everything!
    --------------------------------------------------------------------------------
    >>>>>>>> USING AUTO REPLY...
    ...
    An impasta! 🍝😆
    --------------------------------------------------------------------------------
    Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
    ```
    - Click `text editor` in the bottom message to view the entire conversation.

    ## What's next?

    - Change the setting of Cathy and Joe and re-run `start_chat` to see how conversations change.
    - Change the `initial_message` to change the topic of conversations.
    - Increase the `max_turns` to 4, and see how conversations develop.
  17. hideojoho revised this gist Nov 9, 2024. 1 changed file with 71 additions and 5 deletions.
    76 changes: 71 additions & 5 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,83 @@
    # How to get started with AutoGen 0.2

    - Create a new repository called `autogen_test` in GitHub
    - Type: Private
    - Type: `Private`
    - [x] Add a README file
    - Add .gitignore: Python
    - Choose a lisence: None
    - Add .gitignore: `Python`
    - Choose a lisence: `None`
    - Clone the repository to VSCode
    - Copy Clone URL from the `<> Code` button at the top page of the repository on GitHub
    - Open VSCode and type `Shift+Ctrl+P` to open a command pallet
    - Start VSCode and type `Shift+Ctrl+P` to open a command palette
    - Select `Git: Clone` from the command menu
    - Paste the Clone URL
    - Select a folder to clone the repository folder
    - Add a new file called `requirements.txt` and the following lines
    - Create a new file called `.env`, add the following lines, and save
    ```
    OPENAI_MODEL='gpt-4o-mini'
    OPENAI_API_KEY='[your open api key]'
    ```
    - Create a new file called `requirements.txt` and add the following lines
    ```
    ipykernel
    autogen-agentchat~=0.2
    ```
    - Open a new terminal at VSCode, create a virtual environment
    ```ps
    > py.exe -m venv venv
    > .\venv\Scripts\activate
    ```
    - Install Python modules in the virtual environment
    ```ps
    (venv) > python -m pip install -U pip
    (venv) > python -m pip install -r requirements.txt
    ```
    - Create a new notebook called `autogen_test.ipynb`
    - Type `Shift+Ctrl+P` to open a command palette
    - Type `notebook kernel` and select `Notebook: Select Notebook Kernel`
    - Select `Python Environment` and `venv (Python 3.xx.x) venv\Scripts\python.exe`
    - Add a Markdown cell to the notebook
    - Select `+ Markdown` button from the top menu of the notebook to create a Markdown cell and add the content
    ```markdown
    # AutoGen Test
    ```
    - Type `Ctrl+Enter` to run the Markdown cell
    - Add a Code cell to the notebook
    - Select `+ Code` button from the notebook to create a Code cell and add the content
    ```python
    import os
    from dotenv import load_dotenv
    from autogen import ConversableAgent

    load_dotenv()

    config_list = {
    "model": os.getenv('OPENAI_MODEL'),
    "api_key": os.getenv('OPENAI_API_KEY')
    }
    ```
    - Type `Ctrl+Enter` to run the cell
    - Add another Code cell to notebook and run
    ```python
    config_list_cathy = config_list.copy()
    config_list_cathy["temperature"] = 0.9
    config_list_joe = config_list.copy()
    config_list_joe["temperature"] = 0.7

    cathy = ConversableAgent(
    "cathy",
    system_message="Your name is Cathy and you are a part of a duo of comedians.",
    llm_config=config_list_cathy,
    human_input_mode="NEVER",
    )

    joe = ConversableAgent(
    "joe",
    system_message="Your name is Joe and you are a part of a duo of comedians.",
    llm_config=config_list_joe,
    human_input_mode="NEVER",
    )
    ```
    - Add another Code cell and run
    ```python
    result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.", max_turns=2)
    ```
  18. hideojoho created this gist Nov 9, 2024.
    17 changes: 17 additions & 0 deletions how_to_get_started_with_autogen_0.2.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # How to get started with AutoGen 0.2

    - Create a new repository called `autogen_test` in GitHub
    - Type: Private
    - [x] Add a README file
    - Add .gitignore: Python
    - Choose a lisence: None
    - Clone the repository to VSCode
    - Copy Clone URL from the `<> Code` button at the top page of the repository on GitHub
    - Open VSCode and type `Shift+Ctrl+P` to open a command pallet
    - Select `Git: Clone` from the command menu
    - Paste the Clone URL
    - Select a folder to clone the repository folder
    - Add a new file called `requirements.txt` and the following lines
    ```
    autogen-agentchat~=0.2
    ```