"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
"In this notebook, we demonstrate how to use multiple agents to work together and accomplish a task which requires finding info from the web and coding. `AssistantAgent` is an LLM-based agent that can write and debug Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for a user to execute the code written by `AssistantAgent`. We further create a planning agent for the assistant agent to consult. The planning agent is a variation of the LLM-based `AssistantAgent` with a different system message.\n",
"* The [`config_list_openai_aoai`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_openai_aoai) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n",
" - OpenAI API key: os.environ[\"OPENAI_API_KEY\"] or `openai_api_key_file=\"key_openai.txt\"`.\n",
" - Azure OpenAI API key: os.environ[\"AZURE_OPENAI_API_KEY\"] or `aoai_api_key_file=\"key_aoai.txt\"`. Multiple keys can be stored, one per line.\n",
" - Azure OpenAI API base: os.environ[\"AZURE_OPENAI_API_BASE\"] or `aoai_api_base_file=\"base_aoai.txt\"`. Multiple bases can be stored, one per line.\n",
"* The [`config_list_from_json`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file. It first looks for environment variable `env_or_file` which needs to be a valid json string. If that variable is not found, it then looks for a json file with the same name. It filters the configs by filter_dict.\n",
"It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base. If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choose \"upload file\" icon.\n"
"We construct the planning agent named \"planner\" and a user proxy agent for the planner named \"planner_user\". We specify `human_input_mode` as \"NEVER\" in the user proxy agent, which will never ask for human feedback. We define `ask_planner` function to send a message to planner and return the suggestion from the planner."
" system_message=\"You are a helpful AI assistant. You suggest coding and reasoning steps for another AI assistant to accomplish a task. Do not suggest concrete code. For any action beyond writing code or reasoning, convert it to a step which can be implemented by writing code. For example, the action of browsing the web can be implemented by writing code which reads and prints the content of a web page. Finally, inspect the execution result. If the plan is not good, suggest a better plan. If the execution is wrong, analyze the error and suggest a fix.\"\n",
"We construct the assistant agent and the user proxy agent. We specify `human_input_mode` as \"TERMINATE\" in the user proxy agent, which will ask for feedback when it receives a \"TERMINATE\" signal from the assistant agent. We set the `functions` in `AssistantAgent` and `function_map` in `UserProxyAgent` to use the created `ask_planner` function."
" \"description\": \"ask planner to: 1. get a plan for finishing a task, 2. verify the execution result of the plan and potentially suggest new plan.\",\n",
" \"description\": \"question to ask planner. Make sure the question include enough context, such as the code and the execution result. The planner does not know the conversation between you and the user, unless you share the conversation with the planner.\",\n",
"We invoke the `initiate_chat()` method of the user proxy agent to start the conversation. When you run the cell below, you will be prompted to provide feedback after the assistant agent sends a \"TERMINATE\" signal in the end of the message. If you don't provide any feedback (by pressing Enter directly), the conversation will finish. Before the \"TERMINATE\" signal, the user proxy agent will try to execute the code suggested by the assistant agent on behalf of the user."
"To suggest a fix to an open good first issue of FLAML, we first need to fetch the list of open issues labeled as \"good first issue\" from the FLAML GitHub repository. We can do this by using the GitHub API. Here is a Python script that uses the requests library to fetch the list of issues.\n",
"This script will print the ID, title, and URL of each open issue labeled as \"good first issue\". You can run this script to get the list of issues. After that, I can help you to suggest a fix for one of the issues.\n",
"\"message\": \"Here are the open good first issues of FLAML. Please suggest a plan to fix one of them. The issues are: \\n\\n1. [Moving function execution out of UserProxyAgent to be an openai util](https://github.com/microsoft/FLAML/issues/1135)\\n2. [use_label_encoder warning with xgboost](https://github.com/microsoft/FLAML/issues/1120)\\n3. [Use appropriate wait time for retry based on the error message](https://github.com/microsoft/FLAML/issues/1034)\\n4. [Issues with Adding Custom APIs in Auto Generation](https://github.com/microsoft/FLAML/issues/1029)\\n5. [Running flaml[tune] using \\\"-O\\\" flag for python interpreter (optimization - disables assertions) crashes](https://github.com/microsoft/FLAML/issues/981)\\n6. [Conditional parameter flow2 crash](https://github.com/microsoft/FLAML/issues/903)\\n7. [indentation space](https://github.com/microsoft/FLAML/issues/884)\\n8. [Check if openml version is required](https://github.com/microsoft/FLAML/issues/882)\\n9. [Adjust the indent](https://github.com/microsoft/FLAML/issues/834)\\n10. [pip install flaml FAIL](https://github.com/microsoft/FLAML/issues/821)\\n11. [Isolate the ensemble part and expose it to users](https://github.com/microsoft/FLAML/issues/807)\\n12. [how to pass categorical features names or indices to learner](https://github.com/microsoft/FLAML/issues/805)\\n13. [Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?](https://github.com/microsoft/FLAML/issues/785)\\n14. [Add an announcement of the discord channel](https://github.com/microsoft/FLAML/issues/764)\\n15. [Documentation about small budget](https://github.com/microsoft/FLAML/issues/748)\\n16. [Make zero-shot automl more discoverable](https://github.com/microsoft/FLAML/issues/737)\\n17. [New HCrystalBall release](https://github.com/microsoft/FLAML/issues/509)\\n18. [samples about conversion to ONNX](https://github.com/microsoft/FLAML/issues/429)\\n19. [support anomaly detection](https://github.com/microsoft/FLAML/issues/413)\\n20. [CatBoost Fails with Keyword 'groups'](https://github.com/microsoft/FLAML/issues/304)\"\n",
"Here are the open good first issues of FLAML. Please suggest a plan to fix one of them. The issues are: \n",
"\n",
"1. [Moving function execution out of UserProxyAgent to be an openai util](https://github.com/microsoft/FLAML/issues/1135)\n",
"2. [use_label_encoder warning with xgboost](https://github.com/microsoft/FLAML/issues/1120)\n",
"3. [Use appropriate wait time for retry based on the error message](https://github.com/microsoft/FLAML/issues/1034)\n",
"4. [Issues with Adding Custom APIs in Auto Generation](https://github.com/microsoft/FLAML/issues/1029)\n",
"5. [Running flaml[tune] using \"-O\" flag for python interpreter (optimization - disables assertions) crashes](https://github.com/microsoft/FLAML/issues/981)\n",
"11. [Isolate the ensemble part and expose it to users](https://github.com/microsoft/FLAML/issues/807)\n",
"12. [how to pass categorical features names or indices to learner](https://github.com/microsoft/FLAML/issues/805)\n",
"13. [Flaml/LightGBM - Shouldn't I found better/faster or equal results from FLAML than direct LightGBM?](https://github.com/microsoft/FLAML/issues/785)\n",
"14. [Add an announcement of the discord channel](https://github.com/microsoft/FLAML/issues/764)\n",
"15. [Documentation about small budget](https://github.com/microsoft/FLAML/issues/748)\n",
"16. [Make zero-shot automl more discoverable](https://github.com/microsoft/FLAML/issues/737)\n",
"Go through the FLAML repository's source code, specifically the part that deals with xgboost implementation. Check if the 'use_label_encoder' parameter is actually used during model training. If yes, inspect which value it has been assigned and try to find out why this parameter may be causing the warning.\n",
"2. Understand the role of use_label_encoder in XGBoost:\n",
"Understand what the 'use_label_encoder' parameter does and why it would be important to XGBoost. This might require studying XGBoost's documentation and community discussions, particularly any discussions related to this warning.\n",
"3. Suggest modification safely without affecting model performance and other functionalities:\n",
"Once you understand the role and importance of the 'use_label_encoder parameter', think about how you could modify its usage in FLAML's XGBoost implementation to prevent the warning. The plan you design should preserve the current functionalities and not negatively impact the model's performance.\n",
"After changing your code, thoroughly test it to make sure the warning is no longer appearing and that your changes haven't caused any other issues. This involves running existing unit tests and creating new tests if necessary.\n",
"Having made your changes and ensured everything is working correctly, submit your modification as a pull request to the original FLAML repository and follow any steps they have for the contribution process. \n",
"Go through the FLAML repository's source code, specifically the part that deals with xgboost implementation. Check if the 'use_label_encoder' parameter is actually used during model training. If yes, inspect which value it has been assigned and try to find out why this parameter may be causing the warning.\n",
"2. Understand the role of use_label_encoder in XGBoost:\n",
"Understand what the 'use_label_encoder' parameter does and why it would be important to XGBoost. This might require studying XGBoost's documentation and community discussions, particularly any discussions related to this warning.\n",
"3. Suggest modification safely without affecting model performance and other functionalities:\n",
"Once you understand the role and importance of the 'use_label_encoder parameter', think about how you could modify its usage in FLAML's XGBoost implementation to prevent the warning. The plan you design should preserve the current functionalities and not negatively impact the model's performance.\n",
"After changing your code, thoroughly test it to make sure the warning is no longer appearing and that your changes haven't caused any other issues. This involves running existing unit tests and creating new tests if necessary.\n",
"Having made your changes and ensured everything is working correctly, submit your modification as a pull request to the original FLAML repository and follow any steps they have for the contribution process. \n",
"1. **Investigate why the warning is raised**: This step involves going through the FLAML repository's source code, specifically the part that deals with xgboost implementation. You need to check if the 'use_label_encoder' parameter is actually used during model training. If yes, inspect which value it has been assigned and try to find out why this parameter may be causing the warning.\n",
"2. **Understand the role of use_label_encoder in XGBoost**: This step requires studying XGBoost's documentation and community discussions, particularly any discussions related to this warning. You need to understand what the 'use_label_encoder' parameter does and why it would be important to XGBoost.\n",
"3. **Suggest modification safely without affecting model performance and other functionalities**: Once you understand the role and importance of the 'use_label_encoder parameter', you need to think about how you could modify its usage in FLAML's XGBoost implementation to prevent the warning. The plan you design should preserve the current functionalities and not negatively impact the model's performance.\n",
"4. **Implement the plan**: Once you have a modification plan, you need to implement it in the code. You should follow any code style guides or standards set by the FLAML project.\n",
"5. **Test the changes**: After changing your code, you need to thoroughly test it to make sure the warning is no longer appearing and that your changes haven't caused any other issues. This involves running existing unit tests and creating new tests if necessary.\n",
"7. **Create a Pull Request**: Having made your changes and ensured everything is working correctly, you should submit your modification as a pull request to the original FLAML repository and follow any steps they have for the contribution process.\n",
"8. **Respond to review**: The reviewers may have comments or require changes, you should be ready to address any that come up until the solution is accepted.\n",
"When the assistant needs to consult the planner, it suggests a function call to `ask_planner`. When this happens, a line like the following will be displayed:\n",
"\n",
"***** Suggested function Call: ask_planner *****\n"