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

Conversation

rohanthacker
Copy link
Contributor

@rohanthacker rohanthacker commented Dec 16, 2024

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
@ekzhu
Copy link
Collaborator

ekzhu commented Dec 18, 2024

@lspinheiro could you help reviewing this PR?

@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.

@rohanthacker rohanthacker force-pushed the feature/azure-ai-inference-client branch from d53421b to daf43de Compare December 30, 2024 14:19
Copy link
Collaborator

@ekzhu ekzhu left a 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?

@ekzhu ekzhu marked this pull request as ready for review January 13, 2025 23:33
@ekzhu
Copy link
Collaborator

ekzhu commented Jan 13, 2025

@rohanthacker I made this PR ready for review.

@ekzhu ekzhu added this to the 0.4.1 milestone Jan 13, 2025
@lspinheiro lspinheiro self-assigned this Jan 20, 2025
@lspinheiro lspinheiro added models Pertains to using alternate, non-GPT, models (e.g., local models, llama, etc.) proj-extensions labels Jan 20, 2025
@lspinheiro
Copy link
Collaborator

@ekzhu For context, this works for Azure AI Inference. I tested on a Phi-4 deployment I created.

from semantic_kernel import Kernel
from semantic_kernel.memory.null_memory import NullMemory
from semantic_kernel.connectors.ai.azure_ai_inference import AzureAIInferenceChatCompletion
from semantic_kernel.connectors.ai.azure_ai_inference import AzureAIInferenceChatPromptExecutionSettings
from autogen_core.models import SystemMessage, UserMessage, LLMMessage
from autogen_ext.models.semantic_kernel import SKChatCompletionAdapter


kernel = Kernel(memory=NullMemory())

execution_settings = AzureAIInferenceChatPromptExecutionSettings(
    max_tokens=100,
    temperature=0.5,
    top_p=0.9,
)

chat_completion_service = AzureAIInferenceChatCompletion(ai_model_id="Phi-4")
model_adapter = SKChatCompletionAdapter(sk_client=chat_completion_service)

messages: list[LLMMessage] = [
    SystemMessage(content="You are a helpful assistant."),
    UserMessage(content="What is 2 + 2?", source="user"),
]

azure_result = await model_adapter.create(
    messages=messages,
    extra_create_args={"kernel": kernel, "prompt_execution_settings": execution_settings},
)
print("Azure result:", azure_result.content)

@rohanthacker rohanthacker requested a review from ekzhu January 23, 2025 21:43
@rohanthacker
Copy link
Contributor Author

rohanthacker commented Jan 23, 2025

To avoid confusion and prevent overwriting each others work. I am closing this pull request in favor of #5153

However I would really appreciate a callout (reddit/docs, etc) if and when this goes live

@lspinheiro
Copy link
Collaborator

Thanks @rohanthacker , I had just fixed the typing/linting issues in your PR but I couldn't push the changes to your branch. If I knew you would pick it up again I could have made a PR in your fork. Anyway, I will try to get this done today.

@rohanthacker
Copy link
Contributor Author

@lspinheiro No worries, Thank you for the guidance and suggestions on the PR.

@jackgerrits
Copy link
Member

Thanks for all of your work to get it to this point @rohanthacker! We'll make sure to call out, and since the @lspinheiro's PR continues based on your commits you will also be credited as co-author in the commit history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models Pertains to using alternate, non-GPT, models (e.g., local models, llama, etc.) proj-extensions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Azure AI inference
5 participants