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

Added Azure AI Chat Completion Client #4723

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rohanthacker
Copy link
Contributor

Related issue number

#4683 Adds initial support for Azure AI Chat Completion Client

Checks

@ekzhu
Copy link
Collaborator

ekzhu commented Dec 16, 2024

@yanivvak can you review this?

@yanivvak
Copy link

yanivvak commented Dec 17, 2024

@ekzhu @rohanthacker
Great work, I tried to deploy with 3 different options offered by Azure AI inference SDK

  1. Azure open AI - works good, I tried it with magnetic one, the websurfer got stucked, can you take a look?
  2. Serverless - it works, but I didn't got the full answer it was phi 3.5
  3. Managed compute - it didn't run for me, I assume it's an issue with the endpoint and it is not related to your code

@yanivvak
Copy link

@ekzhu ekzhu linked an issue Dec 17, 2024 that may be closed by this pull request
@@ -50,6 +50,9 @@ video-surfer = [
grpc = [
"grpcio~=1.62.0", # TODO: update this once we have a stable version.
]
azure-ai-inference = [
"azure-ai-inference>=1.0.0b6",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason for this version lower bound?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is not intentional, this is what gets added when i run uv add "azure-ai-inference" --optional azure-ai-inference.
Is there another command I should use? I'm not experienced with uv

usage=usage,
cached=False,
)
yield result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update object-level usage data.

usage=usage,
cached=False,
)
return response
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update object-level usage data.

raise ValueError("Model does not support JSON output")

if json_output is True:
create_args["response_format"] = ChatCompletionsResponseFormatJSON()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to check existing response_format value to make sure we aren't overwriting it.

return name


class AzureAIChatCompletionClient(ChatCompletionClient):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekzhu
Copy link
Collaborator

ekzhu commented Dec 18, 2024

@lspinheiro could you help reviewing this PR?


class AzureAIChatCompletionClient(ChatCompletionClient):
def __init__(self, **kwargs: Unpack[AzureAIChatCompletionClientConfig]):
if "endpoint" not in kwargs:
Copy link
Collaborator

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

@lspinheiro
Copy link
Collaborator

@lspinheiro could you help reviewing this PR?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Azure AI inference
4 participants