-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Adding async support to get_human_input #466
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
613a5dd
Adding async support to get_human_input
bonadio 9cf71ec
Adjust code for Code formatting testing fail
bonadio c0b6600
Adjust the test_async_get_human_input.py to run async on test
bonadio d868629
Adjust the test_async_get_human_input.py for pre-commit-check error
bonadio 86c6cc4
Adjust the test_async_get_human_input.py for pre-commit-check error v2
bonadio fbc9f6c
Adjust remove unnecessary register_reply
bonadio 21053d7
Adjust test to use asyncio call
bonadio 01581fd
Adjust go back to not use asyncio
bonadio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import asyncio | ||
| import autogen | ||
| import pytest | ||
| from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_async_get_human_input(): | ||
| try: | ||
| import openai | ||
| except ImportError: | ||
| return | ||
| config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) | ||
|
|
||
| # create an AssistantAgent instance named "assistant" | ||
| assistant = autogen.AssistantAgent( | ||
| name="assistant", | ||
| max_consecutive_auto_reply=2, | ||
| llm_config={"request_timeout": 600, "seed": 41, "config_list": config_list, "temperature": 0}, | ||
| ) | ||
|
|
||
| user_proxy = autogen.UserProxyAgent(name="user", human_input_mode="ALWAYS", code_execution_config=False) | ||
|
|
||
| async def custom_a_get_human_input(prompt): | ||
| return "This is a test" | ||
|
|
||
| user_proxy.a_get_human_input = custom_a_get_human_input | ||
|
|
||
| user_proxy.register_reply([autogen.Agent, None], autogen.ConversableAgent.a_check_termination_and_human_reply) | ||
|
|
||
| await user_proxy.a_initiate_chat(assistant, clear_history=True, message="Hello.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_async_get_human_input() | ||
sonichi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.