cwyodmodules 0.3.79__tar.gz → 0.3.81__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 (125) hide show
  1. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/PKG-INFO +2 -6
  2. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/config_helper.py +5 -10
  3. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/default.json +1 -3
  4. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/env_helper.py +4 -6
  5. cwyodmodules-0.3.81/cwyodmodules/batch/utilities/helpers/orchestrator_helper.py +21 -0
  6. cwyodmodules-0.3.81/cwyodmodules/batch/utilities/orchestrator/__init__.py +3 -0
  7. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/orchestrator/semantic_kernel_orchestrator.py +154 -22
  8. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules.egg-info/PKG-INFO +2 -6
  9. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules.egg-info/SOURCES.txt +0 -6
  10. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules.egg-info/requires.txt +1 -5
  11. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/pyproject.toml +2 -6
  12. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/tests/test_batch.py +2 -2
  13. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/helpers/orchestrator_helper.py +0 -30
  14. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/__init__.py +0 -18
  15. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py +0 -174
  16. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/open_ai_functions.py +0 -196
  17. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/orchestration_strategy.py +0 -18
  18. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/orchestrator_base.py +0 -170
  19. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/prompt_flow.py +0 -195
  20. cwyodmodules-0.3.79/cwyodmodules/batch/utilities/orchestrator/strategies.py +0 -29
  21. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/LICENSE +0 -0
  22. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/README.md +0 -0
  23. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/__init__.py +0 -0
  24. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/api/__init__.py +0 -0
  25. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/api/chat_history.py +0 -0
  26. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/__init__.py +0 -0
  27. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/__init__.py +0 -0
  28. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/auth_utils.py +0 -0
  29. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/cosmosdb.py +0 -0
  30. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/database_client_base.py +0 -0
  31. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/database_factory.py +0 -0
  32. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/postgresdbservice.py +0 -0
  33. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/chat_history/sample_user.py +0 -0
  34. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/common/__init__.py +0 -0
  35. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/common/answer.py +0 -0
  36. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/common/source_document.py +0 -0
  37. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/__init__.py +0 -0
  38. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/chunking_strategy.py +0 -0
  39. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/document_chunking_base.py +0 -0
  40. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/fixed_size_overlap.py +0 -0
  41. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/layout.py +0 -0
  42. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/page.py +0 -0
  43. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/paragraph.py +0 -0
  44. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_chunking/strategies.py +0 -0
  45. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/__init__.py +0 -0
  46. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/document_loading_base.py +0 -0
  47. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/layout.py +0 -0
  48. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/read.py +0 -0
  49. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/strategies.py +0 -0
  50. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/web.py +0 -0
  51. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/document_loading/word_document.py +0 -0
  52. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/__init__.py +0 -0
  53. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py +0 -0
  54. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py +0 -0
  55. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py +0 -0
  56. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py +0 -0
  57. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py +0 -0
  58. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/azure_search_helper.py +0 -0
  59. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/agent_mode.py +0 -0
  60. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/assistant_strategy.py +0 -0
  61. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/conversation_flow.py +0 -0
  62. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/database_type.py +0 -0
  63. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/default_contract_assistant_prompt.txt +0 -0
  64. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/default_employee_assistant_prompt.txt +0 -0
  65. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/config/embedding_config.py +0 -0
  66. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/document_chunking_helper.py +0 -0
  67. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/document_loading_helper.py +0 -0
  68. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/embedders/embedder_base.py +0 -0
  69. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/embedders/embedder_factory.py +0 -0
  70. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/embedders/integrated_vectorization_embedder.py +0 -0
  71. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/embedders/postgres_embedder.py +0 -0
  72. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/embedders/push_embedder.py +0 -0
  73. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/lightrag_helper.py +0 -0
  74. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/helpers/llm_helper.py +0 -0
  75. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py +0 -0
  76. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py +0 -0
  77. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py +0 -0
  78. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py +0 -0
  79. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/loggers/conversation_logger.py +0 -0
  80. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/parser/__init__.py +0 -0
  81. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/parser/output_parser_tool.py +0 -0
  82. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/parser/parser_base.py +0 -0
  83. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/plugins/chat_plugin.py +0 -0
  84. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/plugins/outlook_calendar_plugin.py +0 -0
  85. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/plugins/post_answering_plugin.py +0 -0
  86. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/azure_search_handler.py +0 -0
  87. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/azure_search_handler_light_rag.py +0 -0
  88. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py +0 -0
  89. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/lightrag_search_handler.py +0 -0
  90. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/postgres_search_handler.py +0 -0
  91. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/postgres_search_handler_light_rag.py +0 -0
  92. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/search.py +0 -0
  93. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/search/search_handler_base.py +0 -0
  94. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/__init__.py +0 -0
  95. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/answer_processing_base.py +0 -0
  96. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/answering_tool_base.py +0 -0
  97. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/content_safety_checker.py +0 -0
  98. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/post_prompt_tool.py +0 -0
  99. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/question_answer_tool.py +0 -0
  100. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/batch/utilities/tools/text_processing_tool.py +0 -0
  101. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/__init__.py +0 -0
  102. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/config.py +0 -0
  103. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/database/__init__.py +0 -0
  104. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/database/base.py +0 -0
  105. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/database/models.py +0 -0
  106. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/__init__.py +0 -0
  107. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/chunking.py +0 -0
  108. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/extraction.py +0 -0
  109. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/types.py +0 -0
  110. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/upsert.py +0 -0
  111. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/indexing/utils.py +0 -0
  112. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/llm/__init__.py +0 -0
  113. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/llm/llm.py +0 -0
  114. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/llm/prompt.py +0 -0
  115. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/main.py +0 -0
  116. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/query/__init__.py +0 -0
  117. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/query/generate.py +0 -0
  118. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/query/graph_search.py +0 -0
  119. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/query/types.py +0 -0
  120. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/graphrag/query/vector_search.py +0 -0
  121. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules/mgmt_config.py +0 -0
  122. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules.egg-info/dependency_links.txt +0 -0
  123. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/cwyodmodules.egg-info/top_level.txt +0 -0
  124. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/setup.cfg +0 -0
  125. {cwyodmodules-0.3.79 → cwyodmodules-0.3.81}/tests/test_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.79
