cwyodmodules 0.3.22__tar.gz → 0.3.24__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/PKG-INFO +1 -1
  2. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/database_factory.py +3 -2
  3. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/postgresdbservice.py +3 -2
  4. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py +7 -3
  5. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py +3 -4
  6. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py +4 -2
  7. cwyodmodules-0.3.24/cwyodmodules/batch/utilities/helpers/azure_identity_helper.py +63 -0
  8. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py +3 -2
  9. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py +3 -2
  10. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/azure_search_helper.py +8 -5
  11. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/env_helper.py +11 -5
  12. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/lightrag_helper.py +3 -2
  13. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/llm_helper.py +5 -2
  14. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/secret_helper.py +4 -2
  15. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py +4 -2
  16. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py +4 -2
  17. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py +4 -2
  18. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py +4 -2
  19. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/semantic_kernel_orchestrator.py +8 -7
  20. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py +6 -3
  21. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/content_safety_checker.py +5 -3
  22. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules.egg-info/PKG-INFO +1 -1
  23. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules.egg-info/SOURCES.txt +1 -0
  24. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/pyproject.toml +1 -1
  25. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/LICENSE +0 -0
  26. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/README.md +0 -0
  27. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/api/__init__.py +0 -0
  28. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/api/chat_history.py +0 -0
  29. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/__init__.py +0 -0
  30. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/__init__.py +0 -0
  31. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/auth_utils.py +0 -0
  32. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/cosmosdb.py +0 -0
  33. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/database_client_base.py +0 -0
  34. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/chat_history/sample_user.py +0 -0
  35. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/common/__init__.py +0 -0
  36. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/common/answer.py +0 -0
  37. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/common/source_document.py +0 -0
  38. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/__init__.py +0 -0
  39. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/chunking_strategy.py +0 -0
  40. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/document_chunking_base.py +0 -0
  41. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/fixed_size_overlap.py +0 -0
  42. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/layout.py +0 -0
  43. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/page.py +0 -0
  44. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/paragraph.py +0 -0
  45. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_chunking/strategies.py +0 -0
  46. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/__init__.py +0 -0
  47. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/document_loading_base.py +0 -0
  48. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/layout.py +0 -0
  49. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/read.py +0 -0
  50. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/strategies.py +0 -0
  51. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/web.py +0 -0
  52. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/document_loading/word_document.py +0 -0
  53. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/__init__.py +0 -0
  54. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/assistant_strategy.py +0 -0
  55. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/config_helper.py +0 -0
  56. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/conversation_flow.py +0 -0
  57. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/database_type.py +0 -0
  58. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/default.json +0 -0
  59. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/default_contract_assistant_prompt.txt +0 -0
  60. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/default_employee_assistant_prompt.txt +0 -0
  61. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/config/embedding_config.py +0 -0
  62. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/document_chunking_helper.py +0 -0
  63. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/document_loading_helper.py +0 -0
  64. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/embedders/embedder_base.py +0 -0
  65. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/embedders/embedder_factory.py +0 -0
  66. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/embedders/integrated_vectorization_embedder.py +0 -0
  67. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/embedders/postgres_embedder.py +0 -0
  68. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/embedders/push_embedder.py +0 -0
  69. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/helpers/orchestrator_helper.py +0 -0
  70. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/loggers/conversation_logger.py +0 -0
  71. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/__init__.py +0 -0
  72. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py +0 -0
  73. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/open_ai_functions.py +0 -0
  74. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/orchestration_strategy.py +0 -0
  75. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/orchestrator_base.py +0 -0
  76. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/prompt_flow.py +0 -0
  77. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/orchestrator/strategies.py +0 -0
  78. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/parser/__init__.py +0 -0
  79. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/parser/output_parser_tool.py +0 -0
  80. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/parser/parser_base.py +0 -0
  81. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/plugins/chat_plugin.py +0 -0
  82. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/plugins/outlook_calendar_plugin.py +0 -0
  83. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/plugins/post_answering_plugin.py +0 -0
  84. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/azure_search_handler.py +0 -0
  85. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/azure_search_handler_light_rag.py +0 -0
  86. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/lightrag_search_handler.py +0 -0
  87. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/postgres_search_handler.py +0 -0
  88. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/postgres_search_handler_light_rag.py +0 -0
  89. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/search.py +0 -0
  90. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/search/search_handler_base.py +0 -0
  91. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/__init__.py +0 -0
  92. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/answer_processing_base.py +0 -0
  93. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/answering_tool_base.py +0 -0
  94. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/post_prompt_tool.py +0 -0
  95. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/question_answer_tool.py +0 -0
  96. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/batch/utilities/tools/text_processing_tool.py +0 -0
  97. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/__init__.py +0 -0
  98. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/config.py +0 -0
  99. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/database/__init__.py +0 -0
  100. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/database/base.py +0 -0
  101. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/database/models.py +0 -0
  102. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/__init__.py +0 -0
  103. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/chunking.py +0 -0
  104. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/extraction.py +0 -0
  105. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/types.py +0 -0
  106. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/upsert.py +0 -0
  107. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/indexing/utils.py +0 -0
  108. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/llm/__init__.py +0 -0
  109. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/llm/llm.py +0 -0
  110. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/llm/prompt.py +0 -0
  111. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/main.py +0 -0
  112. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/query/__init__.py +0 -0
  113. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/query/generate.py +0 -0
  114. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/query/graph_search.py +0 -0
  115. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/query/types.py +0 -0
  116. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules/graphrag/query/vector_search.py +0 -0
  117. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules.egg-info/dependency_links.txt +0 -0
  118. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules.egg-info/requires.txt +0 -0
  119. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/cwyodmodules.egg-info/top_level.txt +0 -0
  120. {cwyodmodules-0.3.22 → cwyodmodules-0.3.24}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.22
