Skip to content

Commit 4fcd7fa

Browse files
committed
Update variables
1 parent a1f2e4e commit 4fcd7fa

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

text_2_sql/autogen/src/autogen_text_2_sql/creators/llm_model_creator.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,15 @@ def get_model(cls, model_name: str) -> AzureOpenAIChatCompletionClient:
3030

3131
@classmethod
3232
def get_authentication_properties(cls) -> dict:
33-
if get_identity_type() == IdentityType.SYSTEM_ASSIGNED:
33+
if get_identity_type() in [
34+
IdentityType.SYSTEM_ASSIGNED,
35+
IdentityType.USER_ASSIGNED,
36+
]:
3437
# Create the token provider
3538
api_key = None
3639
token_provider = get_bearer_token_provider(
3740
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
3841
)
39-
elif get_identity_type() == IdentityType.USER_ASSIGNED:
40-
# Create the token provider
41-
api_key = None
42-
token_provider = get_bearer_token_provider(
43-
DefaultAzureCredential(
44-
managed_identity_client_id=os.environ["ClientId"]
45-
),
46-
"https://cognitiveservices.azure.com/.default",
47-
)
4842
else:
4943
token_provider = None
5044
api_key = os.environ["OpenAI__ApiKey"]

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/ai_search.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,11 @@ async def add_entry_to_index(document: dict, vector_fields: dict, index_name: st
289289
document["Question"].encode()
290290
).decode("utf-8")
291291

292-
if identity_type == IdentityType.SYSTEM_ASSIGNED:
292+
if identity_type in [
293+
IdentityType.SYSTEM_ASSIGNED,
294+
IdentityType.USER_ASSIGNED,
295+
]:
293296
credential = DefaultAzureCredential()
294-
elif identity_type == IdentityType.USER_ASSIGNED:
295-
credential = DefaultAzureCredential(
296-
managed_identity_client_id=os.environ["ClientID"]
297-
)
298297
else:
299298
credential = AzureKeyCredential(
300299
os.environ["AIService__AzureSearchOptions__Key"]

text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/data_dictionary_creator.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,14 @@ async def send_request_to_llm(self, system_prompt: str, input: str):
645645
api_version = os.environ["OpenAI__ApiVersion"]
646646
model = os.environ["OpenAI__CompletionDeployment"]
647647

648-
if get_identity_type() == IdentityType.SYSTEM_ASSIGNED:
648+
if get_identity_type() in [
649+
IdentityType.SYSTEM_ASSIGNED,
650+
IdentityType.USER_ASSIGNED,
651+
]:
649652
token_provider = get_bearer_token_provider(
650653
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
651654
)
652655
api_key = None
653-
elif get_identity_type() == IdentityType.USER_ASSIGNED:
654-
token_provider = get_bearer_token_provider(
655-
DefaultAzureCredential(
656-
managed_identity_client_id=os.environ["FunctionApp__ClientId"]
657-
),
658-
"https://cognitiveservices.azure.com/.default",
659-
)
660-
api_key = None
661656
else:
662657
token_provider = None
663658
api_key = os.environ["OpenAI__ApiKey"]

0 commit comments

Comments
 (0)