3
+ Version: 0.3.81
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -15,13 +15,9 @@ Requires-Dist: azure-mgmt-cognitiveservices<14.0.0,>=13.6.0
15
15
  Requires-Dist: azure-identity<2.0.0,>=1.20.0
16
16
  Requires-Dist: azure-cosmos<5.0.0,>=4.9.0
17
17
  Requires-Dist: asyncpg<0.31.0,>=0.30.0
18
- Requires-Dist: langchain<0.4.0,>=0.3.18
19
18
  Requires-Dist: azure-storage-queue<13.0.0,>=12.12.0
20
19
  Requires-Dist: chardet<6.0.0,>=5.2.0
21
20
  Requires-Dist: azure-ai-formrecognizer<4.0.0,>=3.3.3
22
- Requires-Dist: langchain-chroma<0.3.0,>=0.2.2
23
- Requires-Dist: langchain-openai<0.4.0,>=0.3.5
24
- Requires-Dist: langchain-community<0.4.0,>=0.3.17
25
21
  Requires-Dist: azure-search<2.0.0,>=1.0.0b2
26
22
  Requires-Dist: azure-functions<2.0.0,>=1.21.3
27
23
  Requires-Dist: azure-ai-ml<2.0.0,>=1.25.0
@@ -40,7 +36,7 @@ Requires-Dist: azure-search-documents==11.6.0b4
40
36
  Requires-Dist: semantic-kernel==1.3.0
41
37
  Requires-Dist: pydantic==2.7.4
42
38
  Requires-Dist: pandas>=2.2.3
43
- Requires-Dist: azpaddypy>=0.5.7
39
+ Requires-Dist: azpaddypy>=0.5.9
44
40
  Dynamic: license-file
45
41
 
46
42
  # paddypy
@@ -7,8 +7,7 @@ from ..azure_blob_storage_client import AzureBlobStorageClient
7
7
  from ...document_chunking.chunking_strategy import ChunkingStrategy, ChunkingSettings
