cwyodmodules 0.3.36__py3-none-any.whl → 0.3.37__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.
- cwyodmodules/api/chat_history.py +10 -9
- cwyodmodules/batch/utilities/chat_history/auth_utils.py +3 -2
- cwyodmodules/batch/utilities/chat_history/cosmosdb.py +13 -12
- cwyodmodules/batch/utilities/chat_history/postgresdbservice.py +13 -12
- cwyodmodules/batch/utilities/common/source_document.py +9 -8
- cwyodmodules/batch/utilities/document_chunking/fixed_size_overlap.py +2 -1
- cwyodmodules/batch/utilities/document_chunking/layout.py +2 -1
- cwyodmodules/batch/utilities/document_chunking/page.py +2 -1
- cwyodmodules/batch/utilities/document_loading/read.py +2 -1
- cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py +7 -6
- cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py +3 -2
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py +11 -10
- cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py +11 -10
- cwyodmodules/batch/utilities/helpers/azure_search_helper.py +10 -9
- cwyodmodules/batch/utilities/helpers/config/config_helper.py +20 -19
- cwyodmodules/batch/utilities/helpers/embedders/integrated_vectorization_embedder.py +4 -3
- cwyodmodules/batch/utilities/helpers/embedders/postgres_embedder.py +4 -3
- cwyodmodules/batch/utilities/helpers/embedders/push_embedder.py +7 -6
- cwyodmodules/batch/utilities/helpers/env_helper.py +4 -1
- cwyodmodules/batch/utilities/helpers/lightrag_helper.py +5 -4
- cwyodmodules/batch/utilities/helpers/llm_helper.py +10 -9
- cwyodmodules/batch/utilities/helpers/secret_helper.py +3 -3
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py +5 -4
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py +4 -3
- cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py +2 -1
- cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py +4 -3
- cwyodmodules/batch/utilities/orchestrator/open_ai_functions.py +2 -1
- cwyodmodules/batch/utilities/orchestrator/orchestrator_base.py +5 -4
- cwyodmodules/batch/utilities/orchestrator/prompt_flow.py +5 -4
- cwyodmodules/batch/utilities/orchestrator/semantic_kernel_orchestrator.py +2 -1
- cwyodmodules/batch/utilities/parser/output_parser_tool.py +5 -4
- cwyodmodules/batch/utilities/plugins/outlook_calendar_plugin.py +4 -3
- cwyodmodules/batch/utilities/search/azure_search_handler.py +12 -11
- cwyodmodules/batch/utilities/search/azure_search_handler_light_rag.py +10 -9
- cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py +12 -11
- cwyodmodules/batch/utilities/search/lightrag_search_handler.py +9 -8
- cwyodmodules/batch/utilities/search/postgres_search_handler.py +13 -12
- cwyodmodules/batch/utilities/search/postgres_search_handler_light_rag.py +14 -13
- cwyodmodules/batch/utilities/search/search.py +3 -2
- cwyodmodules/batch/utilities/tools/content_safety_checker.py +5 -4
- cwyodmodules/batch/utilities/tools/post_prompt_tool.py +2 -1
- cwyodmodules/batch/utilities/tools/question_answer_tool.py +8 -7
- cwyodmodules/batch/utilities/tools/text_processing_tool.py +2 -1
- {cwyodmodules-0.3.36.dist-info → cwyodmodules-0.3.37.dist-info}/METADATA +2 -2
- {cwyodmodules-0.3.36.dist-info → cwyodmodules-0.3.37.dist-info}/RECORD +48 -48
- {cwyodmodules-0.3.36.dist-info → cwyodmodules-0.3.37.dist-info}/WHEEL +0 -0
- {cwyodmodules-0.3.36.dist-info → cwyodmodules-0.3.37.dist-info}/licenses/LICENSE +0 -0
- {cwyodmodules-0.3.36.dist-info → cwyodmodules-0.3.37.dist-info}/top_level.txt +0 -0
@@ -26,6 +26,7 @@ from ..helpers.llm_helper import LLMHelper
|
|
26
26
|
|
27
27
|
from logging_config import logger
|
28
28
|
env_helper: EnvHelper = EnvHelper()
|
29
|
+
log_execution = env_helper.LOG_EXECUTION
|
29
30
|
log_args = env_helper.LOG_ARGS
|
30
31
|
log_result = env_helper.LOG_RESULT
|
31
32
|
|
@@ -48,7 +49,7 @@ class AzureSearchIndex:
|
|
48
49
|
)
|
49
50
|
|
50
51
|
@property
|
51
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
52
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
52
53
|
def search_dimensions(self) -> int:
|
53
54
|
if AzureSearchIndex._search_dimension is None:
|
54
55
|
AzureSearchIndex._search_dimension = len(
|
@@ -56,7 +57,7 @@ class AzureSearchIndex:
|
|
56
57
|
)
|
57
58
|
return AzureSearchIndex._search_dimension
|
58
59
|
|
59
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
60
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
60
61
|
def create_or_update_index(self):
|
61
62
|
# Create a search index
|
62
63
|
fields = [
|
@@ -119,7 +120,7 @@ class AzureSearchIndex:
|
|
119
120
|
logger.info(f"{result.name} index created successfully.")
|
120
121
|
return result
|
121
122
|
|
122
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
123
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
123
124
|
def get_vector_search_config(self):
|
124
125
|
if self.env_helper.is_auth_type_keys():
|
125
126
|
azure_open_ai_parameters = AzureOpenAIParameters(
|
@@ -172,7 +173,7 @@ class AzureSearchIndex:
|
|
172
173
|
],
|
173
174
|
)
|
174
175
|
|
175
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
176
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
176
177
|
def get_semantic_search_config(self):
|
177
178
|
semantic_config = SemanticConfiguration(
|
178
179
|
name=self.env_helper.AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG,
|
@@ -8,6 +8,7 @@ from azure.core.credentials import AzureKeyCredential
|
|
8
8
|
from ...utilities.helpers.env_helper import EnvHelper
|
9
9
|
from logging_config import logger
|
10
10
|
env_helper: EnvHelper = EnvHelper()
|
11
|
+
log_execution = env_helper.LOG_EXECUTION
|
11
12
|
log_args = env_helper.LOG_ARGS
|
12
13
|
log_result = env_helper.LOG_RESULT
|
13
14
|
|
@@ -26,7 +27,7 @@ class AzureSearchIndexer:
|
|
26
27
|
),
|
27
28
|
)
|
28
29
|
|
29
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
30
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
30
31
|
def create_or_update_indexer(self, indexer_name: str, skillset_name: str):
|
31
32
|
indexer = SearchIndexer(
|
32
33
|
name=indexer_name,
|
@@ -64,7 +65,7 @@ class AzureSearchIndexer:
|
|
64
65
|
)
|
65
66
|
return indexer_result
|
66
67
|
|
67
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
68
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
68
69
|
def run_indexer(self, indexer_name: str):
|
69
70
|
self.indexer_client.reset_indexer(indexer_name)
|
70
71
|
self.indexer_client.run_indexer(indexer_name)
|
@@ -72,7 +73,7 @@ class AzureSearchIndexer:
|
|
72
73
|
f" {indexer_name} is created and running. If queries return no results, please wait a bit and try again."
|
73
74
|
)
|
74
75
|
|
75
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
76
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
76
77
|
def indexer_exists(self, indexer_name: str):
|
77
78
|
return indexer_name in [
|
78
79
|
name for name in self.indexer_client.get_indexer_names()
|
@@ -20,6 +20,7 @@ from azure.core.credentials import AzureKeyCredential
|
|
20
20
|
from ...utilities.helpers.env_helper import EnvHelper
|
21
21
|
from logging_config import logger
|
22
22
|
env_helper: EnvHelper = EnvHelper()
|
23
|
+
log_execution = env_helper.LOG_EXECUTION
|
23
24
|
log_args = env_helper.LOG_ARGS
|
24
25
|
log_result = env_helper.LOG_RESULT
|
25
26
|
|
@@ -43,7 +44,7 @@ class AzureSearchSkillset:
|
|
43
44
|
)
|
44
45
|
self.integrated_vectorization_config = integrated_vectorization_config
|
45
46
|
|
46
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
47
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
47
48
|
def create_skillset(self):
|
48
49
|
skillset_name = f"{self.env_helper.AZURE_SEARCH_INDEX}-skillset"
|
49
50
|
|
@@ -15,6 +15,7 @@ from ..common.answer import Answer
|
|
15
15
|
from ...utilities.helpers.env_helper import EnvHelper
|
16
16
|
from logging_config import logger
|
17
17
|
env_helper: EnvHelper = EnvHelper()
|
18
|
+
log_execution = env_helper.LOG_EXECUTION
|
18
19
|
log_args = env_helper.LOG_ARGS
|
19
20
|
log_result = env_helper.LOG_RESULT
|
20
21
|
|
@@ -51,7 +52,7 @@ class LangChainAgent(OrchestratorBase):
|
|
51
52
|
),
|
52
53
|
]
|
53
54
|
|
54
|
-
@logger.trace_function(log_args=False, log_result=False)
|
55
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
55
56
|
def run_tool(self, user_message: str) -> str:
|
56
57
|
"""
|
57
58
|
Executes the question answering tool with the provided user message.
|
@@ -67,7 +68,7 @@ class LangChainAgent(OrchestratorBase):
|
|
67
68
|
)
|
68
69
|
return answer.to_json()
|
69
70
|
|
70
|
-
@logger.trace_function(log_args=False, log_result=False)
|
71
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
71
72
|
def run_text_processing_tool(self, user_message: str) -> str:
|
72
73
|
"""
|
73
74
|
Executes the text processing tool with the provided user message.
|
@@ -83,7 +84,7 @@ class LangChainAgent(OrchestratorBase):
|
|
83
84
|
)
|
84
85
|
return answer.to_json()
|
85
86
|
|
86
|
-
@logger.trace_function(log_args=False, log_result=False)
|
87
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
87
88
|
async def orchestrate(
|
88
89
|
self, user_message: str, chat_history: List[dict], **kwargs: dict
|
89
90
|
) -> list[dict]:
|
@@ -12,6 +12,7 @@ from ..common.answer import Answer
|
|
12
12
|
from ...utilities.helpers.env_helper import EnvHelper
|
13
13
|
from logging_config import logger
|
14
14
|
env_helper: EnvHelper = EnvHelper()
|
15
|
+
log_execution = env_helper.LOG_EXECUTION
|
15
16
|
log_args = env_helper.LOG_ARGS
|
16
17
|
log_result = env_helper.LOG_RESULT
|
17
18
|
|
@@ -68,7 +69,7 @@ class OpenAIFunctionsOrchestrator(OrchestratorBase):
|
|
68
69
|
},
|
69
70
|
]
|
70
71
|
|
71
|
-
@logger.trace_function(log_args=False, log_result=False)
|
72
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
72
73
|
async def orchestrate(
|
73
74
|
self, user_message: str, chat_history: List[dict], **kwargs: dict
|
74
75
|
) -> list[dict]:
|
@@ -9,6 +9,7 @@ from ..tools.content_safety_checker import ContentSafetyChecker
|
|
9
9
|
from ...utilities.helpers.env_helper import EnvHelper
|
10
10
|
from logging_config import logger
|
11
11
|
env_helper: EnvHelper = EnvHelper()
|
12
|
+
log_execution = env_helper.LOG_EXECUTION
|
12
13
|
log_args = env_helper.LOG_ARGS
|
13
14
|
log_result = env_helper.LOG_RESULT
|
14
15
|
|
@@ -34,7 +35,7 @@ class OrchestratorBase(ABC):
|
|
34
35
|
self.content_safety_checker = ContentSafetyChecker()
|
35
36
|
self.output_parser = OutputParserTool()
|
36
37
|
|
37
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
38
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
38
39
|
def log_tokens(self, prompt_tokens: int, completion_tokens: int) -> None:
|
39
40
|
"""
|
40
41
|
Logs the number of tokens used in the prompt and completion phases of a conversation.
|
@@ -48,7 +49,7 @@ class OrchestratorBase(ABC):
|
|
48
49
|
self.tokens["total"] += prompt_tokens + completion_tokens
|
49
50
|
|
50
51
|
@abstractmethod
|
51
|
-
@logger.trace_function(log_args=False, log_result=False)
|
52
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
52
53
|
async def orchestrate(
|
53
54
|
self,
|
54
55
|
user_message: str,
|
@@ -94,7 +95,7 @@ class OrchestratorBase(ABC):
|
|
94
95
|
|
95
96
|
return None
|
96
97
|
|
97
|
-
@logger.trace_function(log_args=False, log_result=False)
|
98
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
98
99
|
def call_content_safety_output(
|
99
100
|
self, user_message: str, answer: str
|
100
101
|
) -> Optional[list[dict]]:
|
@@ -121,7 +122,7 @@ class OrchestratorBase(ABC):
|
|
121
122
|
|
122
123
|
return None
|
123
124
|
|
124
|
-
@logger.trace_function(log_args=False, log_result=False)
|
125
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
125
126
|
async def handle_message(
|
126
127
|
self,
|
127
128
|
user_message: str,
|
@@ -10,6 +10,7 @@ from ..helpers.env_helper import EnvHelper
|
|
10
10
|
|
11
11
|
from logging_config import logger
|
12
12
|
env_helper: EnvHelper = EnvHelper()
|
13
|
+
log_execution = env_helper.LOG_EXECUTION
|
13
14
|
log_args = env_helper.LOG_ARGS
|
14
15
|
log_result = env_helper.LOG_RESULT
|
15
16
|
|
@@ -37,7 +38,7 @@ class PromptFlowOrchestrator(OrchestratorBase):
|
|
37
38
|
|
38
39
|
logger.info("PromptFlowOrchestrator initialized.")
|
39
40
|
|
40
|
-
@logger.trace_function(log_args=False, log_result=False)
|
41
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
41
42
|
async def orchestrate(
|
42
43
|
self, user_message: str, chat_history: List[dict], **kwargs: dict
|
43
44
|
) -> list[dict]:
|
@@ -111,7 +112,7 @@ class PromptFlowOrchestrator(OrchestratorBase):
|
|
111
112
|
logger.info("Orchestration completed successfully.")
|
112
113
|
return messages
|
113
114
|
|
114
|
-
@logger.trace_function(log_args=False, log_result=False)
|
115
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
115
116
|
def transform_chat_history(self, chat_history: List[dict]) -> List[dict]:
|
116
117
|
"""
|
117
118
|
Transform the chat history into a format suitable for the Prompt Flow service.
|
@@ -142,7 +143,7 @@ class PromptFlowOrchestrator(OrchestratorBase):
|
|
142
143
|
logger.info("Chat history transformation completed.")
|
143
144
|
return transformed_chat_history
|
144
145
|
|
145
|
-
@logger.trace_function(log_args=False, log_result=False)
|
146
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
146
147
|
def transform_data_into_file(
|
147
148
|
self, user_message: str, chat_history: List[dict]
|
148
149
|
) -> str:
|
@@ -164,7 +165,7 @@ class PromptFlowOrchestrator(OrchestratorBase):
|
|
164
165
|
logger.info("Temporary file created")
|
165
166
|
return file.name
|
166
167
|
|
167
|
-
@logger.trace_function(log_args=False, log_result=False)
|
168
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
168
169
|
def transform_citations_into_source_documents(
|
169
170
|
self, citations: dict
|
170
171
|
) -> List[SourceDocument]:
|
@@ -22,6 +22,7 @@ from .orchestrator_base import OrchestratorBase
|
|
22
22
|
|
23
23
|
from logging_config import logger
|
24
24
|
env_helper: EnvHelper = EnvHelper()
|
25
|
+
log_execution = env_helper.LOG_EXECUTION
|
25
26
|
log_args = env_helper.LOG_ARGS
|
26
27
|
log_result = env_helper.LOG_RESULT
|
27
28
|
|
@@ -42,7 +43,7 @@ class SemanticKernelOrchestrator(OrchestratorBase):
|
|
42
43
|
plugin=PostAnsweringPlugin(), plugin_name="PostAnswering"
|
43
44
|
)
|
44
45
|
|
45
|
-
@logger.trace_function(log_args=False, log_result=False)
|
46
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
46
47
|
async def orchestrate(
|
47
48
|
self, user_message: str, chat_history: list[dict], user_info, **kwargs: dict
|
48
49
|
) -> list[dict]:
|
@@ -7,6 +7,7 @@ from ..common.source_document import SourceDocument
|
|
7
7
|
from ...utilities.helpers.env_helper import EnvHelper
|
8
8
|
from logging_config import logger
|
9
9
|
env_helper: EnvHelper = EnvHelper()
|
10
|
+
log_execution = env_helper.LOG_EXECUTION
|
10
11
|
log_args = env_helper.LOG_ARGS
|
11
12
|
log_result = env_helper.LOG_RESULT
|
12
13
|
|
@@ -23,7 +24,7 @@ class OutputParserTool(ParserBase):
|
|
23
24
|
"""
|
24
25
|
self.name = "OutputParser"
|
25
26
|
|
26
|
-
@logger.trace_function(log_args=False, log_result=False)
|
27
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
27
28
|
def _clean_up_answer(self, answer: str) -> str:
|
28
29
|
"""
|
29
30
|
Cleans up the answer by replacing double spaces with single spaces.
|
@@ -36,7 +37,7 @@ class OutputParserTool(ParserBase):
|
|
36
37
|
"""
|
37
38
|
return answer.replace(" ", " ")
|
38
39
|
|
39
|
-
@logger.trace_function(log_args=False, log_result=False)
|
40
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
40
41
|
def _get_source_docs_from_answer(self, answer: str) -> List[int]:
|
41
42
|
"""
|
42
43
|
Extracts all document references from the answer and returns them as a list of integers.
|
@@ -50,7 +51,7 @@ class OutputParserTool(ParserBase):
|
|
50
51
|
results = re.findall(r"\[doc(\d+)\]", answer)
|
51
52
|
return [int(i) for i in results]
|
52
53
|
|
53
|
-
@logger.trace_function(log_args=False, log_result=False)
|
54
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
54
55
|
def _make_doc_references_sequential(self, answer: str) -> str:
|
55
56
|
"""
|
56
57
|
Makes document references in the answer sequential.
|
@@ -72,7 +73,7 @@ class OutputParserTool(ParserBase):
|
|
72
73
|
offset += len(f"[doc{i + 1}]") - (end - start)
|
73
74
|
return updated_answer
|
74
75
|
|
75
|
-
@logger.trace_function(log_args=False, log_result=False)
|
76
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
76
77
|
def parse(
|
77
78
|
self,
|
78
79
|
question: str,
|
@@ -6,6 +6,7 @@ from ...utilities.helpers.env_helper import EnvHelper
|
|
6
6
|
|
7
7
|
from logging_config import logger
|
8
8
|
env_helper: EnvHelper = EnvHelper()
|
9
|
+
log_execution = env_helper.LOG_EXECUTION
|
9
10
|
log_args = env_helper.LOG_ARGS
|
10
11
|
log_result = env_helper.LOG_RESULT
|
11
12
|
|
@@ -16,7 +17,7 @@ class OutlookCalendarPlugin:
|
|
16
17
|
self.user_info = user_info
|
17
18
|
self.env_helper = EnvHelper()
|
18
19
|
|
19
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
20
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
20
21
|
def _get_access_token(self) -> str:
|
21
22
|
logger.info("Retrieving access token from user info")
|
22
23
|
access_token = self.user_info.get("access_token", None)
|
@@ -27,7 +28,7 @@ class OutlookCalendarPlugin:
|
|
27
28
|
return access_token
|
28
29
|
|
29
30
|
@kernel_function(name="get_calendar_events", description="Get upcoming Outlook calendar events, appointments, metings, etc.")
|
30
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
31
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
31
32
|
def get_calendar_events(self, days: int = 1) -> str:
|
32
33
|
language = self.env_helper.AZURE_MAIN_CHAT_LANGUAGE
|
33
34
|
logger.info("Method get_calendar_events of OutlookCalendarPlugin started")
|
@@ -75,7 +76,7 @@ class OutlookCalendarPlugin:
|
|
75
76
|
return answer
|
76
77
|
|
77
78
|
@kernel_function(name="schedule_appointment", description="Schedule a new Outlook calendar appointment, meeting, etc.")
|
78
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
79
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
79
80
|
def schedule_appointment(self, subject: str, start_time: str, end_time: str) -> str:
|
80
81
|
logger.info("Method schedule_appointment of OutlookCalendarPlugin started")
|
81
82
|
language = self.env_helper.AZURE_MAIN_CHAT_LANGUAGE
|
@@ -11,6 +11,7 @@ import tiktoken
|
|
11
11
|
from ...utilities.helpers.env_helper import EnvHelper
|
12
12
|
from logging_config import logger
|
13
13
|
env_helper: EnvHelper = EnvHelper()
|
14
|
+
log_execution = env_helper.LOG_EXECUTION
|
14
15
|
log_args = env_helper.LOG_ARGS
|
15
16
|
log_result = env_helper.LOG_RESULT
|
16
17
|
|
@@ -23,17 +24,17 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
23
24
|
self.llm_helper = LLMHelper()
|
24
25
|
self.azure_computer_vision_client = AzureComputerVisionClient(env_helper)
|
25
26
|
|
26
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
27
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
27
28
|
def create_search_client(self):
|
28
29
|
return AzureSearchHelper().get_search_client()
|
29
30
|
|
30
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
31
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
31
32
|
def perform_search(self, filename):
|
32
33
|
return self.search_client.search(
|
33
34
|
"*", select="title, content, metadata", filter=f"title eq '{filename}'"
|
34
35
|
)
|
35
36
|
|
36
|
-
@logger.trace_function(log_args=False, log_result=False)
|
37
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
37
38
|
def process_results(self, results):
|
38
39
|
logger.info("Processing search results")
|
39
40
|
if results is None:
|
@@ -47,13 +48,13 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
47
48
|
logger.info("Processed results")
|
48
49
|
return data
|
49
50
|
|
50
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
51
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
51
52
|
def get_files(self):
|
52
53
|
return self.search_client.search(
|
53
54
|
"*", select="id, title", include_total_count=True
|
54
55
|
)
|
55
56
|
|
56
|
-
@logger.trace_function(log_args=False, log_result=False)
|
57
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
57
58
|
def output_results(self, results):
|
58
59
|
files = {}
|
59
60
|
for result in results:
|
@@ -66,7 +67,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
66
67
|
|
67
68
|
return files
|
68
69
|
|
69
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
70
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
70
71
|
def delete_files(self, files):
|
71
72
|
ids_to_delete = []
|
72
73
|
files_to_delete = []
|
@@ -78,7 +79,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
78
79
|
|
79
80
|
return ", ".join(files_to_delete)
|
80
81
|
|
81
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
82
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
82
83
|
def search_by_blob_url(self, blob_url):
|
83
84
|
return self.search_client.search(
|
84
85
|
"*",
|
@@ -87,7 +88,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
87
88
|
filter=f"source eq '{blob_url}_SAS_TOKEN_PLACEHOLDER_'",
|
88
89
|
)
|
89
90
|
|
90
|
-
@logger.trace_function(log_args=False, log_result=False)
|
91
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
91
92
|
def query_search(self, question) -> List[SourceDocument]:
|
92
93
|
logger.info(f"Performing query search for question: {question}")
|
93
94
|
encoding = tiktoken.get_encoding(self._ENCODER_NAME)
|
@@ -116,7 +117,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
116
117
|
logger.info("Converting search results to SourceDocument list")
|
117
118
|
return self._convert_to_source_documents(results)
|
118
119
|
|
119
|
-
@logger.trace_function(log_args=False, log_result=False)
|
120
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
120
121
|
def _semantic_search(
|
121
122
|
self,
|
122
123
|
question: str,
|
@@ -151,7 +152,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
151
152
|
top=self.env_helper.AZURE_SEARCH_TOP_K,
|
152
153
|
)
|
153
154
|
|
154
|
-
@logger.trace_function(log_args=False, log_result=False)
|
155
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
155
156
|
def _hybrid_search(
|
156
157
|
self,
|
157
158
|
question: str,
|
@@ -184,7 +185,7 @@ class AzureSearchHandler(SearchHandlerBase):
|
|
184
185
|
top=self.env_helper.AZURE_SEARCH_TOP_K,
|
185
186
|
)
|
186
187
|
|
187
|
-
@logger.trace_function(log_args=False, log_result=False)
|
188
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
188
189
|
def _convert_to_source_documents(self, search_results) -> List[SourceDocument]:
|
189
190
|
source_documents = []
|
190
191
|
for source in search_results:
|
@@ -7,6 +7,7 @@ import json
|
|
7
7
|
from ...utilities.helpers.env_helper import EnvHelper
|
8
8
|
from logging_config import logger
|
9
9
|
env_helper: EnvHelper = EnvHelper()
|
10
|
+
log_execution = env_helper.LOG_EXECUTION
|
10
11
|
log_args = env_helper.LOG_ARGS
|
11
12
|
log_result = env_helper.LOG_RESULT
|
12
13
|
|
@@ -16,17 +17,17 @@ class AzureSearchHandlerLightRag(SearchHandlerBase):
|
|
16
17
|
super().__init__(env_helper)
|
17
18
|
self.light_rag_helper = LightRAGHelper(env_helper)
|
18
19
|
|
19
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
20
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
20
21
|
def create_search_client(self):
|
21
22
|
return self.light_rag_helper.get_search_client()
|
22
23
|
|
23
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
24
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
24
25
|
def perform_search(self, filename):
|
25
26
|
return self.light_rag_helper.search(
|
26
27
|
"*", select="title, content, metadata", filter=f"title eq '{filename}'"
|
27
28
|
)
|
28
29
|
|
29
|
-
@logger.trace_function(log_args=False, log_result=False)
|
30
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
30
31
|
def process_results(self, results):
|
31
32
|
logger.info("Processing search results")
|
32
33
|
if results is None:
|
@@ -39,11 +40,11 @@ class AzureSearchHandlerLightRag(SearchHandlerBase):
|
|
39
40
|
logger.info("Processed results")
|
40
41
|
return data
|
41
42
|
|
42
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
43
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
43
44
|
def get_files(self):
|
44
45
|
return self.light_rag_helper.get_files()
|
45
46
|
|
46
|
-
@logger.trace_function(log_args=False, log_result=False)
|
47
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
47
48
|
def output_results(self, results):
|
48
49
|
files = {}
|
49
50
|
for result in results:
|
@@ -56,7 +57,7 @@ class AzureSearchHandlerLightRag(SearchHandlerBase):
|
|
56
57
|
|
57
58
|
return files
|
58
59
|
|
59
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
60
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
60
61
|
def delete_files(self, files):
|
61
62
|
ids_to_delete = []
|
62
63
|
files_to_delete = []
|
@@ -68,18 +69,18 @@ class AzureSearchHandlerLightRag(SearchHandlerBase):
|
|
68
69
|
|
69
70
|
return ", ".join(files_to_delete)
|
70
71
|
|
71
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
72
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
72
73
|
def search_by_blob_url(self, blob_url):
|
73
74
|
return self.light_rag_helper.search_by_blob_url(blob_url)
|
74
75
|
|
75
|
-
@logger.trace_function(log_args=False, log_result=False)
|
76
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
76
77
|
def query_search(self, question) -> List[SourceDocument]:
|
77
78
|
logger.info(f"Performing query search for question: {question}")
|
78
79
|
results = self.light_rag_helper.query_search(question)
|
79
80
|
logger.info("Converting search results to SourceDocument list")
|
80
81
|
return self._convert_to_source_documents(results)
|
81
82
|
|
82
|
-
@logger.trace_function(log_args=False, log_result=False)
|
83
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
83
84
|
def _convert_to_source_documents(self, search_results) -> List[SourceDocument]:
|
84
85
|
source_documents = []
|
85
86
|
for source in search_results:
|
@@ -10,13 +10,14 @@ import re
|
|
10
10
|
from ...utilities.helpers.env_helper import EnvHelper
|
11
11
|
from logging_config import logger
|
12
12
|
env_helper: EnvHelper = EnvHelper()
|
13
|
+
log_execution = env_helper.LOG_EXECUTION
|
13
14
|
log_args = env_helper.LOG_ARGS
|
14
15
|
log_result = env_helper.LOG_RESULT
|
15
16
|
|
16
17
|
class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
17
18
|
def __init__(self):
|
18
19
|
self.azure_identity_helper = AzureIdentityHelper()
|
19
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
20
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
20
21
|
def create_search_client(self):
|
21
22
|
logger.info("Creating Azure Search Client.")
|
22
23
|
if self._check_index_exists():
|
@@ -31,7 +32,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
31
32
|
),
|
32
33
|
)
|
33
34
|
|
34
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
35
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
35
36
|
def perform_search(self, filename):
|
36
37
|
logger.info(f"Performing search for file: {filename}.")
|
37
38
|
if self._check_index_exists():
|
@@ -41,7 +42,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
41
42
|
filter=f"title eq '{filename}'",
|
42
43
|
)
|
43
44
|
|
44
|
-
@logger.trace_function(log_args=False, log_result=False)
|
45
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
45
46
|
def process_results(self, results):
|
46
47
|
logger.info("Processing search results.")
|
47
48
|
if results is None:
|
@@ -54,7 +55,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
54
55
|
logger.info(f"Processed {len(data)} results.")
|
55
56
|
return data
|
56
57
|
|
57
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
58
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
58
59
|
def get_files(self):
|
59
60
|
logger.info("Fetching files from search index.")
|
60
61
|
if self._check_index_exists():
|
@@ -62,7 +63,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
62
63
|
"*", select="id, chunk_id, title", include_total_count=True
|
63
64
|
)
|
64
65
|
|
65
|
-
@logger.trace_function(log_args=False, log_result=False)
|
66
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
66
67
|
def output_results(self, results):
|
67
68
|
logger.info("Organizing search results into output format.")
|
68
69
|
files = {}
|
@@ -75,7 +76,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
75
76
|
files[filename] = [id]
|
76
77
|
return files
|
77
78
|
|
78
|
-
@logger.trace_function(log_args=log_args, log_result=False)
|
79
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=False)
|
79
80
|
def search_by_blob_url(self, blob_url: str):
|
80
81
|
logger.info(f"Searching by blob URL: {blob_url}.")
|
81
82
|
if self._check_index_exists():
|
@@ -87,7 +88,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
87
88
|
filter=f"title eq '{title}'",
|
88
89
|
)
|
89
90
|
|
90
|
-
@logger.trace_function(log_args=log_args, log_result=log_result)
|
91
|
+
@logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
|
91
92
|
def delete_files(self, files):
|
92
93
|
logger.info("Deleting files.")
|
93
94
|
ids_to_delete = []
|
@@ -102,7 +103,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
102
103
|
logger.info(f"Deleted files: {', '.join(files_to_delete)}.")
|
103
104
|
return ", ".join(files_to_delete)
|
104
105
|
|
105
|
-
@logger.trace_function(log_args=False, log_result=False)
|
106
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
106
107
|
def query_search(self, question) -> List[SourceDocument]:
|
107
108
|
logger.info(f"Querying search for question: {question}.")
|
108
109
|
if self._check_index_exists():
|
@@ -116,7 +117,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
116
117
|
logger.info("Search completed. Converting results to SourceDocuments.")
|
117
118
|
return self._convert_to_source_documents(search_results)
|
118
119
|
|
119
|
-
@logger.trace_function(log_args=False, log_result=False)
|
120
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
120
121
|
def _hybrid_search(self, question: str):
|
121
122
|
logger.info(f"Performing hybrid search for question: {question}.")
|
122
123
|
vector_query = VectorizableTextQuery(
|
@@ -131,7 +132,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
131
132
|
top=self.env_helper.AZURE_SEARCH_TOP_K,
|
132
133
|
)
|
133
134
|
|
134
|
-
@logger.trace_function(log_args=False, log_result=False)
|
135
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
135
136
|
def _semantic_search(self, question: str):
|
136
137
|
logger.info(f"Performing semantic search for question: {question}.")
|
137
138
|
vector_query = VectorizableTextQuery(
|
@@ -150,7 +151,7 @@ class IntegratedVectorizationSearchHandler(SearchHandlerBase):
|
|
150
151
|
query_answer="extractive",
|
151
152
|
top=self.env_helper.AZURE_SEARCH_TOP_K,
|
152
153
|
)
|
153
|
-
@logger.trace_function(log_args=False, log_result=False)
|
154
|
+
@logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
|
154
155
|
def _convert_to_source_documents(self, search_results) -> List[SourceDocument]:
|
155
156
|
logger.info("Converting search results to SourceDocument objects.")
|
156
157
|
source_documents = []
|