cwyodmodules 0.3.42__py3-none-any.whl → 0.3.43__py3-none-any.whl

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 (24) hide show
  1. cwyodmodules/batch/utilities/chat_history/database_factory.py +2 -4
  2. cwyodmodules/batch/utilities/chat_history/postgresdbservice.py +2 -5
  3. cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py +3 -5
  4. cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py +3 -4
  5. cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py +2 -3
  6. cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py +2 -3
  7. cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py +2 -4
  8. cwyodmodules/batch/utilities/helpers/azure_search_helper.py +2 -4
  9. cwyodmodules/batch/utilities/helpers/env_helper.py +3 -5
  10. cwyodmodules/batch/utilities/helpers/lightrag_helper.py +2 -4
  11. cwyodmodules/batch/utilities/helpers/llm_helper.py +2 -4
  12. cwyodmodules/batch/utilities/helpers/secret_helper.py +2 -4
  13. cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py +2 -3
  14. cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py +2 -5
  15. cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py +2 -4
  16. cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py +2 -4
  17. cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py +5 -5
  18. cwyodmodules/batch/utilities/tools/content_safety_checker.py +2 -5
  19. {cwyodmodules-0.3.42.dist-info → cwyodmodules-0.3.43.dist-info}/METADATA +1 -1
  20. {cwyodmodules-0.3.42.dist-info → cwyodmodules-0.3.43.dist-info}/RECORD +23 -24
  21. cwyodmodules/batch/utilities/helpers/azure_identity_helper.py +0 -50
  22. {cwyodmodules-0.3.42.dist-info → cwyodmodules-0.3.43.dist-info}/WHEEL +0 -0
  23. {cwyodmodules-0.3.42.dist-info → cwyodmodules-0.3.43.dist-info}/licenses/LICENSE +0 -0
  24. {cwyodmodules-0.3.42.dist-info → cwyodmodules-0.3.43.dist-info}/top_level.txt +0 -0
@@ -3,14 +3,12 @@ from ..helpers.env_helper import EnvHelper
3
3
  from .cosmosdb import CosmosConversationClient
4
4
  from .postgresdbservice import PostgresConversationClient
5
5
  from ..helpers.config.database_type import DatabaseType
6
- from ..helpers.azure_identity_helper import AzureIdentityHelper
7
-
6
+ from mgmt_config import identity
8
7
 
9
8
  class DatabaseFactory:
10
9
  @staticmethod
11
10
  def get_conversation_client():
12
11
  env_helper: EnvHelper = EnvHelper()
13
- azure_identity_helper = AzureIdentityHelper()
14
12
 
15
13
  if env_helper.DATABASE_TYPE == DatabaseType.COSMOSDB.value:
16
14
  DatabaseFactory._validate_env_vars(
@@ -26,7 +24,7 @@ class DatabaseFactory:
26
24
  f"https://{env_helper.AZURE_COSMOSDB_ACCOUNT}.documents.azure.com:443/"
27
25
  )
28
26
  credential = (
29
- azure_identity_helper.get_credential()
27
+ identity.get_credential()
30
28
  if not env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
31
29
  else env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
32
30
  )
@@ -1,10 +1,8 @@
1
1
  import asyncpg
2
2
  from datetime import datetime, timezone
3
- from ..helpers.azure_identity_helper import AzureIdentityHelper
4
3
  from .database_client_base import DatabaseClientBase
5
-
6
4
  from ...utilities.helpers.env_helper import EnvHelper
7
- from mgmt_config import logger
5
+ from mgmt_config import logger, identity
8
6
  env_helper: EnvHelper = EnvHelper()
9
7
  log_execution = env_helper.LOG_EXECUTION
10
8
  log_args = env_helper.LOG_ARGS
@@ -16,7 +14,6 @@ class PostgresConversationClient(DatabaseClientBase):
16
14
  def __init__(
17
15
  self, user: str, host: str, database: str, enable_message_feedback: bool = False
18
16
  ):
19
- self.azure_identity_helper = AzureIdentityHelper()
20
17
  self.user = user
21
18
  self.host = host
22
19
  self.database = database
@@ -26,7 +23,7 @@ class PostgresConversationClient(DatabaseClientBase):
26
23
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
27
24
  async def connect(self):
28
25
  try:
29
- access_information = self.azure_identity_helper.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
26
+ access_information = identity.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
30
27
  token = access_information.token