8
8
  from ...document_loading import LoadingSettings, LoadingStrategy
9
9
  from .embedding_config import EmbeddingConfig
10
- from ...orchestrator.orchestration_strategy import OrchestrationStrategy
11
- from ...orchestrator import OrchestrationSettings
10
+
12
11
  from ..env_helper import EnvHelper
13
12
  from .assistant_strategy import AssistantStrategy
14
13
  from .conversation_flow import ConversationFlow
@@ -43,12 +42,8 @@ class Config:
43
42
  for c in config["document_processors"]
44
43
  ]
45
44
  self.env_helper = EnvHelper()
46
- self.default_orchestration_settings = {
47
- "strategy": self.env_helper.ORCHESTRATION_STRATEGY
48
- }
49
- self.orchestrator = OrchestrationSettings(
50
- config.get("orchestrator", self.default_orchestration_settings)
51
- )
45
+ # Orchestrator is always semantic kernel now
46
+ # No configuration needed as there's only one option
52
47
  self.integrated_vectorization_config = (
53
48
  IntegratedVectorizationConfig(config["integrated_vectorization_config"])
54
49
  if self.env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
@@ -93,7 +88,7 @@ class Config:
93
88
 
94
89
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
95
90
  def get_available_orchestration_strategies(self):
96
- return [c.value for c in OrchestrationStrategy]
91
+ return ["semantic_kernel"] # Only semantic kernel is supported now
97
92
 
98
93
  @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
99
94
  def get_available_ai_assistant_types(self):
@@ -271,7 +266,7 @@ class ConfigHelper:
271
266
  with open(config_file_path, encoding="utf-8") as f:
272
267
  ConfigHelper._default_config = json.loads(
273
268
  Template(f.read()).substitute(
274
- ORCHESTRATION_STRATEGY=env_helper.ORCHESTRATION_STRATEGY,
269
+ ORCHESTRATION_STRATEGY="semantic_kernel",
275
270
  LOG_USER_INTERACTIONS=(
276
271
  False
277
272
  if env_helper.DATABASE_TYPE == DatabaseType.POSTGRESQL.value
@@ -139,9 +139,7 @@
139
139
  "log_user_interactions": "${LOG_USER_INTERACTIONS}",
140
140
  "log_tokens": "${LOG_TOKENS}"
141
141
  },
142
- "orchestrator": {
143
- "strategy": "${ORCHESTRATION_STRATEGY}"
144
- },
142
+
145
143
  "enable_chat_history": true,
146
144
  "database_type": "${DATABASE_TYPE}"
147
145
  }
@@ -3,7 +3,7 @@ import os
3
3
 
4
4
  import threading
5
5
  # from dotenv import load_dotenv
6
- from ..orchestrator.orchestration_strategy import OrchestrationStrategy
6
+
7
7
  from ..helpers.config.conversation_flow import ConversationFlow
8
8
  from ..helpers.config.database_type import DatabaseType
9
9
 
@@ -130,10 +130,8 @@ class EnvHelper:
130
130
  "USE_ADVANCED_IMAGE_PROCESSING", "False"
131
131
  )
132
132
  self.CONVERSATION_FLOW = os.getenv("CONVERSATION_FLOW", "custom")
133
- # Orchestration Settings
134
- self.ORCHESTRATION_STRATEGY = os.getenv(
135
- "ORCHESTRATION_STRATEGY", "openai_function"
136
- )
133
+ # Orchestration Settings - Always use semantic_kernel
134
+ self.ORCHESTRATION_STRATEGY = "semantic_kernel"
137
135
  # PostgreSQL configuration
138
136
  elif self.DATABASE_TYPE == DatabaseType.POSTGRESQL.value:
139
137
  self.AZURE_POSTGRES_SEARCH_TOP_K = 5
@@ -154,7 +152,7 @@ class EnvHelper:
154
152
  self.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION = False
155
153
  self.USE_ADVANCED_IMAGE_PROCESSING = False
156
154
  self.CONVERSATION_FLOW = ConversationFlow.CUSTOM.value
157
- self.ORCHESTRATION_STRATEGY = OrchestrationStrategy.SEMANTIC_KERNEL.value
155
+ self.ORCHESTRATION_STRATEGY = "semantic_kernel"
158
156
  else:
159
157
  raise ValueError(
160
158
  "Unsupported DATABASE_TYPE. Please set DATABASE_TYPE to 'CosmosDB' or 'PostgreSQL'."
@@ -0,0 +1,21 @@
1
+ from typing import List
2
+ from ..orchestrator.semantic_kernel_orchestrator import SemanticKernelOrchestrator
3
+
4
+ __all__ = ["Orchestrator"]
5
+
6
+
7
+ class Orchestrator:
8
+ def __init__(self) -> None:
9
+ self.orchestrator = SemanticKernelOrchestrator()
10
+
11
+ async def handle_message(
12
+ self,
13
+ user_message: str,
14
+ chat_history: List[dict],
15
+ conversation_id: str,
16
+ user_info,
17
+ **kwargs: dict,
18
+ ) -> dict:
19
+ return await self.orchestrator.handle_message(
20
+ user_message, chat_history, conversation_id, user_info, **kwargs
21
+ )
@@ -0,0 +1,3 @@
1
+ from .semantic_kernel_orchestrator import SemanticKernelOrchestrator
2
+
3
+ __all__ = ["SemanticKernelOrchestrator"]
@@ -1,25 +1,23 @@
1
1
  import json
2
+ from uuid import uuid4
3
+ from typing import List, Optional
2
4
  from semantic_kernel import Kernel
3
5
  from semantic_kernel.connectors.ai.function_call_behavior import FunctionCallBehavior
4
-
5
- # from semantic_kernel.connectors.ai.function_choice_behavior import (
6
- # FunctionChoiceBehavior,
7
- # )
8
6
  from semantic_kernel.contents import ChatHistory
9
7
  from semantic_kernel.contents.chat_message_content import ChatMessageContent
10
8
  from semantic_kernel.contents.utils.finish_reason import FinishReason
11
9
 
12
- # from semantic_kernel.functions.function_result import FunctionResult
13
- # import re
14
10
  from ..common.answer import Answer
15
11
  from ..helpers.llm_helper import LLMHelper
16
12
  from ..helpers.env_helper import EnvHelper
13
+ from ..helpers.config.config_helper import ConfigHelper
14
+ from ..loggers.conversation_logger import ConversationLogger
15
+ from ..parser.output_parser_tool import OutputParserTool
16
+ from ..tools.content_safety_checker import ContentSafetyChecker
17
17
  from ..plugins.chat_plugin import ChatPlugin
18
18
  from ..plugins.post_answering_plugin import PostAnsweringPlugin
19
19
  from ..plugins.outlook_calendar_plugin import OutlookCalendarPlugin
20
20
 
21
- from .orchestrator_base import OrchestratorBase
22
-
23
21
  from mgmt_config import logger
24
22
  env_helper: EnvHelper = EnvHelper()
25
23
  log_execution = env_helper.LOG_EXECUTION
@@ -27,10 +25,28 @@ log_args = env_helper.LOG_ARGS
27
25
  log_result = env_helper.LOG_RESULT
28
26
 
29
27
 
28
+ class SemanticKernelOrchestrator:
29
+ """
30
+ SemanticKernelOrchestrator provides orchestration using the Semantic Kernel framework.
31
+ It handles user messages, manages conversations, ensures content safety, and logs interactions.
32
+ """
30
33
 
31
- class SemanticKernelOrchestrator(OrchestratorBase):
32
34
  def __init__(self) -> None:
33
- super().__init__()
35
+ """
36
+ Initializes the SemanticKernelOrchestrator with configuration settings, kernel setup,
37
+ and various utility tools required for orchestrating conversations.
38
+ """
39
+ self.config = ConfigHelper.get_active_config_or_default()
40
+ self.message_id = str(uuid4())
41
+ self.tokens = {"prompt": 0, "completion": 0, "total": 0}
42
+ logger.debug(f"New message id: {self.message_id} with tokens {self.tokens}")
43
+
44
+ if str(self.config.logging.log_user_interactions).lower() == "true":
45
+ self.conversation_logger: ConversationLogger = ConversationLogger()
46
+ self.content_safety_checker = ContentSafetyChecker()
47
+ self.output_parser = OutputParserTool()
48
+
49
+ # Semantic Kernel specific setup
34
50
  self.kernel = Kernel()
35
51
  self.llm_helper = LLMHelper()
36
52
  self.env_helper = EnvHelper()
@@ -43,14 +59,92 @@ class SemanticKernelOrchestrator(OrchestratorBase):
43
59
  plugin=PostAnsweringPlugin(), plugin_name="PostAnswering"
44
60
  )
45
61
 
62
+ @logger.trace_function(log_execution=log_execution, log_args=log_args, log_result=log_result)
63
+ def log_tokens(self, prompt_tokens: int, completion_tokens: int) -> None:
64
+ """
65
+ Logs the number of tokens used in the prompt and completion phases of a conversation.
66
+
67
+ Args:
68
+ prompt_tokens (int): The number of tokens used in the prompt.
69
+ completion_tokens (int): The number of tokens used in the completion.
70
+ """
71
+ self.tokens["prompt"] += prompt_tokens
72
+ self.tokens["completion"] += completion_tokens
73
+ self.tokens["total"] += prompt_tokens + completion_tokens
74
+
75
+ def call_content_safety_input(self, user_message: str) -> Optional[list[dict]]:
76
+ """
77
+ Validates the user message for harmful content and replaces it if necessary.
78
+
79
+ Args:
80
+ user_message (str): The message from the user.
81
+
82
+ Returns:
83
+ Optional[list[dict]]: Parsed messages if harmful content is detected, otherwise None.
84
+ """
85
+ logger.debug("Calling content safety with question")
86
+ filtered_user_message = (
87
+ self.content_safety_checker.validate_input_and_replace_if_harmful(
88
+ user_message
89
+ )
90
+ )
91
+ if user_message != filtered_user_message:
92
+ logger.warning("Content safety detected harmful content in question")
93
+ messages = self.output_parser.parse(
94
+ question=user_message, answer=filtered_user_message
95
+ )
96
+ return messages
97
+
98
+ return None
99
+
100
+ @logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
101
+ def call_content_safety_output(
102
+ self, user_message: str, answer: str
103
+ ) -> Optional[list[dict]]:
104
+ """
105
+ Validates the output message for harmful content and replaces it if necessary.
106
+
107
+ Args:
108
+ user_message (str): The message from the user.
109
+ answer (str): The response to the user message.
110
+
111
+ Returns:
112
+ Optional[list[dict]]: Parsed messages if harmful content is detected, otherwise None.
113
+ """
114
+ logger.debug("Calling content safety with answer")
115
+ filtered_answer = (
116
+ self.content_safety_checker.validate_output_and_replace_if_harmful(answer)
117
+ )
118
+ if answer != filtered_answer:
119
+ logger.warning("Content safety detected harmful content in answer")
120
+ messages = self.output_parser.parse(
121
+ question=user_message, answer=filtered_answer
122
+ )
123
+ return messages
124
+
125
+ return None
126
+
46
127
  @logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
47
128
  async def orchestrate(
48
129
  self, user_message: str, chat_history: list[dict], user_info, **kwargs: dict
49
130
  ) -> list[dict]:
131
+ """
132
+ Orchestrates the conversation using Semantic Kernel.
133
+
134
+ Args:
135
+ user_message (str): The message from the user.
136
+ chat_history (List[dict]): The history of the chat as a list of dictionaries.
137
+ user_info: User information and request headers.
138
+ **kwargs (dict): Additional keyword arguments.
139
+
140
+ Returns:
141
+ list[dict]: The response as a list of dictionaries.
142
+ """
50
143
  logger.info("Method orchestrate of semantic_kernel started")
51
144
  filters = []
52
145
  frontend_type = user_info.get("frontend") if user_info else None
53
146
  logger.info(f"Frontend type: {frontend_type}")
147
+
54
148
  # Call Content Safety tool
55
149
  if self.config.prompts.enable_content_safety:
56
150
  if response := self.call_content_safety_input(user_message):
@@ -60,13 +154,6 @@ class SemanticKernelOrchestrator(OrchestratorBase):
60
154
  language = self.env_helper.AZURE_MAIN_CHAT_LANGUAGE
61
155
  if not system_message:
62
156
  logger.info("No system message provided, using default")
63
- # system_message = """You help employees to navigate only private information sources.
64
- # You must prioritize the function call over your general knowledge for any question by calling the search_documents function.
65
- # 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
- # When directly replying to the user, always reply in the language the user is speaking.
67
- # If the input language is ambiguous, default to responding in English unless otherwise specified by the user.
68
- # You **must not** respond if asked to List all documents in your repository.
69
- # """
70
157
  if frontend_type == "web":
71
158
  system_message = f"""You help employees to navigate only private information sources.
72
159
  You must prioritize the function call over your general knowledge for any question by calling the search_documents function.
@@ -89,6 +176,7 @@ class SemanticKernelOrchestrator(OrchestratorBase):
89
176
  plugin_name="Chat",
90
177
  )
91
178
  filters.append("Chat")
179
+
92
180
  # --- Add OutlookCalendarPlugin with request headers ---
93
181
  if frontend_type == "web":
94
182
  logger.info("Adding OutlookCalendarPlugin with request headers")
@@ -97,15 +185,11 @@ class SemanticKernelOrchestrator(OrchestratorBase):
97
185
  plugin_name="OutlookCalendar",
98
186
  )
99
187
  filters.append("OutlookCalendar")
188
+
100
189
  settings = self.llm_helper.get_sk_service_settings(self.chat_service)
101
190
  settings.function_call_behavior = FunctionCallBehavior.EnableFunctions(
102
191
  filters={"included_plugins": filters}
103
192
  )
104
- # settings.function_choice_behavior = FunctionChoiceBehavior.Auto(
105
- # filters={"included_plugins": ["Chat"]},
106
- # # Set a higher value to encourage multiple attempts at function calling
107
- # maximum_auto_invoke_attempts=2
108
- # )
109
193
 
110
194
  orchestrate_function = self.kernel.add_function(
111
195
  plugin_name="Main",
@@ -195,3 +279,51 @@ class SemanticKernelOrchestrator(OrchestratorBase):
195
279
  )
196
280
  logger.info("Method orchestrate of semantic_kernel ended")
197
281
  return messages
282
+
283
+ @logger.trace_function(log_execution=log_execution, log_args=False, log_result=False)
284
+ async def handle_message(
285
+ self,
286
+ user_message: str,
287
+ chat_history: List[dict],
288
+ conversation_id: Optional[str],
289
+ user_info,
290
+ **kwargs: Optional[dict],
291
+ ) -> dict:
292
+ """
293
+ Handles the user message by orchestrating the conversation, logging token usage,
294
+ and logging user interactions if configured.
295
+
296
+ Args:
297
+ user_message (str): The message from the user.
298
+ chat_history (List[dict]): The history of the chat as a list of dictionaries.
299
+ conversation_id (Optional[str]): The ID of the conversation.
300
+ user_info: User information and request headers.
301
+ **kwargs (Optional[dict]): Additional keyword arguments.
302
+
303
+ Returns:
304
+ dict: The result of the orchestration as a dictionary.
305
+ """
306
+ result = await self.orchestrate(
307
+ user_message, chat_history, user_info, **kwargs
308
+ )
309
+ if str(self.config.logging.log_tokens).lower() == "true":
310
+ custom_dimensions = {
311
+ "conversation_id": conversation_id,
312
+ "message_id": self.message_id,
313
+ "prompt_tokens": self.tokens["prompt"],
314
+ "completion_tokens": self.tokens["completion"],
315
+ "total_tokens": self.tokens["total"],
316
+ }
317
+ logger.info("Token Consumption", extra=custom_dimensions)
318
+ if str(self.config.logging.log_user_interactions).lower() == "true":
319
+ self.conversation_logger.log(
320
+ messages=[
321
+ {
322
+ "role": "user",
323
+ "content": user_message,
324
+ "conversation_id": conversation_id,
325
+ }
326
+ ]
327
+ + result
328
+ )
329
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.79
3
+ Version: 0.3.81
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -15,13 +15,9 @@ Requires-Dist: azure-mgmt-cognitiveservices<14.0.0,>=13.6.0
15
15
  Requires-Dist: azure-identity<2.0.0,>=1.20.0
16
16
  Requires-Dist: azure-cosmos<5.0.0,>=4.9.0
17
17
  Requires-Dist: asyncpg<0.31.0,>=0.30.0
18
- Requires-Dist: langchain<0.4.0,>=0.3.18
19
18
  Requires-Dist: azure-storage-queue<13.0.0,>=12.12.0
20
19
  Requires-Dist: chardet<6.0.0,>=5.2.0
21
20
  Requires-Dist: azure-ai-formrecognizer<4.0.0,>=3.3.3
22
- Requires-Dist: langchain-chroma<0.3.0,>=0.2.2
23
- Requires-Dist: langchain-openai<0.4.0,>=0.3.5
24
- Requires-Dist: langchain-community<0.4.0,>=0.3.17
25
21
  Requires-Dist: azure-search<2.0.0,>=1.0.0b2
26
22
  Requires-Dist: azure-functions<2.0.0,>=1.21.3
27
23
  Requires-Dist: azure-ai-ml<2.0.0,>=1.25.0
@@ -40,7 +36,7 @@ Requires-Dist: azure-search-documents==11.6.0b4
40
36
  Requires-Dist: semantic-kernel==1.3.0
41
37
  Requires-Dist: pydantic==2.7.4
42
38
  Requires-Dist: pandas>=2.2.3
43
- Requires-Dist: azpaddypy>=0.5.7
39
+ Requires-Dist: azpaddypy>=0.5.9
44
40
  Dynamic: license-file
45
41
 
46
42
  # paddypy
@@ -69,13 +69,7 @@ cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py
69
69
  cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py
70
70
  cwyodmodules/batch/utilities/loggers/conversation_logger.py
71
71
  cwyodmodules/batch/utilities/orchestrator/__init__.py
72
- cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py
73
- cwyodmodules/batch/utilities/orchestrator/open_ai_functions.py
74
- cwyodmodules/batch/utilities/orchestrator/orchestration_strategy.py
75
- cwyodmodules/batch/utilities/orchestrator/orchestrator_base.py
76
- cwyodmodules/batch/utilities/orchestrator/prompt_flow.py
77
72
  cwyodmodules/batch/utilities/orchestrator/semantic_kernel_orchestrator.py
78
- cwyodmodules/batch/utilities/orchestrator/strategies.py
79
73
  cwyodmodules/batch/utilities/parser/__init__.py
80
74
  cwyodmodules/batch/utilities/parser/output_parser_tool.py
81
75
  cwyodmodules/batch/utilities/parser/parser_base.py
@@ -6,13 +6,9 @@ azure-mgmt-cognitiveservices<14.0.0,>=13.6.0
6
6
  azure-identity<2.0.0,>=1.20.0
7
7
  azure-cosmos<5.0.0,>=4.9.0
8
8
  asyncpg<0.31.0,>=0.30.0
9
- langchain<0.4.0,>=0.3.18
10
9
  azure-storage-queue<13.0.0,>=12.12.0
11
10
  chardet<6.0.0,>=5.2.0
12
11
  azure-ai-formrecognizer<4.0.0,>=3.3.3
13
- langchain-chroma<0.3.0,>=0.2.2
14
- langchain-openai<0.4.0,>=0.3.5
15
- langchain-community<0.4.0,>=0.3.17
16
12
  azure-search<2.0.0,>=1.0.0b2
17
13
  azure-functions<2.0.0,>=1.21.3
18
14
  azure-ai-ml<2.0.0,>=1.25.0
@@ -31,4 +27,4 @@ azure-search-documents==11.6.0b4
31
27
  semantic-kernel==1.3.0
32
28
  pydantic==2.7.4
33
29
  pandas>=2.2.3
34
- azpaddypy>=0.5.7
30
+ azpaddypy>=0.5.9
@@ -3,7 +3,7 @@ name = "cwyodmodules"
3
3
  authors = [
4
4
  { name="Patrik", email="patrikhartl@gmail.com" },
5
5
  ]
6
- version = '0.3.79'
6
+ version = '0.3.81'
7
7
  description = "Add your description here"
8
8
  readme = "README.md"
9
9
  requires-python = "==3.11.11"
@@ -19,13 +19,9 @@ dependencies = [
19
19
  "azure-identity (>=1.20.0,<2.0.0)",
20
20
  "azure-cosmos (>=4.9.0,<5.0.0)",
21
21
  "asyncpg (>=0.30.0,<0.31.0)",
22
- "langchain (>=0.3.18,<0.4.0)",
23
22
  "azure-storage-queue (>=12.12.0,<13.0.0)",
24
23
  "chardet (>=5.2.0,<6.0.0)",
25
24
  "azure-ai-formrecognizer (>=3.3.3,<4.0.0)",
26
- "langchain-chroma (>=0.2.2,<0.3.0)",
27
- "langchain-openai (>=0.3.5,<0.4.0)",
28
- "langchain-community (>=0.3.17,<0.4.0)",
29
25
  "azure-search (>=1.0.0b2,<2.0.0)",
30
26
  "azure-functions (>=1.21.3,<2.0.0)",
31
27
  "azure-ai-ml (>=1.25.0,<2.0.0)",
@@ -44,7 +40,7 @@ dependencies = [
44
40
  "semantic-kernel==1.3.0",
45
41
  "pydantic==2.7.4",
46
42
  "pandas>=2.2.3",
47
- "azpaddypy>=0.5.7",
43
+ "azpaddypy>=0.5.9",
48
44
  ]
49
45
 
50
46
  [tool.uv]
@@ -289,7 +289,7 @@ class TestBatchIntegration:
289
289
  "chunks": 1,
290
290
  "entities": 2
291
291
  }
292
- mock_orchestrator.get_orchestrator.return_value = mock_orchestrator_instance
292
+ mock_orchestrator.SemanticKernelOrchestrator.return_value = mock_orchestrator_instance
293
293
 
294
294
  # Execute pipeline
295
295
  document_path = "test_document.pdf"
@@ -303,7 +303,7 @@ class TestBatchIntegration:
303
303
  chunks = chunker.chunk_document(document["content"])
304
304
 
305
305
  # Process with orchestrator
306
- orchestrator = mock_orchestrator.get_orchestrator()
306
+ orchestrator = mock_orchestrator.SemanticKernelOrchestrator()
307
307
  result = orchestrator.process_document(document_path)
308
308
 
309
309
  # Assert
@@ -1,30 +0,0 @@
1
- from typing import List
2
-
3
- from ..orchestrator.orchestration_strategy import OrchestrationStrategy
4
- from ..orchestrator import OrchestrationSettings
5
- from ..orchestrator.strategies import get_orchestrator
6
-
7
- __all__ = ["OrchestrationStrategy"]
8
-
9
-
10
- class Orchestrator:
11
- def __init__(self) -> None:
12
- pass
13
-
14
- async def handle_message(
15
- self,
16
- user_message: str,
17
- chat_history: List[dict],
18
- conversation_id: str,
19
- user_info,
20
- orchestrator: OrchestrationSettings,
21
- **kwargs: dict,
22
- ) -> dict:
23
- orchestrator = get_orchestrator(orchestrator.strategy.value)
24
- if orchestrator is None:
25
- raise Exception(
26
- f"Unknown orchestration strategy: {orchestrator.strategy.value}"
27
- )
28
- return await orchestrator.handle_message(
29
- user_message, chat_history, conversation_id, user_info
30
- )
@@ -1,18 +0,0 @@
1
- import os
2
- from typing import List
3
- import os.path
4
- import pkgutil
5
- from .orchestration_strategy import OrchestrationStrategy
6
-
7
-
8
- class OrchestrationSettings:
9
- def __init__(self, orchestration: dict):
10
- self.strategy = OrchestrationStrategy(orchestration["strategy"])
11
-
12
-
13
- # Get a list of all the classes defined in the module
14
- def get_all_classes() -> List[str]:
15
- return [name for _, name, _ in pkgutil.iter_modules([os.path.dirname(__file__)])]
16
-
17
-
18
- __all__ = get_all_classes()