* Validate llm_config passed to ConversableAgent
Based on #1522, this commit implements the additional validation checks in
`ConversableAgent.`
Add the following validation and `raise ValueError` if:
- The `llm_config` is `None`.
- The `llm_config` is valid, but `config_list` is missing or lacks elements.
- The `config_list` is valid, but no `model` is specified.
The rest of the changes are code churn to adjust or add the test cases.
* Validate llm_config passed to ConversableAgent
Based on #1522, this commit implements the additional validation checks in
`ConversableAgent.`
Add the following validation and `raise ValueError` if:
- The `llm_config` is `None` (validated in `ConversableAgent`).
- The `llm_config` has no `model` specified and `config_list` is empty
(validated in `OpenAIWrapper`).
- The `config_list` has at least one entry, but not all the entries have
the `model` is specified (validated in `OpenAIWrapper`).
The rest of the changes are code churn to adjust or add the test cases.
* Validate llm_config passed to ConversableAgent
Based on #1522, this commit implements the additional validation checks in
`ConversableAgent.`
Add the following validation and `raise ValueError` if:
- The `llm_config` is `None` (validated in `ConversableAgent`).
- The `llm_config` has no `model` specified and `config_list` is empty
(validated in `OpenAIWrapper`).
- The `config_list` has at least one entry, but not all the entries have
the `model` is specified (validated in `OpenAIWrapper`).
The rest of the changes are code churn to adjust or add the test cases.
* Validate llm_config passed to ConversableAgent
Based on #1522, this commit implements the additional validation checks in
`ConversableAgent.`
Add the following validation and `raise ValueError` if:
- The `llm_config` is `None` (validated in `ConversableAgent`).
- The `llm_config` has no `model` specified and `config_list` is empty
(validated in `OpenAIWrapper`).
- The `config_list` has at least one entry, but not all the entries have
the `model` is specified (validated in `OpenAIWrapper`).
The rest of the changes are code churn to adjust or add the test cases.
* Validate llm_config passed to ConversableAgent
Based on #1522, this commit implements the additional validation checks in
`ConversableAgent.`
Add the following validation and `raise ValueError` if:
- The `llm_config` is `None` (validated in `ConversableAgent`).
- The `llm_config` has no `model` specified and `config_list` is empty
(validated in `OpenAIWrapper`).
- The `config_list` has at least one entry, but not all the entries have
the `model` is specified (validated in `OpenAIWrapper`).
The rest of the changes are code churn to adjust or add the test cases.
* Fix the test_web_surfer issue
For anyone reading this: you need to `pip install markdownify` for the
`import WebSurferAgent` to succeed. That is needed to run the
`test_web_surfer.py` locally.
Test logic needs `llm_config` that is not `None` and that is not
`False`.
Let us pray that this works as part of GitHub actions ...
* One more fix for llm_config validation contract
* Validate the OpenAI API key format
Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.
* Add the validation in `__init__` of `OpenAIClient`.
* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.
* Add unit test coverage for the `is_valid_api_key` function.
* Validate the OpenAI API key format
Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.
* Add the validation in `__init__` of `OpenAIClient`.
* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.
*Add unit test coverage for the `is_valid_api_key` function.
* Log a warning when register a default client fails.
* Validate the OpenAI API key format
Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.
* Add the validation in `__init__` of `OpenAIClient`. We'll log a
warning when the OpenAI API key isn't valid.
* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.
* Add unit test coverage for the `is_valid_api_key` function.
* Check for OpenAI base_url before API key validation
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* function calling upgraded: async/sync mixing works now for all combinations and register_function added to simplify registration of functions without decorators
* polishing
* fixing tests
---------
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* Change last_n_messages to default to 'auto'
* Added last_n_messages validation, as per Eric's comment.
---------
Co-authored-by: Davor Runje <davor@airt.ai>
* documentation update and added tests for register_reply function
* added raising an exception on an async reply function in sync chat
* big fixing
* test expanded
* Update autogen/agentchat/conversable_agent.py
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* Update autogen/agentchat/conversable_agent.py
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* refactorization
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* bug fix for async functions
* Update test_conversable_agent.py
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* Update test/agentchat/test_conversable_agent.py
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* commented out cell in a notebook until issue #1205 is not fixed
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* adjust conversable and compressible agents to support tool_calls
* split out tools into their own reply def
* copilot typo
* address review comments
* revert compressible_agent and token_count_utils calls
* cleanup terminate check and remove unnecessary code
* doc search and update
* return function/tool calls as interrupted when user provides a reply to a tool call request
* fix tool name reference
* fix formatting
* fix initiate receiving a dict
* missed changed roled
* ignore incoming role, more similiar to existing code
* consistency
* redundant to_dict
* fix todo comment
* uneeded change
* handle dict reply in groupchat
* Fix generate_tool_call_calls_reply_comment
* change method annotation for register_for_llm from functions to tools
* typo autogen/agentchat/conversable_agent.py
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* add deprecation comments for function_call
* tweak doc strings
* switch to ToolFunction type
* update the return to
* fix generate_init_message return type
* Revert "fix generate_init_message return type"
This reverts commit 645ba8b76afa06f160223ecdac6f3dc1822fd249.
* undo force init to dict
* fix notebooks and groupchat tool handling
* fix type
* use get for key error
* fix teachable to pull content from dict
* change single message tool response
* cleanup unnessary changes
* little better tool response concatenation
* update tools tests
* add skip openai check to tools tests
* fix nits
* move func name normalization to oai_reply and assert configured names
* fix whitespace
* remove extra normalize
* tool name is now normalized in the generate_reply function, so will not be incorrect when sent to receive
* validate function names in init and expand comments for validation methods
* fix dict comprehension
* Dummy llm config for unit tests
* handle tool_calls set to None
* fix tool name reference
* method operates on responses not calls
---------
Co-authored-by: Yiran Wu <32823396+kevin666aa@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
* Remove GPT-4 as the default model.
* Updated test_compressible_agent to work around a bug that would otherwise default to gpt-4. Revist after #1073 is addressed.
* Worked around another bug in test_compressible_agent. It seems the config_list was always empty!
* Reverted changes to compressible agent.
* Noted that GPT-4 is the preferred model in the OAI_CONFIG_LIST_sample and README.
* Fixed failing tests after #1110
* Update OAI_CONFIG_LIST_sample
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* add function decorator to converasble agent
* polishing
* polishing
* added function decorator to the notebook with async function calls
* added support for return type hint and JSON encoding of returned value if needed
* polishing
* polishing
* refactored async case
* Python 3.8 support added
* polishing
* polishing
* missing docs added
* refacotring and changes as requested
* getLogger
* documentation added
* test fix
* test fix
* added testing of agentchat_function_call_currency_calculator.ipynb to test_notebook.py
* added support for Pydantic parameters in function decorator
* polishing
* Update website/docs/Use-Cases/agent_chat.md
Co-authored-by: Li Jiang <bnujli@gmail.com>
* Update website/docs/Use-Cases/agent_chat.md
Co-authored-by: Li Jiang <bnujli@gmail.com>
* fixes problem with logprob parameter in openai.types.chat.chat_completion.Choice added by openai version 1.5.0
* get 100% code coverage on code added
* updated docs
* default values added to JSON schema
* serialization using json.dump() add for values not string or BaseModel
* added limit to openai version because of breaking changes in 1.5.0
* added line-by-line comments in docs to explain the process
* polishing
---------
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: Li Jiang <bnujli@gmail.com>
* fix: typo
* fix: typo
* fix: typo of function name
* fix: typo of function name of test file
* Update test_token_count.py
---------
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
* Added an agent description field that can be distinct from the system_message, and be used to for orchestration (e.g., GroupChatManager, etc.)
* Added debugging.
* Moved default descriptions to constants.
* Fixed conditions under which the assistant uses the default description.
* Removed debugging.
* Updated GroupChat prompt.
* Re-added debugging.
* Removed double [[ ]].
* Another update to GroupSelection prompt.
* Changed 'people' to 'participants' since agents are not people.
* Changed 'role' to 'name'
* Removed debugging statements.
* Restored the default prompt. Created a contrib class with new prompt.
* Fixed documentation.
* Removed broken link.
* Fixed a warning message.
* Removed GroupChatModerator contrib. Will re-add in another PR
* Resolving comment.
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* Added an 'auto' mode to last_n_messages
* Added tests for the last_n_messages = 'auto' mode
* Added test one additional test case that was overlooked.
* Handled possible IndexError in ConversableAgent.last_message method with more clear error message and added test in test_conversable_agent.py.
* Fix code formatting issues.
---------
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* Replace `assert`s in the `conversable_agent` module with `if-log-raise`.
* Use a `logger` object in the `code_utils` module.
* Replace use of `assert` with `if-log-raise` in the `code_utils` module.
* Replace use of `assert` in the `math_utils` module with `if-not-raise`.
* Replace `assert` with `if` in the `oai.completion` module.
* Replace `assert` in the `retrieve_utils` module with an if statement.
* Add missing `not`.
* Blacken `completion.py`.
* Test `generate_reply` and `a_generate_reply` raise an assertion error
when there are neither `messages` nor a `sender`.
* Test `execute_code` raises an `AssertionError` when neither code nor
filename is provided.
* Test `split_text_to_chunks` raises when passed an invalid chunk mode.
* * Add `tiktoken` and `chromadb` to test dependencies as they're used in
the `test_retrieve_utils` module.
* Sort the test requirements alphabetically.
* minor fix for stablility
* fix format
* fix format
* update run_code logic
* format
* Update conversable_agent.py
* fix format
* Update conversable_agent.py
* add tests
* fix format
* revert changes