cwyodmodules 0.3.24__py3-none-any.whl → 0.3.26__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.
@@ -28,10 +28,8 @@ class PostgresConversationClient(DatabaseClientBase):
28
28
  async def connect(self):
29
29
  with tracer.start_as_current_span("PostgresConversationClient.connect"):
30
30
  try:
31
- credential = self.azure_identity_helper.get_credential()
32
- token = credential.get_token(
33
- "https://ossrdbms-aad.database.windows.net/.default"
34
- ).token
31
+ access_information = self.azure_identity_helper.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
32
+ token = access_information.token
35
33
  self.conn = await asyncpg.connect(
36
34
  user=self.user,
37
35
  host=self.host,
@@ -56,8 +56,8 @@ class AzureComputerVisionClient:
56
56
  if self.use_keys:
57
57
  headers["Ocp-Apim-Subscription-Key"] = self.key
58
58
  else:
59
- token_provider = self.azure_identity_helper.get_token_provider(url=self.__TOKEN_SCOPE)
60
- headers["Authorization"] = "Bearer " + token_provider()
59
+ access_information = self.azure_identity_helper.get_token_provider(scopes=self.__TOKEN_SCOPE)
60
+ headers["Authorization"] = "Bearer " + access_information()
61
61
 
62
62
  return requests.post(
63
63
  url=urljoin(self.host, path),
@@ -47,13 +47,21 @@ class AzureIdentityHelper:
47
47
  logger.info("Retrieving ChainedTokenCredential.")
48
48
  return self._credential
49
49
 
50
- def get_token_provider(self, url):
50
+ def get_token(self, scopes):
51
51
  """
52
52
  Returns the configured ChainedTokenCredential.
53
53
  """
54
54
  with tracer.start_as_current_span("AzureIdentityHelper.get_token_provider"):
55
55
  logger.info("Retrieving ChainedTokenCredential provider.")
56
- return get_bearer_token_provider(self._credential, url=url)
56
+ return self._credential.get_token(scopes=scopes)
57
+
58
+ def get_token_provider(self, scopes):
59
+ """
60
+ Returns the configured ChainedTokenCredential.
61
+ """
62
+ with tracer.start_as_current_span("AzureIdentityHelper.get_token_provider"):
63
+ logger.info("Retrieving ChainedTokenCredential provider.")
64
+ return get_bearer_token_provider(self._credential, scopes=scopes)
57
65
 
58
66
 
59
67
  # Example usage (optional, for testing or demonstration):
@@ -25,14 +25,11 @@ class AzurePostgresHelper:
25
25
  dbname = self.env_helper.POSTGRESQL_DATABASE
26
26
 
27
27
  # Acquire the access token
28
- credential = self.azure_identity_helper.get_credential()
29
- access_token = credential.get_token(
30
- "https://ossrdbms-aad.database.windows.net/.default"
31
- )
32
-
28
+ access_information = self.azure_identity_helper.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
29
+ token = access_information.token
33
30
  # Use the token in the connection string
34
31
  conn_string = (
35
- f"host={host} user={user} dbname={dbname} password={access_token.token}"
32
+ f"host={host} user={user} dbname={dbname} password={token}"
36
33
  )
37
34
  keepalive_kwargs = {
38
35
  "keepalives": 1,
@@ -27,14 +27,11 @@ class AzurePostgresHelper:
27
27
  dbname = self.env_helper.POSTGRESQL_DATABASE
28
28
 
29
29
  # Acquire the access token
30
- credential = self.azure_identity_helper.get_credential()
31
- access_token = credential.get_token(
32
- "https://ossrdbms-aad.database.windows.net/.default"
33
- )
34
-
30
+ access_information = self.azure_identity_helper.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
31
+ token = access_information.token
35
32
  # Use the token in the connection string
36
33
  conn_string = (
37
- f"host={host} user={user} dbname={dbname} password={access_token.token}"
34
+ f"host={host} user={user} dbname={dbname} password={token}"
38
35
  )
39
36
  keepalive_kwargs = {
40
37
  "keepalives": 1,
@@ -36,7 +36,7 @@ class EnvHelper:
36
36
  # load_dotenv()
37
37
 
38
38
  logger.info("Initializing EnvHelper")
39
-
39
+
40
40
  # Wrapper for Azure Key Vault
41
41
  os.environ["APPLICATIONINSIGHTS_ENABLED"] = "true"
42
42
 
@@ -73,8 +73,9 @@ class EnvHelper:
73
73
  f"psql-main-{self.PROJECT_CODE}-{self.AZURE_RESOURCE_ENVIRONMENT}"
74
74
  )
75
75
  self.AZURE_AUTH_TYPE = "rbac"
76
- self.AZURE_TOKEN_PROVIDER = AzureIdentityHelper.get_token_provider(url="https://cognitiveservices.azure.com/.default"
77
- )
76
+ azure_identity_helper = AzureIdentityHelper()# Extract context from the incoming request
77
+ access_information = azure_identity_helper.get_token_provider(scopes="https://cognitiveservices.azure.com/.default")
78
+ self.AZURE_TOKEN_PROVIDER = access_information
78
79
  self.AZURE_BLOB_ACCOUNT_NAME = (
79
80
  f"stqueue{self.PROJECT_CODE}{self.AZURE_RESOURCE_ENVIRONMENT}"
80
81
  )
@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__ + ".base_package")
8
8
  class LightRAGHelper:
9
9
  def __init__(self, env_helper):
10
10
  self.env_helper = env_helper
11
- azure_identity_helper = AzureIdentityHelper()
11
+ self.azure_identity_helper = AzureIdentityHelper()
12
12
  self.conn = None
13
13
 
14
14
  def _create_connection(self):
@@ -21,14 +21,11 @@ class LightRAGHelper:
21
21
  dbname = self.env_helper.POSTGRESQL_DATABASE
22
22
 
23
23
  # Acquire the access token
24
- credential = self.azure_identity_helper.get_credential()
25
- access_token = credential.get_token(
26
- "https://ossrdbms-aad.database.windows.net/.default"
27
- )
28
-
24
+ access_information = self.azure_identity_helper.get_token(scopes="https://ossrdbms-aad.database.windows.net/.default")
25
+ token = access_information.token
29
26
  # Use the token in the connection string
30
27
  conn_string = (
31
- f"host={host} user={user} dbname={dbname} password={access_token.token}"
28
+ f"host={host} user={user} dbname={dbname} password={token}"
32
29
  )
33
30
  keepalive_kwargs = {
34
31
  "keepalives": 1,
@@ -325,7 +325,11 @@ class QuestionAnswerTool(AnsweringToolBase):
325
325
  logger.debug(f"Answer format_answer_from_response: {answer}")
326
326
 
327
327
  # Append document citations to the answer
328
- citations = "".join([f"[doc{i+1}]" for i in range(len(source_documents))])
328
+ citations = "".join([
329
+ f"[doc{i+1}]"
330
+ for i in range(len(source_documents))
331
+ if f"[doc{i+1}]" not in answer
332
+ ])
329
333
  answer_with_citations = f"{answer} {citations}"
330
334
  # Generate Answer Object
331
335
  clean_answer = Answer(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.24
3
+ Version: 0.3.26
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -6,7 +6,7 @@ cwyodmodules/batch/utilities/chat_history/auth_utils.py,sha256=TBSg7-ypKNnCPsmWp
6
6
  cwyodmodules/batch/utilities/chat_history/cosmosdb.py,sha256=oiL_iM6yUoxadP7Cx0ewiVAfS2ubdouuI6gllva4-Is,7374
7
7
  cwyodmodules/batch/utilities/chat_history/database_client_base.py,sha256=6y7h2iL0Uxn4c11N99Ao-8nplQGVGQAOnev3GlHIDXA,2328
8
8
  cwyodmodules/batch/utilities/chat_history/database_factory.py,sha256=kdleC4P8u8rYPsx2HcPQwyOgFf_mph3Nh-Mmzz1V7oM,2401
9
- cwyodmodules/batch/utilities/chat_history/postgresdbservice.py,sha256=ktAb0d2fPQLA5N_ti-KE7o96MkjN0hEyWHDDd7KBH90,14081
9
+ cwyodmodules/batch/utilities/chat_history/postgresdbservice.py,sha256=L1WTTHX9RfY_wWhu7vQXDBoZOfXfOtFqSrUjE0h0sYA,14047
10
10
  cwyodmodules/batch/utilities/chat_history/sample_user.py,sha256=GNXZ_yTjud8Zj0vgHnoU96RJMiJt0YRjEVO3pt7203A,3037
11
11
  cwyodmodules/batch/utilities/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  cwyodmodules/batch/utilities/common/answer.py,sha256=C1g_Xt85TfXK2qV1F6J5_o3MyIUdFpUmvgkIpuEcp4I,3093
@@ -28,16 +28,16 @@ cwyodmodules/batch/utilities/document_loading/web.py,sha256=LRTNYs_7CN8nfMOaCoW7
28
28
  cwyodmodules/batch/utilities/document_loading/word_document.py,sha256=-F1asMaupQk4swEeCoAD8tyYENE4Qq-05-VmPUjRdeA,1569
29
29
  cwyodmodules/batch/utilities/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py,sha256=FN2XnEThmtbWnwSi1sEfgekuPH7aJBOAU5n2DBmQ9ww,10315
31
- cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py,sha256=JUv0qRlNi4OmBvNMNlrpeBXapgs3FU5WE8MmebGTs5k,3628
31
+ cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py,sha256=Wq6Sx5k9XZm9xEWMOiNDzxd_Sh7-M4EPRra5QEf5yCs,3639
32
32
  cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py,sha256=wpY4Ih1GPCFgrL4MhznpZSYDFN20R5LV_xlegPt3Phs,6715
33
- cwyodmodules/batch/utilities/helpers/azure_identity_helper.py,sha256=0xX5x_iBCIThjYnb7PjU1W54fBaVwA6fYDh3CjQTS5Y,2482
34
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py,sha256=VVqP6koqavcOjdcBf1lPBlI_Mrt4i46bgICgPwpyE_A,10891
35
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py,sha256=N2WVi77Z85q8Ft_LyOjsD-NytA0atLTFa961HHuQ9ro,10971
33
+ cwyodmodules/batch/utilities/helpers/azure_identity_helper.py,sha256=mB7Xel5G2VD1bb1MVTiYcxmIl-h0980dpHT0fTPRHQk,2829
34
+ cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py,sha256=WSIGBuIp0MNsI67h-t24T26LrX9QvGg4uijAY4YItPg,10852
35
+ cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py,sha256=Ui5diqo-okPiH416A1EyPg1zZLRI1h986jQimcPi0ls,10932
36
36
  cwyodmodules/batch/utilities/helpers/azure_search_helper.py,sha256=U_o6NVtJKByhxbvMKnWtfw2lx43pHBtSsGpThJnrOPo,10425
37
37
  cwyodmodules/batch/utilities/helpers/document_chunking_helper.py,sha256=2MZOjW-fHXgYijP3m9O-nizOlk96Yg0axyxT0K6fTnM,725
38
38
  cwyodmodules/batch/utilities/helpers/document_loading_helper.py,sha256=2HBEl3vW-_PKbX5pPntTC_R5eToTk2Qb-q3M4Mt6hCU,603
39
- cwyodmodules/batch/utilities/helpers/env_helper.py,sha256=Ku_4j6DuKXDgnFul4zrZr_C5iESbmlEPwKWyIkb6aII,15744
40
- cwyodmodules/batch/utilities/helpers/lightrag_helper.py,sha256=GooV_V9uaBmWq89cak_bzSn6Hvjv2PxIQO3eW0Uryy8,3485
39
+ cwyodmodules/batch/utilities/helpers/env_helper.py,sha256=l0kRDKEzYcPyKm6USVRKDtk-NXHrr7hbq8CxWlPvfm0,15893
40
+ cwyodmodules/batch/utilities/helpers/lightrag_helper.py,sha256=m5xlzDGzWGm-ZkpB88VzE-jXRdntBEyUv24mDpotc94,3455
41
41
  cwyodmodules/batch/utilities/helpers/llm_helper.py,sha256=icJy0ix4TimrJKRmYUnODJeh8wHYawAmeZ5QsamAiUg,7499
42
42
  cwyodmodules/batch/utilities/helpers/orchestrator_helper.py,sha256=mCcZyMFG0otnw9gzWd-PYocHmDdFDVg-RT9oDPiDZPk,897
43
43
  cwyodmodules/batch/utilities/helpers/secret_helper.py,sha256=HqzkK83ScREQYtOAoThTmyhTni6n6aQzeJQeVmcN13E,3098
@@ -86,7 +86,7 @@ cwyodmodules/batch/utilities/tools/answer_processing_base.py,sha256=N3Dz7HfN-zl0
86
86
  cwyodmodules/batch/utilities/tools/answering_tool_base.py,sha256=aN2ND5Ud_1ZlIPfhLRrOe_m4MUf_SaXvO6q7GcbGiU8,348
87
87
  cwyodmodules/batch/utilities/tools/content_safety_checker.py,sha256=UuSleGcgH1NzGLsQVU5dONgQSARt7jmhm2WATdHkHq8,4863
88
88
  cwyodmodules/batch/utilities/tools/post_prompt_tool.py,sha256=rhRU18IDfR0Bfu-gdkrRFwOXxNoKm2NY8NoikmjXYRI,2932
89
- cwyodmodules/batch/utilities/tools/question_answer_tool.py,sha256=A-yApCrI3RFvdmmP4RNJQY8qf8eSXE7V4-mbbWvV6mo,13055
89
+ cwyodmodules/batch/utilities/tools/question_answer_tool.py,sha256=JF3XPTEk6FGebLFcBUhT1nNIt_MXGNZmwPYah4cG4Ak,13148
90
90
  cwyodmodules/batch/utilities/tools/text_processing_tool.py,sha256=KSKo8Gm6QgQ5TkoISE4eAfiGOyChN4tCV4Qy5eh0_wQ,1997
91
91
  cwyodmodules/graphrag/__init__.py,sha256=O5fi4Q3RC9Gt8ItNZGV1HjyIJvEz7grYXTFMmUWstxw,111
92
92
  cwyodmodules/graphrag/config.py,sha256=TvG45dezHkqgZzWnPxhpyWciIiKOrD_3JQ3APkoD6Hw,1525
@@ -108,8 +108,8 @@ cwyodmodules/graphrag/query/generate.py,sha256=xBnZs2U9xFWtPk4AfAZgYKbHdcxNcIO6Q
108
108
  cwyodmodules/graphrag/query/graph_search.py,sha256=95h3ecSWx4864XgKABtG0fh3Nk8HkqJVzoCrO8daJ-Y,7724
109
109
  cwyodmodules/graphrag/query/types.py,sha256=1Iq1dp4I4a56_cuFjOZ0NTgd0A2_MpVFznp_czgt6cI,617
110
110
  cwyodmodules/graphrag/query/vector_search.py,sha256=9Gwu9LPjtoAYUU8WKqCvbCHAIg3dpk71reoYd1scLnQ,1807
111
- cwyodmodules-0.3.24.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
112
- cwyodmodules-0.3.24.dist-info/METADATA,sha256=9g64P79MLzDT2cV5kLE0XeOqKAMh59ykcDEyZuxuFsU,1969
113
- cwyodmodules-0.3.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
114
- cwyodmodules-0.3.24.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
115
- cwyodmodules-0.3.24.dist-info/RECORD,,
111
+ cwyodmodules-0.3.26.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
112
+ cwyodmodules-0.3.26.dist-info/METADATA,sha256=osdJnBZgG-oLWInIbdYsBxswchDD7vU7-bayIz6PmzY,1969
113
+ cwyodmodules-0.3.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
114
+ cwyodmodules-0.3.26.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
115
+ cwyodmodules-0.3.26.dist-info/RECORD,,