File tree Expand file tree Collapse file tree
src/ContentProcessor/src/libs/application Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from azure .identity import DefaultAzureCredential
1+ from azure .identity import DefaultAzureCredential , get_bearer_token_provider
2+ from semantic_kernel import Kernel
3+ from semantic_kernel .connectors .ai .open_ai import AzureChatCompletion
24
35from libs .application .application_configuration import AppConfiguration
46from libs .base .application_models import AppModelBase
@@ -12,9 +14,28 @@ class AppContext(AppModelBase):
1214
1315 configuration : AppConfiguration = None
1416 credential : DefaultAzureCredential = None
17+ kernel : Kernel = None
1518
1619 def set_configuration (self , configuration : AppConfiguration ):
1720 self .configuration = configuration
1821
1922 def set_credential (self , credential : DefaultAzureCredential ):
2023 self .credential = credential
24+
25+ def set_kernel (self ):
26+ kernel = Kernel ()
27+
28+ kernel .add_service (
29+ AzureChatCompletion (
30+ service_id = "vision-agent" ,
31+ endpoint = self .configuration .app_azure_openai_endpoint ,
32+ # api_key=self.app_config.azure_openai_key,
33+ ad_token_provider = get_bearer_token_provider (
34+ DefaultAzureCredential (),
35+ "https://cognitiveservices.azure.com/.default" ,
36+ ),
37+ deployment_name = self .configuration .app_azure_openai_model ,
38+ )
39+ )
40+
41+ self .kernel = kernel
You can’t perform that action at this time.
0 commit comments