3
+ Version: 0.3.24
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -2,14 +2,15 @@
2
2
  from ..helpers.env_helper import EnvHelper
3
3
  from .cosmosdb import CosmosConversationClient
4
4
  from .postgresdbservice import PostgresConversationClient
5
- from azure.identity import DefaultAzureCredential
6
5
  from ..helpers.config.database_type import DatabaseType
6
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
7
7
 
8
8
 
9
9
  class DatabaseFactory:
10
10
  @staticmethod
11
11
  def get_conversation_client():
12
12
  env_helper: EnvHelper = EnvHelper()
13
+ azure_identity_helper = AzureIdentityHelper()
13
14
 
14
15
  if env_helper.DATABASE_TYPE == DatabaseType.COSMOSDB.value:
15
16
  DatabaseFactory._validate_env_vars(
@@ -25,7 +26,7 @@ class DatabaseFactory:
25
26
  f"https://{env_helper.AZURE_COSMOSDB_ACCOUNT}.documents.azure.com:443/"
26
27
  )
27
28
  credential = (
28
- DefaultAzureCredential()
29
+ azure_identity_helper.get_credential()
29
30
  if not env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
30
31
  else env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
31
32
  )
@@ -1,6 +1,6 @@
1
1
  import asyncpg
2
2
  from datetime import datetime, timezone
3
- from azure.identity import DefaultAzureCredential
3
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
4
4
  from .database_client_base import DatabaseClientBase
5
5
 
6
6
  from logging import getLogger
@@ -18,6 +18,7 @@ class PostgresConversationClient(DatabaseClientBase):
18
18
  def __init__(
19
19
  self, user: str, host: str, database: str, enable_message_feedback: bool = False
20
20
  ):
21
+ self.azure_identity_helper = AzureIdentityHelper()
21
22
  self.user = user
22
23
  self.host = host
23
24
  self.database = database
@@ -27,7 +28,7 @@ class PostgresConversationClient(DatabaseClientBase):
27
28
  async def connect(self):
28
29
  with tracer.start_as_current_span("PostgresConversationClient.connect"):
29
30
  try:
30
- credential = DefaultAzureCredential()
31
+ credential = self.azure_identity_helper.get_credential()
31
32
  token = credential.get_token(
32
33
  "https://ossrdbms-aad.database.windows.net/.default"
33
34
  ).token
@@ -12,7 +12,7 @@ from azure.core.credentials import AzureNamedKeyCredential
12
12
  from azure.storage.queue import QueueClient, BinaryBase64EncodePolicy
13
13
  import chardet
14
14
  from .env_helper import EnvHelper
15
- from azure.identity import DefaultAzureCredential
15
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
16
16
 
17
17
 
18
18
  def connection_string(account_name: str, account_key: str):
@@ -22,10 +22,12 @@ def connection_string(account_name: str, account_key: str):
22
22
  def create_queue_client():
23
23
  env_helper: EnvHelper = EnvHelper()
24
24
  if env_helper.AZURE_AUTH_TYPE == "rbac":
25
+ azure_identity_helper = AzureIdentityHelper()
26
+ credential = azure_identity_helper.get_credential()
25
27
  return QueueClient(
26
28
  account_url=f"https://{env_helper.AZURE_BLOB_ACCOUNT_NAME}.queue.core.windows.net/",
27
29
  queue_name=env_helper.DOCUMENT_PROCESSING_QUEUE_NAME,
28
- credential=DefaultAzureCredential(),
30
+ credential=credential,
29
31
  message_encode_policy=BinaryBase64EncodePolicy(),
30
32
  )
