Skip to content

Updating Python Chat App#1137

Open
mrm9084 wants to merge 1 commit intomainfrom
PythonChatAppUpdate
Open

Updating Python Chat App#1137
mrm9084 wants to merge 1 commit intomainfrom
PythonChatAppUpdate

Conversation

@mrm9084
Copy link
Member

@mrm9084 mrm9084 commented Feb 27, 2026

No description provided.

@mrm9084 mrm9084 requested a review from Copilot February 27, 2026 22:58
response = chat_client.complete(
model=CHAT_COMPLETION_CONFIG.model,
messages=chat_messages,
max_tokens=CHAT_COMPLETION_CONFIG.max_tokens,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is currently removed due to a bug in the python sdk Azure/azure-sdk-for-python#44455

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Python ChatApp sample to use Azure AI Foundry (via azure-ai-inference) instead of the openai Azure OpenAI client, while keeping Azure App Configuration as the settings source.

Changes:

  • Swap dependency from openai to azure-ai-inference.
  • Rename and simplify configuration models from “Azure OpenAI” to “Azure AI Foundry”.
  • Update the app to create a ChatCompletionsClient using DefaultAzureCredential and invoke complete(...).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
examples/Python/ChatApp/requirements.txt Replaces openai dependency with azure-ai-inference.
examples/Python/ChatApp/models.py Renames service config model and reshapes chat completion configuration fields.
examples/Python/ChatApp/app.py Switches client creation and chat completion call to Azure AI Foundry inference client.
examples/Python/ChatApp/README.md Updates sample documentation to reference Azure AI Foundry and new configuration keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 69 to 70
chat_messages = list(CHAT_COMPLETION_CONFIG.messages)
chat_messages.extend(chat_conversation)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

ChatCompletionConfiguration.messages is optional (defaults to None), but main() unconditionally does list(CHAT_COMPLETION_CONFIG.messages). If messages isn’t configured in App Configuration, this will raise TypeError: 'NoneType' object is not iterable. Consider making messages required, or defaulting it to an empty list (e.g., via default_factory=list) and/or handling None here.

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 33
model: Optional[str] = None
max_completion_tokens: Optional[int] = None
reasoning_effort: Optional[str] = None
verbosity: Optional[str] = None
stream: Optional[bool] = None
messages: Optional[List[Dict[str, str]]] = None
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

messages is typed as Optional[...] = None, but the application logic expects a list of messages to always exist (it clones and extends it each turn). Consider changing this field to a non-optional list with a default_factory=list to reflect actual usage and avoid None at runtime.

Copilot uses AI. Check for mistakes.
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.

2 participants