Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update assistant agent #1121

Merged
merged 16 commits into from
Jul 15, 2023
4 changes: 2 additions & 2 deletions .github/workflows/openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ jobs:
WOLFRAM_ALPHA_APPID: ${{ secrets.WOLFRAM_ALPHA_APPID }}
run: |
pip install nbconvert nbformat ipykernel
coverage run -a -m pytest test/autogen/oai/test_notebook.py
coverage run -a -m pytest test/autogen/test_notebook.py
coverage xml
cat "$(pwd)/test/autogen/oai/executed_openai_notebook_output.txt"
cat "$(pwd)/test/autogen/executed_openai_notebook_output.txt"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions flaml/autogen/agent/assistant_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


class AssistantAgent(Agent):
"""(Experimental) Assistant agent, able to suggest code blocks."""
"""(Experimental) Assistant agent, able to suggest code blocks with default system message."""

DEFAULT_SYSTEM_MESSAGE = """You are a helpful AI assistant.
In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute. You must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code.
1. When you need to ask the user for some info, use the code to output the info you need, for example, browse or search the web, download/read a file.
In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute. You must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.
1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file.
2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly. Solve the task step by step if you need to.
If you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.
If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes.
Verify your answer carefully. If a function for planning is provided, call the function to make plans and verify the execution.
If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
When you find an answer, verify the answer carefully. If a function for planning is provided, call the function to make plans and verify the execution.
Reply "TERMINATE" in the end when everything is done.
"""

Expand Down
2 changes: 1 addition & 1 deletion flaml/autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _get_response(cls, config: Dict, raise_error=False, use_cache=True):
logger.info(f"retrying in {cls.retry_time} seconds...", exc_info=1)
sleep(cls.retry_time)
except APIError as err:
error_code = err and err.json_body and err.json_body.get("error")
error_code = err and err.json_body and isinstance(err.json_body, dict) and err.json_body.get("error")
error_code = error_code and error_code.get("code")
if error_code == "content_filter":
raise
Expand Down
2 changes: 1 addition & 1 deletion flaml/autogen/oai/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def config_list_openai_aoai(
# Assuming Azure OpenAI api bases in os.environ["AZURE_OPENAI_API_BASE"], in separated lines
api_bases=os.environ.get("AZURE_OPENAI_API_BASE", "").split("\n"),
api_type="azure",
api_version="2023-03-15-preview", # change if necessary
api_version="2023-06-01-preview", # change if necessary
)
if exclude != "aoai"
else []
Expand Down
2 changes: 1 addition & 1 deletion flaml/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.0rc3"
__version__ = "2.0.0rc4"
Loading
Loading