31
28
  self.conn = await asyncpg.connect(
32
29
  user=self.user,
@@ -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 ..helpers.azure_identity_helper import AzureIdentityHelper
15
+ from mgmt_config import identity
16
16
 
17
17
 
18
18
  def connection_string(account_name: str, account_key: str):
@@ -22,8 +22,7 @@ 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
+ credential = identity.get_credential()
27
26
  return QueueClient(
28
27
  account_url=f"https://{env_helper.AZURE_BLOB_ACCOUNT_NAME}.queue.core.windows.net/",
29
28
  queue_name=env_helper.DOCUMENT_PROCESSING_QUEUE_NAME,
@@ -49,7 +48,6 @@ class AzureBlobStorageClient:
49
48
  container_name: Optional[str] = None,
50
49
  ):
51
50
  env_helper: EnvHelper = EnvHelper()
52
- self.azure_identity_helper = AzureIdentityHelper()
53
51
 
54
52
  self.auth_type = env_helper.AZURE_AUTH_TYPE
55
53
  self.account_name = account_name or env_helper.AZURE_BLOB_ACCOUNT_NAME
@@ -58,7 +56,7 @@ class AzureBlobStorageClient:
58
56
 
59
57
  if self.auth_type == "rbac":
60
58
  self.account_key = None
61
- credential = self.azure_identity_helper.get_credential()
59
+ credential = identity.get_credential()
62
60
  self.blob_service_client = BlobServiceClient(
63
61
  account_url=self.endpoint, credential=credential
64
62
  )
@@ -1,5 +1,5 @@
1
1
  from urllib.parse import urljoin
2
- from ..helpers.azure_identity_helper import AzureIdentityHelper
2
+ from mgmt_config import identity
3
3
 
4
4
  import requests
5
5
  from requests import Response
@@ -20,7 +20,6 @@ class AzureComputerVisionClient:
20
20
  __RESPONSE_VECTOR_KEY = "vector"
21
21
 
22
22
  def __init__(self, env_helper: EnvHelper) -> None:
23
- self.azure_identity_helper = AzureIdentityHelper()
24
23
  self.host = env_helper.AZURE_COMPUTER_VISION_ENDPOINT
25
24
  self.timeout = env_helper.AZURE_COMPUTER_VISION_TIMEOUT
26
25
  self.key = env_helper.AZURE_COMPUTER_VISION_KEY
@@ -61,10 +60,10 @@ class AzureComputerVisionClient:
61
60
  if self.use_keys:
62
61
  headers["Ocp-Apim-Subscription-Key"] = self.key
63
62
  else:
64
- access_information = self.azure_identity_helper.get_token_provider(
63
+ access_information = identity.get_token_provider(
65
64
  scopes=self.__TOKEN_SCOPE
66
65
  )
67
- headers["Authorization"] = "Bearer " + access_information()
66
+ headers["Authorization"] = "Bearer " + access_information.get_token()
68
67
 
69
68
  return requests.post(
70
69
  url=urljoin(self.host, path),
@@ -1,6 +1,6 @@
1
1
  from azure.core.credentials import AzureKeyCredential
2
2
  from azure.ai.formrecognizer import DocumentAnalysisClient
3
- from ..helpers.azure_identity_helper import AzureIdentityHelper
3
+ from mgmt_config import identity
4
4
  import html
5
5
  import traceback
6
6
  from .env_helper import EnvHelper
@@ -20,8 +20,7 @@ class AzureFormRecognizerClient:
20
20
  env_helper.AZURE_FORM_RECOGNIZER_ENDPOINT
21
21
  )
22
22
  if env_helper.AZURE_AUTH_TYPE == "rbac":
23
- self.azure_identity_helper = AzureIdentityHelper()
24
- credential = self.azure_identity_helper.get_credential()
23
+ credential = identity.get_credential()
25
24
  self.document_analysis_client = DocumentAnalysisClient(
26
25
  endpoint=self.AZURE_FORM_RECOGNIZER_ENDPOINT,
27
26
  credential=credential,
@@ -1,6 +1,6 @@
1
1
  import psycopg2
2
2
  from psycopg2.extras import execute_values, RealDictCursor
3
- from ..helpers.azure_identity_helper import AzureIdentityHelper
3
+ from mgmt_config import identity
4
4
  from .llm_helper import LLMHelper
5
5
  from .env_helper import EnvHelper
6
6
 
@@ -15,7 +15,6 @@ class AzurePostgresHelper:
15
15
  def __init__(self):
16
16
  self.llm_helper = LLMHelper()
17
17
  self.env_helper = EnvHelper()
18
- self.azure_identity_helper = AzureIdentityHelper()
19
18
  self.conn = None
20
19
 
21
20
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
@@ -29,7 +28,7 @@ class AzurePostgresHelper:
29
28
  dbname = self.env_helper.POSTGRESQL_DATABASE
30
29
 
31
30
  # Acquire the access token
32
- access_information = self.azure_identity_helper.get_token(
31
+ access_information = identity.get_token(
33
32
  scopes="https://ossrdbms-aad.database.windows.net/.default"
34
33
  )
35
34
  token = access_information.token
@@ -3,9 +3,8 @@ from psycopg2.extras import execute_values, RealDictCursor
3
3
  from .llm_helper import LLMHelper
4
4
  from .env_helper import EnvHelper
5
5
  from .lightrag_helper import LightRAGHelper
6
- from ..helpers.azure_identity_helper import AzureIdentityHelper
7
6
 
8
- from mgmt_config import logger
7
+ from mgmt_config import logger, identity
9
8
  env_helper: EnvHelper = EnvHelper()
10
9
  log_execution = env_helper.LOG_EXECUTION
11
10
  log_args = env_helper.LOG_ARGS
@@ -17,7 +16,6 @@ class AzurePostgresHelper:
17
16
  self.llm_helper = LLMHelper()
18
17
  self.env_helper = EnvHelper()
19
18
  self.lightrag_helper = LightRAGHelper()
20
- self.azure_identity_helper = AzureIdentityHelper()
21
19
  self.conn = None
22
20
 
23
21
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
@@ -31,7 +29,7 @@ class AzurePostgresHelper:
31
29
  dbname = self.env_helper.POSTGRESQL_DATABASE
32
30
 
33
31
  # Acquire the access token
34
- access_information = self.azure_identity_helper.get_token(
32
+ access_information = identity.get_token(
35
33
  scopes="https://ossrdbms-aad.database.windows.net/.default"
36
34
  )
37
35
  token = access_information.token
@@ -2,7 +2,6 @@ from azure.identity import ChainedTokenCredential, DefaultAzureCredential
2
2
  from typing import Union
3
3
  from langchain_community.vectorstores import AzureSearch
4
4
  from azure.core.credentials import AzureKeyCredential
5
- from ..helpers.azure_identity_helper import AzureIdentityHelper
6
5
  from azure.search.documents import SearchClient
7
6
  from azure.search.documents.indexes import SearchIndexClient
8
7
  from azure.search.documents.indexes.models import (
@@ -28,7 +27,7 @@ from azure.search.documents.indexes.models import (
28
27
  from ..helpers.azure_computer_vision_client import AzureComputerVisionClient
29
28
  from ..helpers.llm_helper import LLMHelper
30
29
  from ..helpers.env_helper import EnvHelper
31
- from mgmt_config import logger
30
+ from mgmt_config import logger, identity
32
31
  env_helper: EnvHelper = EnvHelper()
33
32
  log_execution = env_helper.LOG_EXECUTION
34
33
  log_args = env_helper.LOG_ARGS
@@ -41,7 +40,6 @@ class AzureSearchHelper:
41
40
  def __init__(self):
42
41
  self.llm_helper = LLMHelper()
43
42
  self.env_helper = EnvHelper()
44
- self.azure_identity_helper = AzureIdentityHelper()
45
43
 
46
44
  search_credential = self._search_credential()
47
45
  self.search_client = self._create_search_client(search_credential)
@@ -53,7 +51,7 @@ class AzureSearchHelper:
53
51
  if self.env_helper.is_auth_type_keys():
54
52
  return AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
55
53
  else:
56
- credential = self.azure_identity_helper.get_credential()
54
+ credential = identity.get_credential()
57
55
  return credential
58
56
 
59
57
  @logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
@@ -1,15 +1,14 @@
1
1
  import json
2
2
  import os
3
3
 
4
- import threading
4
+ import threading
5
5
  # from dotenv import load_dotenv
6
6
  from ..orchestrator.orchestration_strategy import OrchestrationStrategy
7
7
  from ..helpers.config.conversation_flow import ConversationFlow
8
8
  from ..helpers.config.database_type import DatabaseType
9
9
  from ..helpers.secret_helper import SecretHelper
10
- from ..helpers.azure_identity_helper import AzureIdentityHelper
11
10
 
12
- from mgmt_config import logger
11
+ from mgmt_config import logger, identity
13
12
 
14
13
 
15
14
 
@@ -76,8 +75,7 @@ class EnvHelper:
76
75
  f"psql-main-{self.PROJECT_CODE}-{self.AZURE_RESOURCE_ENVIRONMENT}"
77
76
  )
78
77
  self.AZURE_AUTH_TYPE = "rbac"
79
- azure_identity_helper = AzureIdentityHelper()# Extract context from the incoming request
80
- access_information = azure_identity_helper.get_token_provider(scopes="https://cognitiveservices.azure.com/.default")
78
+ access_information = identity.get_token_provider(scopes="https://cognitiveservices.azure.com/.default")
81
79
  self.AZURE_TOKEN_PROVIDER = access_information
82
80
  self.AZURE_BLOB_ACCOUNT_NAME = (
83
81
  f"stqueue{self.PROJECT_CODE}{self.AZURE_RESOURCE_ENVIRONMENT}"
@@ -1,9 +1,8 @@
1
1
  import psycopg2
2
2
  from psycopg2.extras import execute_values, RealDictCursor
3
- from ..helpers.azure_identity_helper import AzureIdentityHelper
4
3
 
5
4
  from ...utilities.helpers.env_helper import EnvHelper
6
- from mgmt_config import logger
5
+ from mgmt_config import logger, identity
7
6
  env_helper: EnvHelper = EnvHelper()
8
7
  log_execution = env_helper.LOG_EXECUTION
9
8
  log_args = env_helper.LOG_ARGS
@@ -13,7 +12,6 @@ log_result = env_helper.LOG_RESULT
13
12
  class LightRAGHelper:
14
13
  def __init__(self, env_helper):
15
14
  self.env_helper = env_helper
16
- self.azure_identity_helper = AzureIdentityHelper()
17
15
  self.conn = None
18
16
 
19
17
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
@@ -27,7 +25,7 @@ class LightRAGHelper:
27
25
  dbname = self.env_helper.POSTGRESQL_DATABASE
28
26
 
29
27
  # Acquire the access token
30
- access_information = self.azure_identity_helper.get_token(
28
+ access_information = identity.get_token(
31
29
  scopes="https://ossrdbms-aad.database.windows.net/.default"
32
30
  )
33
31
  token = access_information.token
@@ -7,10 +7,9 @@ from semantic_kernel.connectors.ai.open_ai.prompt_execution_settings.azure_chat_
7
7
  AzureChatPromptExecutionSettings,
8
8
  )
9
9
  from azure.ai.ml import MLClient
10
- from ..helpers.azure_identity_helper import AzureIdentityHelper
11
10
  from .env_helper import EnvHelper
12
11
 
13
- from mgmt_config import logger
12
+ from mgmt_config import logger, identity
14
13
  env_helper: EnvHelper = EnvHelper()
15
14
  log_execution = env_helper.LOG_EXECUTION
16
15
  log_args = env_helper.LOG_ARGS
@@ -21,7 +20,6 @@ class LLMHelper:
21
20
  def __init__(self):
22
21
  logger.info("Initializing LLMHelper")
23
22
  self.env_helper: EnvHelper = EnvHelper()
24
- self.azure_identity_helper = AzureIdentityHelper()
25
23
 
26
24
  self.auth_type_keys = self.env_helper.is_auth_type_keys()
27
25
  self.token_provider = self.env_helper.AZURE_TOKEN_PROVIDER
@@ -190,7 +188,7 @@ class LLMHelper:
190
188
  @logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
191
189
  def get_ml_client(self):
192
190
  if not hasattr(self, "_ml_client"):
193
- credential = self.azure_identity_helper.get_credential()
191
+ credential = identity.get_credential()
194
192
  self._ml_client = MLClient(
195
193
  credential,
196
194
  self.env_helper.AZURE_SUBSCRIPTION_ID,
@@ -1,7 +1,6 @@
1
- from ..helpers.azure_identity_helper import AzureIdentityHelper
2
1
  from azure.keyvault.secrets import SecretClient
3
2
 
4
- from mgmt_config import logger
3
+ from mgmt_config import logger, identity
5
4
 
6
5
 
7
6
  class SecretHelper:
@@ -19,11 +18,10 @@ class SecretHelper:
19
18
  Returns:
20
19
  None
21
20
  """
22
- self.azure_identity_helper = AzureIdentityHelper()
23
21
  self.USE_KEY_VAULT = True
24
22
  self.secret_client = None
25
23
  if self.USE_KEY_VAULT:
26
- credential = self.azure_identity_helper.get_credential()
24
+ credential = identity.get_credential()
27
25
  self.secret_client = SecretClient(
28
26
  vault_url=keyvault_uri,
29
27
  credential=credential,
@@ -7,21 +7,20 @@ 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 ..helpers.azure_identity_helper import AzureIdentityHelper
11
10
  from azure.core.credentials import AzureKeyCredential
11
+ from mgmt_config import identity
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
18
  self.indexer_client = SearchIndexerClient(
20
19
  self.env_helper.AZURE_SEARCH_SERVICE,
21
20
  (
22
21
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
23
22
  if self.env_helper.is_auth_type_keys()
24
- else self.azure_identity_helper.get_credential()
23
+ else identity.get_credential()
25
24
  ),
26
25
  )
27
26
 
@@ -20,11 +20,9 @@ from azure.search.documents.indexes.models import (
20
20
  SearchIndex,
21
21
  )
22
22
  from ..helpers.env_helper import EnvHelper
23
- from ..helpers.azure_identity_helper import AzureIdentityHelper
24
23
  from azure.core.credentials import AzureKeyCredential
25
24
  from ..helpers.llm_helper import LLMHelper
26
-
27
- from mgmt_config import logger
25
+ from mgmt_config import logger, identity
28
26
  env_helper: EnvHelper = EnvHelper()
29
27
  log_execution = env_helper.LOG_EXECUTION
30
28
  log_args = env_helper.LOG_ARGS
@@ -37,14 +35,13 @@ class AzureSearchIndex:
37
35
  def __init__(self, env_helper: EnvHelper, llm_helper: LLMHelper):
38
36
  self.env_helper = env_helper
39
37
  self.llm_helper = llm_helper
40
- self.azure_identity_helper = AzureIdentityHelper()
41
38
 
42
39
  self.index_client = SearchIndexClient(
43
40
  self.env_helper.AZURE_SEARCH_SERVICE,
44
41
  (
45
42
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
46
43
  if self.env_helper.is_auth_type_keys()
47
- else self.azure_identity_helper.get_credential()
44
+ else identity.get_credential()
48
45
  ),
49
46
  )
50
47
 
@@ -1,12 +1,11 @@
1
1
  from azure.search.documents.indexes.models import SearchIndexer, FieldMapping
2
2
  from azure.search.documents.indexes import SearchIndexerClient
3
3
  from ..helpers.env_helper import EnvHelper
4
- from ..helpers.azure_identity_helper import AzureIdentityHelper
5
4
  from azure.core.credentials import AzureKeyCredential
6
5
 
7
6
 
8
7
  from ...utilities.helpers.env_helper import EnvHelper
9
- from mgmt_config import logger
8
+ from mgmt_config import logger, identity
10
9
  env_helper: EnvHelper = EnvHelper()
11
10
  log_execution = env_helper.LOG_EXECUTION
12
11
  log_args = env_helper.LOG_ARGS
@@ -16,14 +15,13 @@ log_result = env_helper.LOG_RESULT
16
15
  class AzureSearchIndexer:
17
16
  def __init__(self, env_helper: EnvHelper):
18
17
  self.env_helper = env_helper
19
- self.azure_identity_helper = AzureIdentityHelper()
20
18
 
21
19
  self.indexer_client = SearchIndexerClient(
22
20
  self.env_helper.AZURE_SEARCH_SERVICE,
23
21
  (
24
22
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
25
23
  if self.env_helper.is_auth_type_keys()
26
- else self.azure_identity_helper.get_credential()
24
+ else identity.get_credential()
27
25
  ),
28
26
  )
29
27
 
@@ -14,11 +14,10 @@ from azure.search.documents.indexes.models import (
14
14
  from azure.search.documents.indexes import SearchIndexerClient
15
15
  from ..helpers.config.config_helper import IntegratedVectorizationConfig
16
16
  from ..helpers.env_helper import EnvHelper
17
- from ..helpers.azure_identity_helper import AzureIdentityHelper
18
17
  from azure.core.credentials import AzureKeyCredential
19
18
 
20
19
  from ...utilities.helpers.env_helper import EnvHelper
21
- from mgmt_config import logger
20
+ from mgmt_config import logger, identity
22
21
  env_helper: EnvHelper = EnvHelper()
23
22
  log_execution = env_helper.LOG_EXECUTION
24
23
  log_args = env_helper.LOG_ARGS
@@ -32,14 +31,13 @@ class AzureSearchSkillset:
32
31
  integrated_vectorization_config: IntegratedVectorizationConfig,
33
32
  ):
34
33
  self.env_helper = env_helper
35
- self.azure_identity_helper = AzureIdentityHelper()
36
34
 
37
35
  self.indexer_client = SearchIndexerClient(
38
36
  self.env_helper.AZURE_SEARCH_SERVICE,
39
37
  (
40
38
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
41
39
  if self.env_helper.is_auth_type_keys()
42
- else self.azure_identity_helper.get_credential()
40
+ else identity.get_credential()
43
41
  ),
44
42
  )
45
43
  self.integrated_vectorization_config = integrated_vectorization_config
@@ -4,11 +4,10 @@ from azure.search.documents import SearchClient
4
4
  from azure.search.documents.indexes import SearchIndexClient
5
5
  from azure.search.documents.models import VectorizableTextQuery
6
6
  from azure.core.credentials import AzureKeyCredential
7
- from ..helpers.azure_identity_helper import AzureIdentityHelper
8
7
  from ..common.source_document import SourceDocument
9
8
  import re
10
9
  from ...utilities.helpers.env_helper import EnvHelper
11
- from mgmt_config import logger
10
+ from mgmt_config import logger, identity
12
11
  env_helper: EnvHelper = EnvHelper()
13
12
  log_execution = env_helper.LOG_EXECUTION
14
13
  log_args = env_helper.LOG_ARGS
@@ -16,7 +15,8 @@ log_result = env_helper.LOG_RESULT
16
15
 
17
16
  class IntegratedVectorizationSearchHandler(SearchHandlerBase):
18
17
  def __init__(self):
19
- self.azure_identity_helper = AzureIdentityHelper()
18
+ self.env_helper = EnvHelper()
19
+
20
20
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
21
21
  def create_search_client(self):
22
22
  logger.info("Creating Azure Search Client.")
@@ -28,7 +28,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
28
28
  credential=(
29
29
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
30
30
  if self.env_helper.is_auth_type_keys()
31
- else self.azure_identity_helper.get_credential()
31
+ else identity.get_credential()
32
32
  ),
33
33
  )
34
34
 
@@ -186,7 +186,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
186
186
  credential=(
187
187
  AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
188
188
  if self.env_helper.is_auth_type_keys()
189
- else self.azure_identity_helper.get_credential()
189
+ else identity.get_credential()
190
190
  ),
191
191
  )
192
192
 
@@ -1,13 +1,12 @@
1
1
  from azure.ai.contentsafety import ContentSafetyClient
2
2
  from azure.core.credentials import AzureKeyCredential
3
- from ..helpers.azure_identity_helper import AzureIdentityHelper
4
3
  from azure.core.exceptions import HttpResponseError
5
4
  from azure.ai.contentsafety.models import AnalyzeTextOptions
6
5
  from ..helpers.env_helper import EnvHelper
7
6
  from .answer_processing_base import AnswerProcessingBase
8
7
  from ..common.answer import Answer
9
8
 
10
- from mgmt_config import logger
9
+ from mgmt_config import logger, identity
11
10
  env_helper: EnvHelper = EnvHelper()
12
11
  log_execution = env_helper.LOG_EXECUTION
13
12
  log_args = env_helper.LOG_ARGS
@@ -16,10 +15,8 @@ log_result = env_helper.LOG_RESULT
16
15
 
17
16
  class ContentSafetyChecker(AnswerProcessingBase):
18
17
  def __init__(self):
19
- self.azure_identity_helper = AzureIdentityHelper()
20
-
21
18
  if env_helper.AZURE_AUTH_TYPE == "rbac":
22
- credential = self.azure_identity_helper.get_credential()
19
+ credential = identity.get_credential()
23
20
  logger.info(
24
21
  "Initializing ContentSafetyClient with RBAC authentication."
25
22
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.42
3
+ Version: 0.3.43
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -6,8 +6,8 @@ cwyodmodules/batch/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
6
6
  cwyodmodules/batch/utilities/chat_history/auth_utils.py,sha256=4DipngRgRwkbwt-R1j0_I_KCazLuV5RSFtXn1zJ-5vE,2109
7
7
  cwyodmodules/batch/utilities/chat_history/cosmosdb.py,sha256=St5wWqVm4IOsDmlJDNlJHv9PVrPmdN04-9MYmc5udMY,8777
8
8
  cwyodmodules/batch/utilities/chat_history/database_client_base.py,sha256=6y7h2iL0Uxn4c11N99Ao-8nplQGVGQAOnev3GlHIDXA,2328
9
- cwyodmodules/batch/utilities/chat_history/database_factory.py,sha256=kdleC4P8u8rYPsx2HcPQwyOgFf_mph3Nh-Mmzz1V7oM,2401
10
- cwyodmodules/batch/utilities/chat_history/postgresdbservice.py,sha256=tkE7dpv95GNXwHah_Oj33LYmAuDerf5YhEAot1BjGt4,13027
9
+ cwyodmodules/batch/utilities/chat_history/database_factory.py,sha256=3fUmxTmxLZ01DUwBfxZ8raZjsEppVgAnTpchMGcH2oU,2302
10
+ cwyodmodules/batch/utilities/chat_history/postgresdbservice.py,sha256=71TtWBNzGq4T-4TubzFGEBSCTRRm28wB04q0AZTyQ9o,12892
11
11
  cwyodmodules/batch/utilities/chat_history/sample_user.py,sha256=GNXZ_yTjud8Zj0vgHnoU96RJMiJt0YRjEVO3pt7203A,3037
12
12
  cwyodmodules/batch/utilities/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  cwyodmodules/batch/utilities/common/answer.py,sha256=C1g_Xt85TfXK2qV1F6J5_o3MyIUdFpUmvgkIpuEcp4I,3093
@@ -28,20 +28,19 @@ cwyodmodules/batch/utilities/document_loading/strategies.py,sha256=ZBKYPJD8UJmPB
28
28
  cwyodmodules/batch/utilities/document_loading/web.py,sha256=LRTNYs_7CN8nfMOaCoW7Py_obrLpj3vI4kneNVEHGXE,1186
29
29
  cwyodmodules/batch/utilities/document_loading/word_document.py,sha256=-F1asMaupQk4swEeCoAD8tyYENE4Qq-05-VmPUjRdeA,1569
30
30
  cwyodmodules/batch/utilities/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py,sha256=FN2XnEThmtbWnwSi1sEfgekuPH7aJBOAU5n2DBmQ9ww,10315
32
- cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py,sha256=tCSJM0SsC_ris4NZ-WCBvP5n2mRZBhVHjnpYjUVHUVQ,4333
33
- cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py,sha256=agZEbw3vJAOiX7fpzCsId527VMsLOez3cVELYlpUJy0,7002
34
- cwyodmodules/batch/utilities/helpers/azure_identity_helper.py,sha256=aiYZH4F9aZBd5DDRuVvIn6jiIDgC0i-R-1-NqHqosnI,1806
35
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py,sha256=J0JZEuH0OE0sGtC4G2E5X4df4Ua1Jg8LKspL-sVxxxQ,11894
36
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py,sha256=-6CPczt8vbkedZliSXmmoLat8EiKm4oHIFldbQe_Q5k,11966
37
- cwyodmodules/batch/utilities/helpers/azure_search_helper.py,sha256=_HDHbrpWbbM8AJfcd2deTtseZK-hM4ar9QCrXvVSfYM,11445
31
+ cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py,sha256=WgJFr1o4ZLqTTogS5oFwqSTHs6ofrycjrnSvffhIjoA,10140
32
+ cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py,sha256=zxpUx_Z5T2VmtgMuAdwLtIwQXF9QI-v11ShTnaSfjRA,4235
33
+ cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py,sha256=wEbSJjZuV_u-4yWYNCiG5RwifjxNO8hdfXDuDoV-KiY,6890
34
+ cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py,sha256=efDNCnhrY-IJBKEwrJN_xbg4I72_r2HY3g6vyMYw5AM,11786
35
+ cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py,sha256=M92Ir9vzXRMpCXcENE3Jux13C6mrMc6o9julcM6b3uY,11835
36
+ cwyodmodules/batch/utilities/helpers/azure_search_helper.py,sha256=vIIMEck1wPg9oRlWweE2gSZ1nUYc_tmEe4QeFlsrwKk,11314
38
37
  cwyodmodules/batch/utilities/helpers/document_chunking_helper.py,sha256=2MZOjW-fHXgYijP3m9O-nizOlk96Yg0axyxT0K6fTnM,725
39
38
  cwyodmodules/batch/utilities/helpers/document_loading_helper.py,sha256=2HBEl3vW-_PKbX5pPntTC_R5eToTk2Qb-q3M4Mt6hCU,603
40
- cwyodmodules/batch/utilities/helpers/env_helper.py,sha256=sgpaLlw3SlW99j9mvei-XE8wb1lX1f_vhEXeKf7hZvs,16021
41
- cwyodmodules/batch/utilities/helpers/lightrag_helper.py,sha256=18J8G-N7Rt1Yk2Hf2VlM_5LzKTcFTf72U_RCRXvgtMI,3976
42
- cwyodmodules/batch/utilities/helpers/llm_helper.py,sha256=hgxfNhAZGmWLakKTUu6d8FVrmUjFKJyAGUfpls9elL8,8413
39
+ cwyodmodules/batch/utilities/helpers/env_helper.py,sha256=S0EG0XzILrJ_iPCAwKN-kzx-yPl5K__MtBZee924DKE,15881
40
+ cwyodmodules/batch/utilities/helpers/lightrag_helper.py,sha256=7lb9JMm5IohsO73LWo5bWmlzWCGYNsx_fYl-aFdwATQ,3845
41
+ cwyodmodules/batch/utilities/helpers/llm_helper.py,sha256=lHLYrUidtaemmKrVbWoo7oIvwluUoPUk16U5lV-YIX8,8282
43
42
  cwyodmodules/batch/utilities/helpers/orchestrator_helper.py,sha256=mCcZyMFG0otnw9gzWd-PYocHmDdFDVg-RT9oDPiDZPk,897
44
- cwyodmodules/batch/utilities/helpers/secret_helper.py,sha256=eRMDFo7NIjzJpgkKfCSKUwNsrq6gfjoujyRrgu27ci0,2887
43
+ cwyodmodules/batch/utilities/helpers/secret_helper.py,sha256=RYDPR-1c7uChfmAJfzvN_GiI4u6czyWZ67XQah0hla4,2756
45
44
  cwyodmodules/batch/utilities/helpers/config/assistant_strategy.py,sha256=uT8h646zEURU9x8oDOH7pWoZKb0Mw6dA2nJtA2M-ufg,171
46
45
  cwyodmodules/batch/utilities/helpers/config/config_helper.py,sha256=26na6YrLqRLhdSZxTSlOnJOkIcPbTcbFVuPEQTPT3WY,14908
47
46
  cwyodmodules/batch/utilities/helpers/config/conversation_flow.py,sha256=4nP8a-I-sME5-2unzWWBNpTzWdfpfc5_EAYU6Pn6LAQ,94
@@ -55,10 +54,10 @@ cwyodmodules/batch/utilities/helpers/embedders/embedder_factory.py,sha256=cJ9ZTX
55
54
  cwyodmodules/batch/utilities/helpers/embedders/integrated_vectorization_embedder.py,sha256=qguAc5gRxbZdSXe9qjkn1eqRgVc8LrsiZAE3ggeJaSg,3338
56
55
  cwyodmodules/batch/utilities/helpers/embedders/postgres_embedder.py,sha256=_Wc4gkMDsXvGLkz7NpslkTAumvyZt6CHKlktU3bzbcU,4865
57
56
  cwyodmodules/batch/utilities/helpers/embedders/push_embedder.py,sha256=jxOp-AW1vTQMQHR6f-UoD0gFxD2ZJ6E0SLt1KvzdykQ,9143
58
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py,sha256=rDwPgr-UCSYscc7hPOUJMwP09a9rX1MXAGf94TubdQo,2231
59
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py,sha256=VwyfKBUDcWt0uBW_8mtq0XlFzaBZNUdKUjF8WUvt9uU,6733
60
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py,sha256=xhrF783aC1lWSVPHiX8zF_zX6npT4NSE3_UWvGSjcYQ,3361
61
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py,sha256=cfIZbiJAQ15LB0_j_xno8EQt6cY_HfhL07zrU-wBAYI,5902
57
+ cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py,sha256=_412aNCETv21Pb2kAE_L2My_4svxxpIXcY8L7zNmoG0,2123
58
+ cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py,sha256=19qKloRV6_CYJbuGnAwV60sH9lkzyGFGA3SvvKciuDM,6601
59
+ cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py,sha256=qWBsFGIJkrUEcgV8cPv93_FZatVLeLyKD5R-gnSUfj0,3230
60
+ cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py,sha256=5X0cSf-BqiXLbWQ6dVbOOkGQrmsIZp1FD5seJq9YfCI,5771
62
61
  cwyodmodules/batch/utilities/loggers/conversation_logger.py,sha256=0aXsL475-6WTqg18nHFJMFRBo34oIXWrZ_eVZwULcdk,3014
63
62
  cwyodmodules/batch/utilities/orchestrator/__init__.py,sha256=4nCkoUWTROUHJMolgMwPgFIUsJrFUuu0zlHXMUTchRc,479
64
63
  cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py,sha256=X-rnXhd20XUcu2YUYMzKi0acJsBhCADMypauOZkbJas,6892
@@ -76,7 +75,7 @@ cwyodmodules/batch/utilities/plugins/outlook_calendar_plugin.py,sha256=q4RUHa9ij
76
75
  cwyodmodules/batch/utilities/plugins/post_answering_plugin.py,sha256=U1zzf_ztxzl4y-9Qah_n7ylHDZfnDSp2ork5ctdkA5I,1117
77
76
  cwyodmodules/batch/utilities/search/azure_search_handler.py,sha256=SiPy-C2H6pncwTCyUNF5cjL3TZZ4wZmFCMy2xsBjrwk,8046
78
77
  cwyodmodules/batch/utilities/search/azure_search_handler_light_rag.py,sha256=OHyp-QWU-7HTeKxOLNqR7G5r8CIlhDzzuZX-7xVLMQQ,3917
79
- cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py,sha256=nX5JSQd3e-DOcjJsueuDqeqfNgR7ZhkzWQqIInQ8ayU,8600
78
+ cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py,sha256=uphMlUfZiju96w2SC0KyL5n5rS_4OUvrXL03o1aU7to,8490
80
79
  cwyodmodules/batch/utilities/search/lightrag_search_handler.py,sha256=e3AAPyeKEAazJcjz3INy5EJZIUs80MPgKDMFjhgCdaA,3312
81
80
  cwyodmodules/batch/utilities/search/postgres_search_handler.py,sha256=pSkbDwimPuIVyyYKiZIg6jmItLYJ59Xugyiuy9kLEV8,5571
82
81
  cwyodmodules/batch/utilities/search/postgres_search_handler_light_rag.py,sha256=4N5VRK0c0jvRlVL_JozPmBm_tBrloSHRDXexqo1jdis,5981
@@ -85,7 +84,7 @@ cwyodmodules/batch/utilities/search/search_handler_base.py,sha256=UyS9dFoY-Sp4b-
85
84
  cwyodmodules/batch/utilities/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
85
  cwyodmodules/batch/utilities/tools/answer_processing_base.py,sha256=N3Dz7HfN-zl0yPl9cSvnChcEufFMqwRsDAJ5Lgck-ho,293
87
86
  cwyodmodules/batch/utilities/tools/answering_tool_base.py,sha256=aN2ND5Ud_1ZlIPfhLRrOe_m4MUf_SaXvO6q7GcbGiU8,348
88
- cwyodmodules/batch/utilities/tools/content_safety_checker.py,sha256=ViikBC3wwySqcFUB6TcVQSjutCUu5KRgg4InZaHegms,4307
87
+ cwyodmodules/batch/utilities/tools/content_safety_checker.py,sha256=AOCzRkpacBAWVhHtuhK42ON5q8hqHEArmY_lE_G_DJQ,4167
89
88
  cwyodmodules/batch/utilities/tools/post_prompt_tool.py,sha256=tGxw8qMNS7jp8P3KqpqHplicmX064sL2J85VwnCWBbA,2495
90
89
  cwyodmodules/batch/utilities/tools/question_answer_tool.py,sha256=8GWurj50bUND_4x0i1_UPfwl1HMLUIpvq5xBv-q5UDA,12213
91
90
  cwyodmodules/batch/utilities/tools/text_processing_tool.py,sha256=zCF83SQaC8k6z6-Gevxj6AdDKzhU3P_6FG0hAnrG5Zk,1824
@@ -109,8 +108,8 @@ cwyodmodules/graphrag/query/generate.py,sha256=xBnZs2U9xFWtPk4AfAZgYKbHdcxNcIO6Q
109
108
  cwyodmodules/graphrag/query/graph_search.py,sha256=95h3ecSWx4864XgKABtG0fh3Nk8HkqJVzoCrO8daJ-Y,7724
110
109
  cwyodmodules/graphrag/query/types.py,sha256=1Iq1dp4I4a56_cuFjOZ0NTgd0A2_MpVFznp_czgt6cI,617
111
110
  cwyodmodules/graphrag/query/vector_search.py,sha256=9Gwu9LPjtoAYUU8WKqCvbCHAIg3dpk71reoYd1scLnQ,1807
112
- cwyodmodules-0.3.42.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
113
- cwyodmodules-0.3.42.dist-info/METADATA,sha256=48pZpR1Wj91W8zN8om8njkNcQZEJfwk9BdyrpPpHHZk,2002
114
- cwyodmodules-0.3.42.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
- cwyodmodules-0.3.42.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
116
- cwyodmodules-0.3.42.dist-info/RECORD,,
111
+ cwyodmodules-0.3.43.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
112
+ cwyodmodules-0.3.43.dist-info/METADATA,sha256=CJHnTq4Q2E-Dcn8GiIYWPqI4jyvxQ1S44KIVClTitQY,2002
113
+ cwyodmodules-0.3.43.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
114
+ cwyodmodules-0.3.43.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
115
+ cwyodmodules-0.3.43.dist-info/RECORD,,
@@ -1,50 +0,0 @@
1
- from azure.identity import (
2
- TokenCachePersistenceOptions,
3
- get_bearer_token_provider,
4
- DefaultAzureCredential
5
- )
6
-
7
- from logging import getLogger
8
- from opentelemetry import trace, baggage
9
- from opentelemetry.propagate import extract
10
-
11
- logger = getLogger("__main__")
12
- tracer = trace.get_tracer("__main__")
13
-
14
- class AzureIdentityHelper:
15
- """
16
- A helper class to provide a chained Azure token credential.
17
- It prioritizes Managed Identity, then Environment variables.
18
- Token caching is configured for in-memory persistence.
19
- """
20
- def __init__(self):
21
-
22
- token_cache_options = TokenCachePersistenceOptions(allow_unencrypted_storage=True)
23
-
24
- self._credential = DefaultAzureCredential(
25
- token_cache_persistence_options=token_cache_options
26
- )
27
-
28
- def get_credential(self):
29
- """
30
- Returns the configured ChainedTokenCredential.
31
- """
32
- with tracer.start_as_current_span("AzureIdentityHelper.get_credential"):
33
- logger.info("Retrieving ChainedTokenCredential.")
34
- return self._credential
35
-
36
- def get_token(self, scopes):
37
- """
38
- Returns the configured ChainedTokenCredential.
39
- """
40
- with tracer.start_as_current_span("AzureIdentityHelper.get_token_provider"):
41
- logger.info("Retrieving ChainedTokenCredential provider.")
42
- return self._credential.get_token(scopes)
43
-
44
- def get_token_provider(self, scopes):
45
- """
46
- Returns the configured ChainedTokenCredential.
47
- """
48
- with tracer.start_as_current_span("AzureIdentityHelper.get_token_provider"):
49
- logger.info("Retrieving ChainedTokenCredential provider.")
50
- return get_bearer_token_provider(self._credential, scopes)