Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve component config, add description support in dump_component (#…
…5203) <!-- Thank you for your contribution! Please review https://microsoft.github.io/autogen/docs/Contribute before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? It is currently hard to add a description to a component (defaults to None also) .. you have to call super.dump() modify and return. This PR makes the experience better. - allows you specify `component_description` and `component_label` as an optional class var. label is an optional human readable name for the the component. - will use component_description if provided int he description field when dumped if there is no description, will use the first line of class docstring. Takes advantage of all the good practices we have in writing good docstrings. label defaults to component type. For example ```python model_client=OpenAIChatCompletionClient( model="gpt-4o-2024-08-06" ) config = model_client.dump_component() print(config.model_dump_json()) ``` Note the description field below is no longer None and there is a label ```python { "provider": "autogen_ext.models.openai.OpenAIChatCompletionClient", "component_type": "model", "version": 1, "component_version": 1, "description": "Chat completion client for OpenAI hosted models.", "label": "OpenAIChatCompletionClient", "config": { "model": "gpt-4o-2024-08-06" } } ``` <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number <!-- For example: "Closes #1234" --> None, felt faster to fix. ## Checks - [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed.
- Loading branch information