31
33
 
@@ -47,6 +49,7 @@ class AzureBlobStorageClient:
47
49
  container_name: Optional[str] = None,
48
50
  ):
49
51
  env_helper: EnvHelper = EnvHelper()
52
+ self.azure_identity_helper = AzureIdentityHelper()
50
53
 
51
54
  self.auth_type = env_helper.AZURE_AUTH_TYPE
52
55
  self.account_name = account_name or env_helper.AZURE_BLOB_ACCOUNT_NAME
@@ -55,8 +58,9 @@ class AzureBlobStorageClient:
55
58
 
56
59
  if self.auth_type == "rbac":
57
60
  self.account_key = None
61
+ credential = self.azure_identity_helper.get_credential()
58
62
  self.blob_service_client = BlobServiceClient(
59
- account_url=self.endpoint, credential=DefaultAzureCredential()
63
+ account_url=self.endpoint, credential=credential
60
64
  )
61
65
  self.user_delegation_key = None
62
66
  self.user_delegation_key = self.request_user_delegation_key(
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  from urllib.parse import urljoin
3
- from azure.identity import DefaultAzureCredential, get_bearer_token_provider
3
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
4
4
 
5
5
  import requests
6
6
  from requests import Response
@@ -18,6 +18,7 @@ class AzureComputerVisionClient:
18
18
  __RESPONSE_VECTOR_KEY = "vector"
19
19
 
20
20
  def __init__(self, env_helper: EnvHelper) -> None:
21
+ self.azure_identity_helper = AzureIdentityHelper()
21
22
  self.host = env_helper.AZURE_COMPUTER_VISION_ENDPOINT
22
23
  self.timeout = env_helper.AZURE_COMPUTER_VISION_TIMEOUT
23
24
  self.key = env_helper.AZURE_COMPUTER_VISION_KEY
@@ -55,9 +56,7 @@ class AzureComputerVisionClient:
55
56
  if self.use_keys:
56
57
  headers["Ocp-Apim-Subscription-Key"] = self.key
57
58
  else:
58
- token_provider = get_bearer_token_provider(
59
- DefaultAzureCredential(), self.__TOKEN_SCOPE
60
- )
59
+ token_provider = self.azure_identity_helper.get_token_provider(url=self.__TOKEN_SCOPE)
61
60
  headers["Authorization"] = "Bearer " + token_provider()
62
61
 
63
62
  return requests.post(
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  from azure.core.credentials import AzureKeyCredential
3
3
  from azure.ai.formrecognizer import DocumentAnalysisClient
4
- from azure.identity import DefaultAzureCredential
4
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
5
5
  import html
6
6
  import traceback
7
7
  from .env_helper import EnvHelper
@@ -17,9 +17,11 @@ class AzureFormRecognizerClient:
17
17
  env_helper.AZURE_FORM_RECOGNIZER_ENDPOINT
18
18
  )
19
19
  if env_helper.AZURE_AUTH_TYPE == "rbac":
20
+ self.azure_identity_helper = AzureIdentityHelper()
21
+ credential = self.azure_identity_helper.get_credential()
20
22
  self.document_analysis_client = DocumentAnalysisClient(
21
23
  endpoint=self.AZURE_FORM_RECOGNIZER_ENDPOINT,
22
- credential=DefaultAzureCredential(),
24
+ credential=credential,
23
25
  headers={
24
26
  "x-ms-useragent": "chat-with-your-data-solution-accelerator/1.0.0"
25
27
  },
@@ -0,0 +1,63 @@
1
+ from azure.identity import (
2
+ ChainedTokenCredential,
3
+ ManagedIdentityCredential,
4
+ EnvironmentCredential,
5
+ TokenCachePersistenceOptions,
6
+ get_bearer_token_provider
7
+ )
8
+
9
+ from logging import getLogger
10
+ from opentelemetry import trace, baggage
11
+ from opentelemetry.propagate import extract
12
+
13
+ logger = getLogger("__main__")
14
+ tracer = trace.get_tracer("__main__")
15
+ class AzureIdentityHelper:
16
+ """
17
+ A helper class to provide a chained Azure token credential.
18
+ It prioritizes Managed Identity, then Environment variables.
19
+ Token caching is configured for in-memory persistence.
20
+ """
21
+ def __init__(self):
22
+ # Configure in-memory token cache persistence
23
+ # For in-memory, unencrypted storage is typically allowed for simplicity during development.
24
+ # In production, especially with shared environments, consider the security implications.
25
+ token_cache_options = TokenCachePersistenceOptions(allow_unencrypted_storage=True)
26
+
27
+ # Create individual credential instances
28
+ managed_identity_credential = ManagedIdentityCredential(
29
+ token_cache_persistence_options=token_cache_options
30
+ )
31
+ environment_credential = EnvironmentCredential(
32
+ token_cache_persistence_options=token_cache_options
33
+ )
34
+
35
+ # Create a chain of credentials
36
+ # The chain will try credentials in the order they are provided.
37
+ self._credential = ChainedTokenCredential(
38
+ managed_identity_credential,
39
+ environment_credential
40
+ )
41
+
42
+ def get_credential(self) -> ChainedTokenCredential:
43
+ """
44
+ Returns the configured ChainedTokenCredential.
45
+ """
46
+ with tracer.start_as_current_span("AzureIdentityHelper.get_credential"):
47
+ logger.info("Retrieving ChainedTokenCredential.")
48
+ return self._credential
49
+
50
+ def get_token_provider(self, url):
51
+ """
52
+ Returns the configured ChainedTokenCredential.
53
+ """
54
+ with tracer.start_as_current_span("AzureIdentityHelper.get_token_provider"):
55
+ logger.info("Retrieving ChainedTokenCredential provider.")
56
+ return get_bearer_token_provider(self._credential, url=url)
57
+
58
+
59
+ # Example usage (optional, for testing or demonstration):
60
+ if __name__ == "__main__":
61
+ helper = AzureIdentityHelper()
62
+ credential = helper.get_credential()
63
+ print("Successfully created ChainedTokenCredential.")
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import psycopg2
3
3
  from psycopg2.extras import execute_values, RealDictCursor
4
- from azure.identity import DefaultAzureCredential
4
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
5
5
  from .llm_helper import LLMHelper
6
6
  from .env_helper import EnvHelper
7
7
 
@@ -12,6 +12,7 @@ class AzurePostgresHelper:
12
12
  def __init__(self):
13
13
  self.llm_helper = LLMHelper()
14
14
  self.env_helper = EnvHelper()
15
+ self.azure_identity_helper = AzureIdentityHelper()
15
16
  self.conn = None
16
17
 
17
18
  def _create_search_client(self):
@@ -24,7 +25,7 @@ class AzurePostgresHelper:
24
25
  dbname = self.env_helper.POSTGRESQL_DATABASE
25
26
 
26
27
  # Acquire the access token
27
- credential = DefaultAzureCredential()
28
+ credential = self.azure_identity_helper.get_credential()
28
29
  access_token = credential.get_token(
29
30
  "https://ossrdbms-aad.database.windows.net/.default"
30
31
  )
@@ -1,10 +1,10 @@
1
1
  import logging
2
2
  import psycopg2
3
3
  from psycopg2.extras import execute_values, RealDictCursor
4
- from azure.identity import DefaultAzureCredential
5
4
  from .llm_helper import LLMHelper
6
5
  from .env_helper import EnvHelper
7
6
  from .lightrag_helper import LightRAGHelper
7
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
8
8
 
9
9
  logger = logging.getLogger(__name__ + ".base_package")
10
10
 
@@ -14,6 +14,7 @@ class AzurePostgresHelper:
14
14
  self.llm_helper = LLMHelper()
15
15
  self.env_helper = EnvHelper()
16
16
  self.lightrag_helper = LightRAGHelper()
17
+ self.azure_identity_helper = AzureIdentityHelper()
17
18
  self.conn = None
18
19
 
19
20
  def _create_search_client(self):
@@ -26,7 +27,7 @@ class AzurePostgresHelper:
26
27
  dbname = self.env_helper.POSTGRESQL_DATABASE
27
28
 
28
29
  # Acquire the access token
29
- credential = DefaultAzureCredential()
30
+ credential = self.azure_identity_helper.get_credential()
30
31
  access_token = credential.get_token(
31
32
  "https://ossrdbms-aad.database.windows.net/.default"
32
33
  )
@@ -1,8 +1,9 @@
1
1
  import logging
2
+ from azure.identity import ChainedTokenCredential
2
3
  from typing import Union
3
4
  from langchain_community.vectorstores import AzureSearch
4
5
  from azure.core.credentials import AzureKeyCredential
5
- from azure.identity import DefaultAzureCredential
6
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
6
7
  from azure.search.documents import SearchClient
7
8
  from azure.search.documents.indexes import SearchIndexClient
8
9
  from azure.search.documents.indexes.models import (
@@ -39,7 +40,8 @@ class AzureSearchHelper:
39
40
  def __init__(self):
40
41
  self.llm_helper = LLMHelper()
41
42
  self.env_helper = EnvHelper()
42
-
43
+ self.azure_identity_helper = AzureIdentityHelper()
44
+
43
45
  search_credential = self._search_credential()
44
46
  self.search_client = self._create_search_client(search_credential)
45
47
  self.search_index_client = self._create_search_index_client(search_credential)
@@ -49,10 +51,11 @@ class AzureSearchHelper:
49
51
  if self.env_helper.is_auth_type_keys():
50
52
  return AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
51
53
  else:
52
- return DefaultAzureCredential()
54
+ credential = self.azure_identity_helper.get_credential()
55
+ return credential
53
56
 
54
57
  def _create_search_client(
55
- self, search_credential: Union[AzureKeyCredential, DefaultAzureCredential]
58
+ self, search_credential: Union[AzureKeyCredential, ChainedTokenCredential]
56
59
  ) -> SearchClient:
57
60
  return SearchClient(
58
61
  endpoint=self.env_helper.AZURE_SEARCH_SERVICE,
@@ -61,7 +64,7 @@ class AzureSearchHelper:
61
64
  )
62
65
 
63
66
  def _create_search_index_client(
64
- self, search_credential: Union[AzureKeyCredential, DefaultAzureCredential]
67
+ self, search_credential: Union[AzureKeyCredential, ChainedTokenCredential]
65
68
  ):
66
69
  return SearchIndexClient(
67
70
  endpoint=self.env_helper.AZURE_SEARCH_SERVICE, credential=search_credential
@@ -1,16 +1,23 @@
1
1
  import json
2
2
  import os
3
- import logging
4
3
 
5
4
  import threading
6
5
  # from dotenv import load_dotenv
7
- from azure.identity import DefaultAzureCredential, get_bearer_token_provider
8
6
  from ..orchestrator.orchestration_strategy import OrchestrationStrategy
9
7
  from ..helpers.config.conversation_flow import ConversationFlow
10
8
  from ..helpers.config.database_type import DatabaseType
11
9
  from ..helpers.secret_helper import SecretHelper
10
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
11
+
12
+ from logging import getLogger
13
+ from opentelemetry import trace, baggage
14
+ from opentelemetry.propagate import extract
15
+
16
+ # logger = getLogger("__main__" + ".base_package")
17
+ logger = getLogger("__main__")
18
+ # tracer = trace.get_tracer("__main__" + ".base_package")
19
+ tracer = trace.get_tracer("__main__")
12
20
 
13
- logger = logging.getLogger(__name__ + ".base_package")
14
21
 
15
22
 
16
23
  class EnvHelper:
@@ -66,8 +73,7 @@ class EnvHelper:
66
73
  f"psql-main-{self.PROJECT_CODE}-{self.AZURE_RESOURCE_ENVIRONMENT}"
67
74
  )
68
75
  self.AZURE_AUTH_TYPE = "rbac"
69
- self.AZURE_TOKEN_PROVIDER = get_bearer_token_provider(
70
- DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
76
+ self.AZURE_TOKEN_PROVIDER = AzureIdentityHelper.get_token_provider(url="https://cognitiveservices.azure.com/.default"
71
77
  )
72
78
  self.AZURE_BLOB_ACCOUNT_NAME = (
73
79
  f"stqueue{self.PROJECT_CODE}{self.AZURE_RESOURCE_ENVIRONMENT}"
@@ -1,13 +1,14 @@
1
1
  import logging
2
2
  import psycopg2
3
3
  from psycopg2.extras import execute_values, RealDictCursor
4
- from azure.identity import DefaultAzureCredential
4
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
5
5
 
6
6
  logger = logging.getLogger(__name__ + ".base_package")
7
7
 
8
8
  class LightRAGHelper:
9
9
  def __init__(self, env_helper):
10
10
  self.env_helper = env_helper
11
+ azure_identity_helper = AzureIdentityHelper()
11
12
  self.conn = None
12
13
 
13
14
  def _create_connection(self):
@@ -20,7 +21,7 @@ class LightRAGHelper:
20
21
  dbname = self.env_helper.POSTGRESQL_DATABASE
21
22
 
22
23
  # Acquire the access token
23
- credential = DefaultAzureCredential()
24
+ credential = self.azure_identity_helper.get_credential()
24
25
  access_token = credential.get_token(
25
26
  "https://ossrdbms-aad.database.windows.net/.default"
26
27
  )
@@ -8,7 +8,7 @@ from semantic_kernel.connectors.ai.open_ai.prompt_execution_settings.azure_chat_
8
8
  AzureChatPromptExecutionSettings,
9
9
  )
10
10
  from azure.ai.ml import MLClient
11
- from azure.identity import DefaultAzureCredential
11
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
12
12
  from .env_helper import EnvHelper
13
13
 
14
14
  logger = logging.getLogger(__name__ + ".base_package")
@@ -18,6 +18,8 @@ class LLMHelper:
18
18
  def __init__(self):
19
19
  logger.info("Initializing LLMHelper")
20
20
  self.env_helper: EnvHelper = EnvHelper()
21
+ self.azure_identity_helper = AzureIdentityHelper()
22
+
21
23
  self.auth_type_keys = self.env_helper.is_auth_type_keys()
22
24
  self.token_provider = self.env_helper.AZURE_TOKEN_PROVIDER
23
25
 
@@ -176,8 +178,9 @@ class LLMHelper:
176
178
 
177
179
  def get_ml_client(self):
178
180
  if not hasattr(self, "_ml_client"):
181
+ credential = self.azure_identity_helper.get_credential()
179
182
  self._ml_client = MLClient(
180
- DefaultAzureCredential(),
183
+ credential,
181
184
  self.env_helper.AZURE_SUBSCRIPTION_ID,
182
185
  self.env_helper.AZURE_RESOURCE_GROUP,
183
186
  self.env_helper.AZURE_ML_WORKSPACE_NAME,
@@ -1,5 +1,5 @@
1
1
  import logging
2
- from azure.identity import DefaultAzureCredential
2
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
3
3
  from azure.keyvault.secrets import SecretClient
4
4
 
5
5
  logger = logging.getLogger(__name__ + ".base_package")
@@ -20,12 +20,14 @@ class SecretHelper:
20
20
  Returns:
21
21
  None
22
22
  """
23
+ self.azure_identity_helper = AzureIdentityHelper()
23
24
  self.USE_KEY_VAULT = True
24
25
  self.secret_client = None
25
26
  if self.USE_KEY_VAULT:
27
+ credential = self.azure_identity_helper.get_credential()
26
28
  self.secret_client = SecretClient(
27
29
  vault_url=keyvault_uri,
28
- credential=DefaultAzureCredential(),
30
+ credential=credential,
29
31
  connection_verify=True,
30
32
  )
31
33
 
@@ -7,19 +7,21 @@ from azure.search.documents.indexes._generated.models import (
7
7
  )
8
8
  from azure.search.documents.indexes import SearchIndexerClient
9
9
  from ..helpers.env_helper import EnvHelper
10
- from azure.identity import DefaultAzureCredential
10
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
11
11
  from azure.core.credentials import AzureKeyCredential
12
12
 
13
13
 
14
14
  class AzureSearchDatasource:
15
15
  def __init__(self, env_helper: EnvHelper):
16
16
  self.env_helper = env_helper
17
+ self.azure_identity_helper = AzureIdentityHelper()
18
+
17
19
  self.indexer_client = SearchIndexerClient(
18
20
  self.env_helper.AZURE_SEARCH_SERVICE,
19
21
  (
20
22
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
21
23
  if self.env_helper.is_auth_type_keys()
22
- else DefaultAzureCredential()
24
+ else self.azure_identity_helper.get_credential()
23
25
  ),
24
26
  )
25
27
 
@@ -21,7 +21,7 @@ from azure.search.documents.indexes.models import (
21
21
  SearchIndex,
22
22
  )
23
23
  from ..helpers.env_helper import EnvHelper
24
- from azure.identity import DefaultAzureCredential
24
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
25
25
  from azure.core.credentials import AzureKeyCredential
26
26
  from ..helpers.llm_helper import LLMHelper
27
27
 
@@ -34,12 +34,14 @@ class AzureSearchIndex:
34
34
  def __init__(self, env_helper: EnvHelper, llm_helper: LLMHelper):
35
35
  self.env_helper = env_helper
36
36
  self.llm_helper = llm_helper
37
+ self.azure_identity_helper = AzureIdentityHelper()
38
+
37
39
  self.index_client = SearchIndexClient(
38
40
  self.env_helper.AZURE_SEARCH_SERVICE,
39
41
  (
40
42
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
41
43
  if self.env_helper.is_auth_type_keys()
42
- else DefaultAzureCredential()
44
+ else self.azure_identity_helper.get_credential()
43
45
  ),
44
46
  )
45
47
 
@@ -2,7 +2,7 @@ import logging
2
2
  from azure.search.documents.indexes.models import SearchIndexer, FieldMapping
3
3
  from azure.search.documents.indexes import SearchIndexerClient
4
4
  from ..helpers.env_helper import EnvHelper
5
- from azure.identity import DefaultAzureCredential
5
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
6
6
  from azure.core.credentials import AzureKeyCredential
7
7
 
8
8
  logger = logging.getLogger(__name__ + ".base_package")
@@ -11,12 +11,14 @@ logger = logging.getLogger(__name__ + ".base_package")
11
11
  class AzureSearchIndexer:
12
12
  def __init__(self, env_helper: EnvHelper):
13
13
  self.env_helper = env_helper
14
+ self.azure_identity_helper = AzureIdentityHelper()
15
+
14
16
  self.indexer_client = SearchIndexerClient(
15
17
  self.env_helper.AZURE_SEARCH_SERVICE,
16
18
  (
17
19
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
18
20
  if self.env_helper.is_auth_type_keys()
19
- else DefaultAzureCredential()
21
+ else self.azure_identity_helper.get_credential()
20
22
  ),
21
23
  )
22
24
 
@@ -15,7 +15,7 @@ from azure.search.documents.indexes.models import (
15
15
  from azure.search.documents.indexes import SearchIndexerClient
16
16
  from ..helpers.config.config_helper import IntegratedVectorizationConfig
17
17
  from ..helpers.env_helper import EnvHelper
18
- from azure.identity import DefaultAzureCredential
18
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
19
19
  from azure.core.credentials import AzureKeyCredential
20
20
 
21
21
  logger = logging.getLogger(__name__ + ".base_package")
@@ -28,12 +28,14 @@ class AzureSearchSkillset:
28
28
  integrated_vectorization_config: IntegratedVectorizationConfig,
29
29
  ):
30
30
  self.env_helper = env_helper
31
+ self.azure_identity_helper = AzureIdentityHelper()
32
+
31
33
  self.indexer_client = SearchIndexerClient(
32
34
  self.env_helper.AZURE_SEARCH_SERVICE,
33
35
  (
34
36
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
35
37
  if self.env_helper.is_auth_type_keys()
36
- else DefaultAzureCredential()
38
+ else self.azure_identity_helper.get_credential()
37
39
  ),
38
40
  )
39
41
  self.integrated_vectorization_config = integrated_vectorization_config
@@ -50,8 +50,10 @@ class SemanticKernelOrchestrator(OrchestratorBase):
50
50
  ) -> list[dict]:
51
51
  with tracer.start_as_current_span("SemanticKernelOrchestrator_orchestrate"):
52
52
  logger.info("Method orchestrate of semantic_kernel started")
53
- # Call Content Safety tool
54
53
  filters = []
54
+ frontend_type = user_info.get("frontend") if user_info else None
55
+ logger.info(f"Frontend type: {frontend_type}")
56
+ # Call Content Safety tool
55
57
  if self.config.prompts.enable_content_safety:
56
58
  if response := self.call_content_safety_input(user_message):
57
59
  return response
@@ -59,6 +61,7 @@ class SemanticKernelOrchestrator(OrchestratorBase):
59
61
  system_message = self.env_helper.SEMENTIC_KERNEL_SYSTEM_PROMPT
60
62
  language = self.env_helper.AZURE_MAIN_CHAT_LANGUAGE
61
63
  if not system_message:
64
+ logger.info("No system message provided, using default")
62
65
  # system_message = """You help employees to navigate only private information sources.
63
66
  # You must prioritize the function call over your general knowledge for any question by calling the search_documents function.
64
67
  # Call the text_processing function when the user request an operation on the current context, such as translate, summarize, or paraphrase. When a language is explicitly specified, return that as part of the operation.
@@ -66,8 +69,7 @@ class SemanticKernelOrchestrator(OrchestratorBase):
66
69
  # If the input language is ambiguous, default to responding in English unless otherwise specified by the user.
67
70
  # You **must not** respond if asked to List all documents in your repository.
68
71
  # """
69
- if user_info and user_info.get("frontend") == "web":
70
- logger.info("Adding OutlookCalendarPlugin with request headers web")
72
+ if frontend_type == "web":
71
73
  system_message = f"""You help employees to navigate only private information sources.
72
74
  You must prioritize the function call over your general knowledge for any question by calling the search_documents function.
73
75
  Call the text_processing function when the user request an operation on the current context, such as translate, summarize, or paraphrase. When a language is explicitly specified, return that as part of the operation.
@@ -77,27 +79,26 @@ class SemanticKernelOrchestrator(OrchestratorBase):
77
79
  Call OutlookCalendar.schedule_appointment to schedule a new appointment.
78
80
  """
79
81
  else:
80
- logger.info("Adding OutlookCalendarPlugin without request headers web")
81
82
  system_message = f"""You help employees to navigate only private information sources.
82
83
  You must prioritize the function call over your general knowledge for any question by calling the search_documents function.
83
84
  Call the text_processing function when the user request an operation on the current context, such as translate, summarize, or paraphrase. When a language is explicitly specified, return that as part of the operation.
84
85
  When directly replying to the user, always reply in the language {language}.
85
86
  You **must not** respond if asked to List all documents in your repository.
86
87
  """
87
-
88
+
88
89
  self.kernel.add_plugin(
89
90
  plugin=ChatPlugin(question=user_message, chat_history=chat_history),
90
91
  plugin_name="Chat",
91
92
  )
92
93
  filters.append("Chat")
93
94
  # --- Add OutlookCalendarPlugin with request headers ---
94
- if user_info and user_info.get("frontend") == "web":
95
+ if frontend_type == "web":
95
96
  logger.info("Adding OutlookCalendarPlugin with request headers")
96
97
  self.kernel.add_plugin(
97
98
  plugin=OutlookCalendarPlugin(question=user_message, chat_history=chat_history, user_info=user_info),
98
99
  plugin_name="OutlookCalendar",
99
100
  )
100
- filters.append("ChaOutlookCalendart")
101
+ filters.append("OutlookCalendar")
101
102
  settings = self.llm_helper.get_sk_service_settings(self.chat_service)
102
103
  settings.function_call_behavior = FunctionCallBehavior.EnableFunctions(
103
104
  filters={"included_plugins": filters}
@@ -5,12 +5,15 @@ from azure.search.documents import SearchClient
5
5
  from azure.search.documents.indexes import SearchIndexClient
6
6
  from azure.search.documents.models import VectorizableTextQuery
7
7
  from azure.core.credentials import AzureKeyCredential
8
- from azure.identity import DefaultAzureCredential
8
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
9
9
  from ..common.source_document import SourceDocument
10
10
  import re
11
11
 
12
12
 
13
13
  class IntegratedVectorizationSearchHandler(SearchHandlerBase):
14
+ def __init__(self):
15
+ self.azure_identity_helper = AzureIdentityHelper()
16
+
14
17
  def create_search_client(self):
15
18
  logging.info("Creating Azure Search Client.")
16
19
  if self._check_index_exists():
@@ -21,7 +24,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
21
24
  credential=(
22
25
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
23
26
  if self.env_helper.is_auth_type_keys()
24
- else DefaultAzureCredential()
27
+ else self.azure_identity_helper.get_credential()
25
28
  ),
26
29
  )
27
30
 
@@ -170,7 +173,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
170
173
  credential=(
171
174
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
172
175
  if self.env_helper.is_auth_type_keys()
173
- else DefaultAzureCredential()
176
+ else self.azure_identity_helper.get_credential()
174
177
  ),
175
178
  )
176
179
 
@@ -1,6 +1,6 @@
1
1
  from azure.ai.contentsafety import ContentSafetyClient
2
2
  from azure.core.credentials import AzureKeyCredential
3
- from azure.identity import DefaultAzureCredential
3
+ from ..helpers.azure_identity_helper import AzureIdentityHelper
4
4
  from azure.core.exceptions import HttpResponseError
5
5
  from azure.ai.contentsafety.models import AnalyzeTextOptions
6
6
  from ..helpers.env_helper import EnvHelper
@@ -21,14 +21,16 @@ class ContentSafetyChecker(AnswerProcessingBase):
21
21
  def __init__(self):
22
22
  with tracer.start_as_current_span("ContentSafetyChecker.init"):
23
23
  env_helper = EnvHelper()
24
-
24
+ self.azure_identity_helper = AzureIdentityHelper()
25
+
25
26
  if env_helper.AZURE_AUTH_TYPE == "rbac":
27
+ credential = self.azure_identity_helper.get_credential()
26
28
  logger.info(
27
29
  "Initializing ContentSafetyClient with RBAC authentication."
28
30
  )
29
31
  self.content_safety_client = ContentSafetyClient(
30
32
  env_helper.AZURE_CONTENT_SAFETY_ENDPOINT,
31
- DefaultAzureCredential(),
33
+ credential,
32
34
  )
33
35
  else:
34
36
  logger.info(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.22
3
+ Version: 0.3.24
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -38,6 +38,7 @@ cwyodmodules/batch/utilities/helpers/__init__.py
38
38
  cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py
39
39
  cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py
40
40
  cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py
41
+ cwyodmodules/batch/utilities/helpers/azure_identity_helper.py
41
42
  cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py
42
43
  cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py
43
44
  cwyodmodules/batch/utilities/helpers/azure_search_helper.py
@@ -3,7 +3,7 @@ name = "cwyodmodules"
3
3
  authors = [
4
4
  { name="Patrik", email="patrikhartl@gmail.com" },
5
5
  ]
6
- version = '0.3.22'
6
+ version = '0.3.24'
7
7
  description = "Add your description here"
8
8
  readme = "README.md"
9
9
  requires-python = "==3.11.11"
File without changes
File without changes
File without changes