-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Added Azure AI Chat Completion Client #4723
base: main
Are you sure you want to change the base?
Added Azure AI Chat Completion Client #4723
Conversation
@yanivvak can you review this? |
@ekzhu @rohanthacker
|
python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py
Show resolved
Hide resolved
python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py
Show resolved
Hide resolved
python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py
Show resolved
Hide resolved
python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py
Show resolved
Hide resolved
@lspinheiro could you help reviewing this PR? |
|
||
class AzureAIChatCompletionClient(ChatCompletionClient): | ||
def __init__(self, **kwargs: Unpack[AzureAIChatCompletionClientConfig]): | ||
if "endpoint" not in kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this part could benefit from some better separation of concerns between config validation and instantiation. e.g.
class AzureAIChatCompletionClient(ChatCompletionClient):
def __init__(self, **kwargs: Unpack[AzureAIClientConfiguration]):
config = self._validate_config(kwargs)
self._client = self._create_client(config)
self._create_args = self._prepare_create_args(config)
# ...
@staticmethod
def _validate_config(config: Mapping[str, Any]) -> AzureAIClientConfiguration:
# Validation logic here
return config
Looks quite good and is consistent with the openai client. I have a minor comment about the config validation. @jackgerrits may have more options since a lot of the design decisions here are driven by his original implementation of the openai client. If anything doesn't make since in this context he would be the best person to evaluate. |
* Added: object-level usage data * Added: doc string * Added: check existing response_format value * Added: _validate_config and _create_client
d53421b
to
daf43de
Compare
content = choice.message.content or "" | ||
|
||
response = CreateResult( | ||
finish_reason=finish_reason, # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the latest update to canonicalize the finish_reason. See OpenAIChatCompletionClient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rohanthacker Is this PR ready to review? It looks good from code perspective. @srjoglekar246 could you help to use it in an assistant agent and running some teams on it to test it out?
|
||
def __init__(self, **kwargs: Unpack[AzureAIChatCompletionClientConfig]): | ||
config = self._validate_config(kwargs) | ||
self._model_capabilities = config["model_capabilities"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Model Capabilities are deprecated, use ModelInfo
. See OpenAIChatCompletionClient: https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py#L912-L913
client = AzureAIChatCompletionClient( | ||
endpoint="endpoint", | ||
credential=AzureKeyCredential("api_key"), | ||
model_capabilities={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use model_info
as model_capabilities
is deprecated.
@rohanthacker I made this PR ready for review. |
Related issue number
#4683 Adds initial support for Azure AI Chat Completion Client
Checks