lfx-nightly 0.2.0.dev0__py3-none-any.whl → 0.2.0.dev26__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 (188) hide show
  1. lfx/_assets/component_index.json +1 -1
  2. lfx/base/agents/agent.py +13 -1
  3. lfx/base/agents/altk_base_agent.py +380 -0
  4. lfx/base/agents/altk_tool_wrappers.py +565 -0
  5. lfx/base/agents/events.py +2 -1
  6. lfx/base/composio/composio_base.py +159 -224
  7. lfx/base/data/base_file.py +88 -21
  8. lfx/base/data/storage_utils.py +192 -0
  9. lfx/base/data/utils.py +178 -14
  10. lfx/base/embeddings/embeddings_class.py +113 -0
  11. lfx/base/models/groq_constants.py +74 -58
  12. lfx/base/models/groq_model_discovery.py +265 -0
  13. lfx/base/models/model.py +1 -1
  14. lfx/base/models/model_utils.py +100 -0
  15. lfx/base/models/openai_constants.py +7 -0
  16. lfx/base/models/watsonx_constants.py +32 -8
  17. lfx/base/tools/run_flow.py +601 -129
  18. lfx/cli/commands.py +6 -3
  19. lfx/cli/common.py +2 -2
  20. lfx/cli/run.py +1 -1
  21. lfx/cli/script_loader.py +53 -11
  22. lfx/components/Notion/create_page.py +1 -1
  23. lfx/components/Notion/list_database_properties.py +1 -1
  24. lfx/components/Notion/list_pages.py +1 -1
  25. lfx/components/Notion/list_users.py +1 -1
  26. lfx/components/Notion/page_content_viewer.py +1 -1
  27. lfx/components/Notion/search.py +1 -1
  28. lfx/components/Notion/update_page_property.py +1 -1
  29. lfx/components/__init__.py +19 -5
  30. lfx/components/{agents → altk}/__init__.py +5 -9
  31. lfx/components/altk/altk_agent.py +193 -0
  32. lfx/components/apify/apify_actor.py +1 -1
  33. lfx/components/composio/__init__.py +70 -18
  34. lfx/components/composio/apollo_composio.py +11 -0
  35. lfx/components/composio/bitbucket_composio.py +11 -0
  36. lfx/components/composio/canva_composio.py +11 -0
  37. lfx/components/composio/coda_composio.py +11 -0
  38. lfx/components/composio/composio_api.py +10 -0
  39. lfx/components/composio/discord_composio.py +1 -1
  40. lfx/components/composio/elevenlabs_composio.py +11 -0
  41. lfx/components/composio/exa_composio.py +11 -0
  42. lfx/components/composio/firecrawl_composio.py +11 -0
  43. lfx/components/composio/fireflies_composio.py +11 -0
  44. lfx/components/composio/gmail_composio.py +1 -1
  45. lfx/components/composio/googlebigquery_composio.py +11 -0
  46. lfx/components/composio/googlecalendar_composio.py +1 -1
  47. lfx/components/composio/googledocs_composio.py +1 -1
  48. lfx/components/composio/googlemeet_composio.py +1 -1
  49. lfx/components/composio/googlesheets_composio.py +1 -1
  50. lfx/components/composio/googletasks_composio.py +1 -1
  51. lfx/components/composio/heygen_composio.py +11 -0
  52. lfx/components/composio/mem0_composio.py +11 -0
  53. lfx/components/composio/peopledatalabs_composio.py +11 -0
  54. lfx/components/composio/perplexityai_composio.py +11 -0
  55. lfx/components/composio/serpapi_composio.py +11 -0
  56. lfx/components/composio/slack_composio.py +3 -574
  57. lfx/components/composio/slackbot_composio.py +1 -1
  58. lfx/components/composio/snowflake_composio.py +11 -0
  59. lfx/components/composio/tavily_composio.py +11 -0
  60. lfx/components/composio/youtube_composio.py +2 -2
  61. lfx/components/cuga/__init__.py +34 -0
  62. lfx/components/cuga/cuga_agent.py +730 -0
  63. lfx/components/data/__init__.py +78 -28
  64. lfx/components/data_source/__init__.py +58 -0
  65. lfx/components/{data → data_source}/api_request.py +26 -3
  66. lfx/components/{data → data_source}/csv_to_data.py +15 -10
  67. lfx/components/{data → data_source}/json_to_data.py +15 -8
  68. lfx/components/{data → data_source}/news_search.py +1 -1
  69. lfx/components/{data → data_source}/rss.py +1 -1
  70. lfx/components/{data → data_source}/sql_executor.py +1 -1
  71. lfx/components/{data → data_source}/url.py +1 -1
  72. lfx/components/{data → data_source}/web_search.py +1 -1
  73. lfx/components/datastax/astradb_cql.py +1 -1
  74. lfx/components/datastax/astradb_graph.py +1 -1
  75. lfx/components/datastax/astradb_tool.py +1 -1
  76. lfx/components/datastax/astradb_vectorstore.py +1 -1
  77. lfx/components/datastax/hcd.py +1 -1
  78. lfx/components/deactivated/json_document_builder.py +1 -1
  79. lfx/components/docling/__init__.py +0 -3
  80. lfx/components/elastic/elasticsearch.py +1 -1
  81. lfx/components/elastic/opensearch_multimodal.py +1575 -0
  82. lfx/components/files_and_knowledge/__init__.py +47 -0
  83. lfx/components/{data → files_and_knowledge}/directory.py +1 -1
  84. lfx/components/{data → files_and_knowledge}/file.py +246 -18
  85. lfx/components/{knowledge_bases → files_and_knowledge}/retrieval.py +2 -2
  86. lfx/components/{data → files_and_knowledge}/save_file.py +142 -22
  87. lfx/components/flow_controls/__init__.py +58 -0
  88. lfx/components/{logic → flow_controls}/conditional_router.py +1 -1
  89. lfx/components/{logic → flow_controls}/loop.py +43 -9
  90. lfx/components/flow_controls/run_flow.py +108 -0
  91. lfx/components/glean/glean_search_api.py +1 -1
  92. lfx/components/groq/groq.py +35 -28
  93. lfx/components/helpers/__init__.py +102 -0
  94. lfx/components/input_output/__init__.py +3 -1
  95. lfx/components/input_output/chat.py +4 -3
  96. lfx/components/input_output/chat_output.py +4 -4
  97. lfx/components/input_output/text.py +1 -1
  98. lfx/components/input_output/text_output.py +1 -1
  99. lfx/components/{data → input_output}/webhook.py +1 -1
  100. lfx/components/knowledge_bases/__init__.py +59 -4
  101. lfx/components/langchain_utilities/character.py +1 -1
  102. lfx/components/langchain_utilities/csv_agent.py +84 -16
  103. lfx/components/langchain_utilities/json_agent.py +67 -12
  104. lfx/components/langchain_utilities/language_recursive.py +1 -1
  105. lfx/components/llm_operations/__init__.py +46 -0
  106. lfx/components/{processing → llm_operations}/batch_run.py +1 -1
  107. lfx/components/{processing → llm_operations}/lambda_filter.py +1 -1
  108. lfx/components/{logic → llm_operations}/llm_conditional_router.py +1 -1
  109. lfx/components/{processing/llm_router.py → llm_operations/llm_selector.py} +3 -3
  110. lfx/components/{processing → llm_operations}/structured_output.py +1 -1
  111. lfx/components/logic/__init__.py +126 -0
  112. lfx/components/mem0/mem0_chat_memory.py +11 -0
  113. lfx/components/models/__init__.py +64 -9
  114. lfx/components/models_and_agents/__init__.py +49 -0
  115. lfx/components/{agents → models_and_agents}/agent.py +2 -2
  116. lfx/components/models_and_agents/embedding_model.py +423 -0
  117. lfx/components/models_and_agents/language_model.py +398 -0
  118. lfx/components/{agents → models_and_agents}/mcp_component.py +53 -44
  119. lfx/components/{helpers → models_and_agents}/memory.py +1 -1
  120. lfx/components/nvidia/system_assist.py +1 -1
  121. lfx/components/olivya/olivya.py +1 -1
  122. lfx/components/ollama/ollama.py +17 -3
  123. lfx/components/processing/__init__.py +9 -57
  124. lfx/components/processing/converter.py +1 -1
  125. lfx/components/processing/dataframe_operations.py +1 -1
  126. lfx/components/processing/parse_json_data.py +2 -2
  127. lfx/components/processing/parser.py +1 -1
  128. lfx/components/processing/split_text.py +1 -1
  129. lfx/components/qdrant/qdrant.py +1 -1
  130. lfx/components/redis/redis.py +1 -1
  131. lfx/components/twelvelabs/split_video.py +10 -0
  132. lfx/components/twelvelabs/video_file.py +12 -0
  133. lfx/components/utilities/__init__.py +43 -0
  134. lfx/components/{helpers → utilities}/calculator_core.py +1 -1
  135. lfx/components/{helpers → utilities}/current_date.py +1 -1
  136. lfx/components/{processing → utilities}/python_repl_core.py +1 -1
  137. lfx/components/vectorstores/local_db.py +9 -0
  138. lfx/components/youtube/youtube_transcripts.py +118 -30
  139. lfx/custom/custom_component/component.py +57 -1
  140. lfx/custom/custom_component/custom_component.py +68 -6
  141. lfx/graph/edge/base.py +43 -20
  142. lfx/graph/graph/base.py +4 -1
  143. lfx/graph/state/model.py +15 -2
  144. lfx/graph/utils.py +6 -0
  145. lfx/graph/vertex/base.py +4 -1
  146. lfx/graph/vertex/param_handler.py +10 -7
  147. lfx/helpers/__init__.py +12 -0
  148. lfx/helpers/flow.py +117 -0
  149. lfx/inputs/input_mixin.py +24 -1
  150. lfx/inputs/inputs.py +13 -1
  151. lfx/interface/components.py +161 -83
  152. lfx/log/logger.py +5 -3
  153. lfx/services/database/__init__.py +5 -0
  154. lfx/services/database/service.py +25 -0
  155. lfx/services/deps.py +87 -22
  156. lfx/services/manager.py +19 -6
  157. lfx/services/mcp_composer/service.py +998 -157
  158. lfx/services/session.py +5 -0
  159. lfx/services/settings/base.py +51 -7
  160. lfx/services/settings/constants.py +8 -0
  161. lfx/services/storage/local.py +76 -46
  162. lfx/services/storage/service.py +152 -29
  163. lfx/template/field/base.py +3 -0
  164. lfx/utils/ssrf_protection.py +384 -0
  165. lfx/utils/validate_cloud.py +26 -0
  166. {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/METADATA +38 -22
  167. {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/RECORD +182 -150
  168. {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/WHEEL +1 -1
  169. lfx/components/agents/altk_agent.py +0 -366
  170. lfx/components/agents/cuga_agent.py +0 -1013
  171. lfx/components/docling/docling_remote_vlm.py +0 -284
  172. lfx/components/logic/run_flow.py +0 -71
  173. lfx/components/models/embedding_model.py +0 -195
  174. lfx/components/models/language_model.py +0 -144
  175. /lfx/components/{data → data_source}/mock_data.py +0 -0
  176. /lfx/components/{knowledge_bases → files_and_knowledge}/ingestion.py +0 -0
  177. /lfx/components/{logic → flow_controls}/data_conditional_router.py +0 -0
  178. /lfx/components/{logic → flow_controls}/flow_tool.py +0 -0
  179. /lfx/components/{logic → flow_controls}/listen.py +0 -0
  180. /lfx/components/{logic → flow_controls}/notify.py +0 -0
  181. /lfx/components/{logic → flow_controls}/pass_message.py +0 -0
  182. /lfx/components/{logic → flow_controls}/sub_flow.py +0 -0
  183. /lfx/components/{processing → models_and_agents}/prompt.py +0 -0
  184. /lfx/components/{helpers → processing}/create_list.py +0 -0
  185. /lfx/components/{helpers → processing}/output_parser.py +0 -0
  186. /lfx/components/{helpers → processing}/store_message.py +0 -0
  187. /lfx/components/{helpers → utilities}/id_generator.py +0 -0
  188. {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,7 @@ from lfx.inputs.inputs import DataInput, DropdownInput, IntInput
9
9
  class LanguageRecursiveTextSplitterComponent(LCTextSplitterComponent):
10
10
  display_name: str = "Language Recursive Text Splitter"
11
11
  description: str = "Split text into chunks of a specified length based on language."
12
- documentation: str = "https://docs.langflow.org/components/text-splitters#languagerecursivetextsplitter"
12
+ documentation: str = "https://docs.langflow.org/bundles-langchain"
13
13
  name = "LanguageRecursiveTextSplitter"
14
14
  icon = "LangChain"
15
15
 
@@ -0,0 +1,46 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ from lfx.components._importing import import_mod
6
+
7
+ if TYPE_CHECKING:
8
+ from lfx.components.llm_operations.batch_run import BatchRunComponent
9
+ from lfx.components.llm_operations.lambda_filter import SmartTransformComponent
10
+ from lfx.components.llm_operations.llm_conditional_router import SmartRouterComponent
11
+ from lfx.components.llm_operations.llm_selector import LLMSelectorComponent
12
+ from lfx.components.llm_operations.structured_output import StructuredOutputComponent
13
+
14
+ _dynamic_imports = {
15
+ "BatchRunComponent": "batch_run",
16
+ "SmartTransformComponent": "lambda_filter",
17
+ "SmartRouterComponent": "llm_conditional_router",
18
+ "LLMSelectorComponent": "llm_selector",
19
+ "StructuredOutputComponent": "structured_output",
20
+ }
21
+
22
+ __all__ = [
23
+ "BatchRunComponent",
24
+ "LLMSelectorComponent",
25
+ "SmartRouterComponent",
26
+ "SmartTransformComponent",
27
+ "StructuredOutputComponent",
28
+ ]
29
+
30
+
31
+ def __getattr__(attr_name: str) -> Any:
32
+ """Lazily import LLM operation components on attribute access."""
33
+ if attr_name not in _dynamic_imports:
34
+ msg = f"module '{__name__}' has no attribute '{attr_name}'"
35
+ raise AttributeError(msg)
36
+ try:
37
+ result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)
38
+ except (ModuleNotFoundError, ImportError, AttributeError) as e:
39
+ msg = f"Could not import '{attr_name}' from '{__name__}': {e}"
40
+ raise AttributeError(msg) from e
41
+ globals()[attr_name] = result
42
+ return result
43
+
44
+
45
+ def __dir__() -> list[str]:
46
+ return list(__all__)
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
16
16
  class BatchRunComponent(Component):
17
17
  display_name = "Batch Run"
18
18
  description = "Runs an LLM on each row of a DataFrame column. If no column is specified, all columns are used."
19
- documentation: str = "https://docs.langflow.org/components-processing#batch-run"
19
+ documentation: str = "https://docs.langflow.org/batch-run"
20
20
  icon = "List"
21
21
 
22
22
  inputs = [
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
16
16
  class LambdaFilterComponent(Component):
17
17
  display_name = "Smart Transform"
18
18
  description = "Uses an LLM to generate a function for filtering or transforming structured data."
19
- documentation: str = "https://docs.langflow.org/components-processing#smart-transform"
19
+ documentation: str = "https://docs.langflow.org/smart-transform"
20
20
  icon = "square-function"
21
21
  name = "Smart Transform"
22
22
 
@@ -9,7 +9,7 @@ from lfx.schema.table import EditMode
9
9
  class SmartRouterComponent(Component):
10
10
  display_name = "Smart Router"
11
11
  description = "Routes an input message using LLM-based categorization."
12
- icon = "equal"
12
+ icon = "route"
13
13
  name = "SmartRouter"
14
14
 
15
15
  def __init__(self, **kwargs):
@@ -14,10 +14,10 @@ from lfx.schema.message import Message
14
14
  from lfx.template.field.base import Output
15
15
 
16
16
 
17
- class LLMRouterComponent(Component):
18
- display_name = "LLM Router"
17
+ class LLMSelectorComponent(Component):
18
+ display_name = "LLM Selector"
19
19
  description = "Routes the input to the most appropriate LLM based on OpenRouter model specifications"
20
- documentation: str = "https://docs.langflow.org/components-processing#llm-router"
20
+ documentation: str = "https://docs.langflow.org/llm-selector"
21
21
  icon = "git-branch"
22
22
 
23
23
  # Constants for magic values
@@ -20,7 +20,7 @@ from lfx.schema.table import EditMode
20
20
  class StructuredOutputComponent(Component):
21
21
  display_name = "Structured Output"
22
22
  description = "Uses an LLM to generate structured data. Ideal for extraction and consistency."
23
- documentation: str = "https://docs.langflow.org/components-processing#structured-output"
23
+ documentation: str = "https://docs.langflow.org/structured-output"
24
24
  name = "StructuredOutput"
25
25
  icon = "braces"
26
26
 
@@ -1,5 +1,12 @@
1
+ """Logic module - backwards compatibility alias for flow_controls.
2
+
3
+ This module provides backwards compatibility by forwarding imports
4
+ to flow_controls where the actual logic components are located.
5
+ """
6
+
1
7
  from __future__ import annotations
2
8
 
9
+ import sys
3
10
  from typing import TYPE_CHECKING, Any
4
11
 
5
12
  from lfx.components._importing import import_mod
@@ -36,12 +43,131 @@ __all__ = [
36
43
  "SubFlowComponent",
37
44
  ]
38
45
 
46
+ # Register redirected submodules in sys.modules for direct importlib.import_module() calls
47
+ # This allows imports like: import lfx.components.logic.listen
48
+ _redirected_submodules = {
49
+ "lfx.components.logic.listen": "lfx.components.flow_controls.listen",
50
+ "lfx.components.logic.loop": "lfx.components.flow_controls.loop",
51
+ "lfx.components.logic.notify": "lfx.components.flow_controls.notify",
52
+ "lfx.components.logic.pass_message": "lfx.components.flow_controls.pass_message",
53
+ "lfx.components.logic.conditional_router": "lfx.components.flow_controls.conditional_router",
54
+ "lfx.components.logic.data_conditional_router": "lfx.components.flow_controls.data_conditional_router",
55
+ "lfx.components.logic.flow_tool": "lfx.components.flow_controls.flow_tool",
56
+ "lfx.components.logic.run_flow": "lfx.components.flow_controls.run_flow",
57
+ "lfx.components.logic.sub_flow": "lfx.components.flow_controls.sub_flow",
58
+ }
59
+
60
+ for old_path, new_path in _redirected_submodules.items():
61
+ if old_path not in sys.modules:
62
+ # Use a lazy loader that imports the actual module when accessed
63
+ class _RedirectedModule:
64
+ def __init__(self, target_path: str, original_path: str):
65
+ self._target_path = target_path
66
+ self._original_path = original_path
67
+ self._module = None
68
+
69
+ def __getattr__(self, name: str) -> Any:
70
+ if self._module is None:
71
+ from importlib import import_module
72
+
73
+ self._module = import_module(self._target_path)
74
+ # Also register under the original path for future imports
75
+ sys.modules[self._original_path] = self._module
76
+ return getattr(self._module, name)
77
+
78
+ def __repr__(self) -> str:
79
+ return f"<redirected module '{self._original_path}' -> '{self._target_path}'>"
80
+
81
+ sys.modules[old_path] = _RedirectedModule(new_path, old_path)
82
+
39
83
 
40
84
  def __getattr__(attr_name: str) -> Any:
41
85
  """Lazily import logic components on attribute access."""
86
+ # Handle submodule access for backwards compatibility
87
+ if attr_name == "listen":
88
+ from importlib import import_module
89
+
90
+ result = import_module("lfx.components.flow_controls.listen")
91
+ globals()[attr_name] = result
92
+ return result
93
+ if attr_name == "loop":
94
+ from importlib import import_module
95
+
96
+ result = import_module("lfx.components.flow_controls.loop")
97
+ globals()[attr_name] = result
98
+ return result
99
+ if attr_name == "notify":
100
+ from importlib import import_module
101
+
102
+ result = import_module("lfx.components.flow_controls.notify")
103
+ globals()[attr_name] = result
104
+ return result
105
+ if attr_name == "pass_message":
106
+ from importlib import import_module
107
+
108
+ result = import_module("lfx.components.flow_controls.pass_message")
109
+ globals()[attr_name] = result
110
+ return result
111
+ if attr_name == "conditional_router":
112
+ from importlib import import_module
113
+
114
+ result = import_module("lfx.components.flow_controls.conditional_router")
115
+ globals()[attr_name] = result
116
+ return result
117
+ if attr_name == "data_conditional_router":
118
+ from importlib import import_module
119
+
120
+ result = import_module("lfx.components.flow_controls.data_conditional_router")
121
+ globals()[attr_name] = result
122
+ return result
123
+ if attr_name == "flow_tool":
124
+ from importlib import import_module
125
+
126
+ result = import_module("lfx.components.flow_controls.flow_tool")
127
+ globals()[attr_name] = result
128
+ return result
129
+ if attr_name == "run_flow":
130
+ from importlib import import_module
131
+
132
+ result = import_module("lfx.components.flow_controls.run_flow")
133
+ globals()[attr_name] = result
134
+ return result
135
+ if attr_name == "sub_flow":
136
+ from importlib import import_module
137
+
138
+ result = import_module("lfx.components.flow_controls.sub_flow")
139
+ globals()[attr_name] = result
140
+ return result
141
+
42
142
  if attr_name not in _dynamic_imports:
43
143
  msg = f"module '{__name__}' has no attribute '{attr_name}'"
44
144
  raise AttributeError(msg)
145
+
146
+ # Most logic components were moved to flow_controls
147
+ # Forward them to flow_controls for backwards compatibility
148
+ if attr_name in (
149
+ "ConditionalRouterComponent",
150
+ "DataConditionalRouterComponent",
151
+ "FlowToolComponent",
152
+ "LoopComponent",
153
+ "PassMessageComponent",
154
+ "RunFlowComponent",
155
+ "SubFlowComponent",
156
+ ):
157
+ from lfx.components import flow_controls
158
+
159
+ result = getattr(flow_controls, attr_name)
160
+ globals()[attr_name] = result
161
+ return result
162
+
163
+ # SmartRouterComponent was moved to llm_operations
164
+ if attr_name == "SmartRouterComponent":
165
+ from lfx.components import llm_operations
166
+
167
+ result = getattr(llm_operations, attr_name)
168
+ globals()[attr_name] = result
169
+ return result
170
+
45
171
  try:
46
172
  result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)
47
173
  except (ModuleNotFoundError, ImportError, AttributeError) as e:
@@ -7,6 +7,11 @@ from lfx.inputs.inputs import DictInput, HandleInput, MessageTextInput, NestedDi
7
7
  from lfx.io import Output
8
8
  from lfx.log.logger import logger
9
9
  from lfx.schema.data import Data
10
+ from lfx.utils.validate_cloud import raise_error_if_astra_cloud_disable_component
11
+
12
+ disable_component_in_astra_cloud_msg = (
13
+ "Mem0 chat memory is not supported in Astra cloud environment. Please use local storage mode or mem0 cloud."
14
+ )
10
15
 
11
16
 
12
17
  class Mem0MemoryComponent(LCChatMemoryComponent):
@@ -80,6 +85,8 @@ class Mem0MemoryComponent(LCChatMemoryComponent):
80
85
 
81
86
  def build_mem0(self) -> Memory:
82
87
  """Initializes a Mem0 memory instance based on provided configuration and API keys."""
88
+ # Check if we're in Astra cloud environment and raise an error if we are.
89
+ raise_error_if_astra_cloud_disable_component(disable_component_in_astra_cloud_msg)
83
90
  if self.openai_api_key:
84
91
  os.environ["OPENAI_API_KEY"] = self.openai_api_key
85
92
 
@@ -95,6 +102,8 @@ class Mem0MemoryComponent(LCChatMemoryComponent):
95
102
 
96
103
  def ingest_data(self) -> Memory:
97
104
  """Ingests a new message into Mem0 memory and returns the updated memory instance."""
105
+ # Check if we're in Astra cloud environment and raise an error if we are.
106
+ raise_error_if_astra_cloud_disable_component(disable_component_in_astra_cloud_msg)
98
107
  mem0_memory = self.existing_memory or self.build_mem0()
99
108
 
100
109
  if not self.ingest_message or not self.user_id:
@@ -115,6 +124,8 @@ class Mem0MemoryComponent(LCChatMemoryComponent):
115
124
 
116
125
  def build_search_results(self) -> Data:
117
126
  """Searches the Mem0 memory for related messages based on the search query and returns the results."""
127
+ # Check if we're in Astra cloud environment and raise an error if we are.
128
+ raise_error_if_astra_cloud_disable_component(disable_component_in_astra_cloud_msg)
118
129
  mem0_memory = self.ingest_data()
119
130
  search_query = self.search_query
120
131
  user_id = self.user_id
@@ -1,28 +1,82 @@
1
+ """Models module - backwards compatibility alias for models_and_agents.
2
+
3
+ This module provides backwards compatibility by forwarding model-related imports
4
+ to models_and_agents where the actual model components are located.
5
+ """
6
+
1
7
  from __future__ import annotations
2
8
 
3
- from typing import TYPE_CHECKING, Any
9
+ import sys
10
+ from typing import Any
4
11
 
5
12
  from lfx.components._importing import import_mod
6
13
 
7
- if TYPE_CHECKING:
8
- from lfx.components.models.embedding_model import EmbeddingModelComponent
9
- from lfx.components.models.language_model import LanguageModelComponent
10
-
14
+ # Forward model components from models_and_agents
11
15
  _dynamic_imports = {
12
- "EmbeddingModelComponent": "embedding_model",
13
16
  "LanguageModelComponent": "language_model",
17
+ "EmbeddingModelComponent": "embedding_model",
18
+ }
19
+
20
+ __all__ = [
21
+ "EmbeddingModelComponent",
22
+ "LanguageModelComponent",
23
+ ]
24
+
25
+ # Register redirected submodules in sys.modules for direct importlib.import_module() calls
26
+ # This allows imports like: import lfx.components.models.embedding_model
27
+ _redirected_submodules = {
28
+ "lfx.components.models.embedding_model": "lfx.components.models_and_agents.embedding_model",
29
+ "lfx.components.models.language_model": "lfx.components.models_and_agents.language_model",
14
30
  }
15
31
 
16
- __all__ = ["EmbeddingModelComponent", "LanguageModelComponent"]
32
+ for old_path, new_path in _redirected_submodules.items():
33
+ if old_path not in sys.modules:
34
+ # Use a lazy loader that imports the actual module when accessed
35
+ class _RedirectedModule:
36
+ def __init__(self, target_path: str, original_path: str):
37
+ self._target_path = target_path
38
+ self._original_path = original_path
39
+ self._module = None
40
+
41
+ def __getattr__(self, name: str) -> Any:
42
+ if self._module is None:
43
+ from importlib import import_module
44
+
45
+ self._module = import_module(self._target_path)
46
+ # Also register under the original path for future imports
47
+ sys.modules[self._original_path] = self._module
48
+ return getattr(self._module, name)
49
+
50
+ def __repr__(self) -> str:
51
+ return f"<redirected module '{self._original_path}' -> '{self._target_path}'>"
52
+
53
+ sys.modules[old_path] = _RedirectedModule(new_path, old_path)
17
54
 
18
55
 
19
56
  def __getattr__(attr_name: str) -> Any:
20
- """Lazily import model components on attribute access."""
57
+ """Forward attribute access to models_and_agents components."""
58
+ # Handle submodule access for backwards compatibility
59
+ if attr_name == "embedding_model":
60
+ from importlib import import_module
61
+
62
+ result = import_module("lfx.components.models_and_agents.embedding_model")
63
+ globals()[attr_name] = result
64
+ return result
65
+ if attr_name == "language_model":
66
+ from importlib import import_module
67
+
68
+ result = import_module("lfx.components.models_and_agents.language_model")
69
+ globals()[attr_name] = result
70
+ return result
71
+
21
72
  if attr_name not in _dynamic_imports:
22
73
  msg = f"module '{__name__}' has no attribute '{attr_name}'"
23
74
  raise AttributeError(msg)
75
+
76
+ # Import from models_and_agents using the correct package path
77
+ package = "lfx.components.models_and_agents"
24
78
  try:
25
- result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)
79
+ result = import_mod(attr_name, _dynamic_imports[attr_name], package)
26
80
  except (ModuleNotFoundError, ImportError, AttributeError) as e:
27
81
  msg = f"Could not import '{attr_name}' from '{__name__}': {e}"
28
82
  raise AttributeError(msg) from e
@@ -31,4 +85,5 @@ def __getattr__(attr_name: str) -> Any:
31
85
 
32
86
 
33
87
  def __dir__() -> list[str]:
88
+ """Return directory of available components."""
34
89
  return list(__all__)
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ from lfx.components._importing import import_mod
6
+
7
+ if TYPE_CHECKING:
8
+ from lfx.components.models_and_agents.agent import AgentComponent
9
+ from lfx.components.models_and_agents.embedding_model import EmbeddingModelComponent
10
+ from lfx.components.models_and_agents.language_model import LanguageModelComponent
11
+ from lfx.components.models_and_agents.mcp_component import MCPToolsComponent
12
+ from lfx.components.models_and_agents.memory import MemoryComponent
13
+ from lfx.components.models_and_agents.prompt import PromptComponent
14
+
15
+ _dynamic_imports = {
16
+ "AgentComponent": "agent",
17
+ "EmbeddingModelComponent": "embedding_model",
18
+ "LanguageModelComponent": "language_model",
19
+ "MCPToolsComponent": "mcp_component",
20
+ "MemoryComponent": "memory",
21
+ "PromptComponent": "prompt",
22
+ }
23
+
24
+ __all__ = [
25
+ "AgentComponent",
26
+ "EmbeddingModelComponent",
27
+ "LanguageModelComponent",
28
+ "MCPToolsComponent",
29
+ "MemoryComponent",
30
+ "PromptComponent",
31
+ ]
32
+
33
+
34
+ def __getattr__(attr_name: str) -> Any:
35
+ """Lazily import model and agent components on attribute access."""
36
+ if attr_name not in _dynamic_imports:
37
+ msg = f"module '{__name__}' has no attribute '{attr_name}'"
38
+ raise AttributeError(msg)
39
+ try:
40
+ result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)
41
+ except (ModuleNotFoundError, ImportError, AttributeError) as e:
42
+ msg = f"Could not import '{attr_name}' from '{__name__}': {e}"
43
+ raise AttributeError(msg) from e
44
+ globals()[attr_name] = result
45
+ return result
46
+
47
+
48
+ def __dir__() -> list[str]:
49
+ return list(__all__)
@@ -14,9 +14,9 @@ from lfx.base.models.model_input_constants import (
14
14
  MODELS_METADATA,
15
15
  )
16
16
  from lfx.base.models.model_utils import get_model_name
17
- from lfx.components.helpers.current_date import CurrentDateComponent
18
- from lfx.components.helpers.memory import MemoryComponent
17
+ from lfx.components.helpers import CurrentDateComponent
19
18
  from lfx.components.langchain_utilities.tool_calling import ToolCallingAgentComponent
19
+ from lfx.components.models_and_agents.memory import MemoryComponent
20
20
  from lfx.custom.custom_component.component import get_component_toolkit
21
21
  from lfx.custom.utils import update_component_build_config
22
22
  from lfx.helpers.base_model import build_model_from_schema