File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Copyright (c) Microsoft Corporation.
2- # Licensed under the MIT license.
3- #
1+ # -------------------------------------------------------------------------
2+ # Copyright (c) Microsoft Corporation. All rights reserved.
3+ # Licensed under the MIT License. See License.txt in the project root for
4+ # license information.
5+ # --------------------------------------------------------------------------
6+ """
7+ Azure App Configuration Chat Application using Azure OpenAI.
8+ This module provides a simple chat application that uses configurations from Azure App Configuration
9+ and connects to Azure OpenAI services for chat completions.
10+ """
411import os
12+ from typing import TypeVar , List
513from azure .identity import DefaultAzureCredential , get_bearer_token_provider
614from azure .appconfiguration .provider import load , SettingSelector
715from openai import AzureOpenAI
816from models import ModelConfiguration , Message
9- from typing import TypeVar , List
1017
1118# Get Azure App Configuration endpoint from environment variable
1219ENDPOINT = os .environ .get ("AZURE_APPCONFIG_ENDPOINT" )
2229chat_app_selector = SettingSelector (key_filter = "ChatApp:*" )
2330
2431# Load configuration from Azure App Configuration
25- global config
2632config = load (
2733 endpoint = ENDPOINT ,
2834 selects = [chat_app_selector ],
Original file line number Diff line number Diff line change 1- # Copyright (c) Microsoft Corporation.
2- # Licensed under the MIT license.
3- #
1+ # -------------------------------------------------------------------------
2+ # Copyright (c) Microsoft Corporation. All rights reserved.
3+ # Licensed under the MIT License. See License.txt in the project root for
4+ # license information.
5+ # --------------------------------------------------------------------------
6+ """
7+ Model classes for Azure OpenAI Chat Application.
8+ This module provides data classes for representing chat messages and model configurations
9+ used in the Azure OpenAI-powered chat application.
10+ """
411from typing import List , Optional , Dict , Any
512
613
@@ -11,6 +18,7 @@ class Message:
1118 """
1219
1320 def __init__ (self , role : Optional [str ] = None , content : Optional [str ] = None ):
21+ """Initialize a Message instance with role and content."""
1422 self .role = role
1523 self .content = content
1624
@@ -34,6 +42,7 @@ def __init__(
3442 temperature : float = 0.7 ,
3543 top_p : float = 0.95 ,
3644 ):
45+ """Initialize model configuration with parameters for OpenAI API calls."""
3746 self .model = model
3847 self .messages = messages or []
3948 self .max_tokens = int (max_tokens ) if max_tokens is not None else 1024
You can’t perform that action at this time.
0 commit comments