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.
- lfx/_assets/component_index.json +1 -1
- lfx/base/agents/agent.py +13 -1
- lfx/base/agents/altk_base_agent.py +380 -0
- lfx/base/agents/altk_tool_wrappers.py +565 -0
- lfx/base/agents/events.py +2 -1
- lfx/base/composio/composio_base.py +159 -224
- lfx/base/data/base_file.py +88 -21
- lfx/base/data/storage_utils.py +192 -0
- lfx/base/data/utils.py +178 -14
- lfx/base/embeddings/embeddings_class.py +113 -0
- lfx/base/models/groq_constants.py +74 -58
- lfx/base/models/groq_model_discovery.py +265 -0
- lfx/base/models/model.py +1 -1
- lfx/base/models/model_utils.py +100 -0
- lfx/base/models/openai_constants.py +7 -0
- lfx/base/models/watsonx_constants.py +32 -8
- lfx/base/tools/run_flow.py +601 -129
- lfx/cli/commands.py +6 -3
- lfx/cli/common.py +2 -2
- lfx/cli/run.py +1 -1
- lfx/cli/script_loader.py +53 -11
- lfx/components/Notion/create_page.py +1 -1
- lfx/components/Notion/list_database_properties.py +1 -1
- lfx/components/Notion/list_pages.py +1 -1
- lfx/components/Notion/list_users.py +1 -1
- lfx/components/Notion/page_content_viewer.py +1 -1
- lfx/components/Notion/search.py +1 -1
- lfx/components/Notion/update_page_property.py +1 -1
- lfx/components/__init__.py +19 -5
- lfx/components/{agents → altk}/__init__.py +5 -9
- lfx/components/altk/altk_agent.py +193 -0
- lfx/components/apify/apify_actor.py +1 -1
- lfx/components/composio/__init__.py +70 -18
- lfx/components/composio/apollo_composio.py +11 -0
- lfx/components/composio/bitbucket_composio.py +11 -0
- lfx/components/composio/canva_composio.py +11 -0
- lfx/components/composio/coda_composio.py +11 -0
- lfx/components/composio/composio_api.py +10 -0
- lfx/components/composio/discord_composio.py +1 -1
- lfx/components/composio/elevenlabs_composio.py +11 -0
- lfx/components/composio/exa_composio.py +11 -0
- lfx/components/composio/firecrawl_composio.py +11 -0
- lfx/components/composio/fireflies_composio.py +11 -0
- lfx/components/composio/gmail_composio.py +1 -1
- lfx/components/composio/googlebigquery_composio.py +11 -0
- lfx/components/composio/googlecalendar_composio.py +1 -1
- lfx/components/composio/googledocs_composio.py +1 -1
- lfx/components/composio/googlemeet_composio.py +1 -1
- lfx/components/composio/googlesheets_composio.py +1 -1
- lfx/components/composio/googletasks_composio.py +1 -1
- lfx/components/composio/heygen_composio.py +11 -0
- lfx/components/composio/mem0_composio.py +11 -0
- lfx/components/composio/peopledatalabs_composio.py +11 -0
- lfx/components/composio/perplexityai_composio.py +11 -0
- lfx/components/composio/serpapi_composio.py +11 -0
- lfx/components/composio/slack_composio.py +3 -574
- lfx/components/composio/slackbot_composio.py +1 -1
- lfx/components/composio/snowflake_composio.py +11 -0
- lfx/components/composio/tavily_composio.py +11 -0
- lfx/components/composio/youtube_composio.py +2 -2
- lfx/components/cuga/__init__.py +34 -0
- lfx/components/cuga/cuga_agent.py +730 -0
- lfx/components/data/__init__.py +78 -28
- lfx/components/data_source/__init__.py +58 -0
- lfx/components/{data → data_source}/api_request.py +26 -3
- lfx/components/{data → data_source}/csv_to_data.py +15 -10
- lfx/components/{data → data_source}/json_to_data.py +15 -8
- lfx/components/{data → data_source}/news_search.py +1 -1
- lfx/components/{data → data_source}/rss.py +1 -1
- lfx/components/{data → data_source}/sql_executor.py +1 -1
- lfx/components/{data → data_source}/url.py +1 -1
- lfx/components/{data → data_source}/web_search.py +1 -1
- lfx/components/datastax/astradb_cql.py +1 -1
- lfx/components/datastax/astradb_graph.py +1 -1
- lfx/components/datastax/astradb_tool.py +1 -1
- lfx/components/datastax/astradb_vectorstore.py +1 -1
- lfx/components/datastax/hcd.py +1 -1
- lfx/components/deactivated/json_document_builder.py +1 -1
- lfx/components/docling/__init__.py +0 -3
- lfx/components/elastic/elasticsearch.py +1 -1
- lfx/components/elastic/opensearch_multimodal.py +1575 -0
- lfx/components/files_and_knowledge/__init__.py +47 -0
- lfx/components/{data → files_and_knowledge}/directory.py +1 -1
- lfx/components/{data → files_and_knowledge}/file.py +246 -18
- lfx/components/{knowledge_bases → files_and_knowledge}/retrieval.py +2 -2
- lfx/components/{data → files_and_knowledge}/save_file.py +142 -22
- lfx/components/flow_controls/__init__.py +58 -0
- lfx/components/{logic → flow_controls}/conditional_router.py +1 -1
- lfx/components/{logic → flow_controls}/loop.py +43 -9
- lfx/components/flow_controls/run_flow.py +108 -0
- lfx/components/glean/glean_search_api.py +1 -1
- lfx/components/groq/groq.py +35 -28
- lfx/components/helpers/__init__.py +102 -0
- lfx/components/input_output/__init__.py +3 -1
- lfx/components/input_output/chat.py +4 -3
- lfx/components/input_output/chat_output.py +4 -4
- lfx/components/input_output/text.py +1 -1
- lfx/components/input_output/text_output.py +1 -1
- lfx/components/{data → input_output}/webhook.py +1 -1
- lfx/components/knowledge_bases/__init__.py +59 -4
- lfx/components/langchain_utilities/character.py +1 -1
- lfx/components/langchain_utilities/csv_agent.py +84 -16
- lfx/components/langchain_utilities/json_agent.py +67 -12
- lfx/components/langchain_utilities/language_recursive.py +1 -1
- lfx/components/llm_operations/__init__.py +46 -0
- lfx/components/{processing → llm_operations}/batch_run.py +1 -1
- lfx/components/{processing → llm_operations}/lambda_filter.py +1 -1
- lfx/components/{logic → llm_operations}/llm_conditional_router.py +1 -1
- lfx/components/{processing/llm_router.py → llm_operations/llm_selector.py} +3 -3
- lfx/components/{processing → llm_operations}/structured_output.py +1 -1
- lfx/components/logic/__init__.py +126 -0
- lfx/components/mem0/mem0_chat_memory.py +11 -0
- lfx/components/models/__init__.py +64 -9
- lfx/components/models_and_agents/__init__.py +49 -0
- lfx/components/{agents → models_and_agents}/agent.py +2 -2
- lfx/components/models_and_agents/embedding_model.py +423 -0
- lfx/components/models_and_agents/language_model.py +398 -0
- lfx/components/{agents → models_and_agents}/mcp_component.py +53 -44
- lfx/components/{helpers → models_and_agents}/memory.py +1 -1
- lfx/components/nvidia/system_assist.py +1 -1
- lfx/components/olivya/olivya.py +1 -1
- lfx/components/ollama/ollama.py +17 -3
- lfx/components/processing/__init__.py +9 -57
- lfx/components/processing/converter.py +1 -1
- lfx/components/processing/dataframe_operations.py +1 -1
- lfx/components/processing/parse_json_data.py +2 -2
- lfx/components/processing/parser.py +1 -1
- lfx/components/processing/split_text.py +1 -1
- lfx/components/qdrant/qdrant.py +1 -1
- lfx/components/redis/redis.py +1 -1
- lfx/components/twelvelabs/split_video.py +10 -0
- lfx/components/twelvelabs/video_file.py +12 -0
- lfx/components/utilities/__init__.py +43 -0
- lfx/components/{helpers → utilities}/calculator_core.py +1 -1
- lfx/components/{helpers → utilities}/current_date.py +1 -1
- lfx/components/{processing → utilities}/python_repl_core.py +1 -1
- lfx/components/vectorstores/local_db.py +9 -0
- lfx/components/youtube/youtube_transcripts.py +118 -30
- lfx/custom/custom_component/component.py +57 -1
- lfx/custom/custom_component/custom_component.py +68 -6
- lfx/graph/edge/base.py +43 -20
- lfx/graph/graph/base.py +4 -1
- lfx/graph/state/model.py +15 -2
- lfx/graph/utils.py +6 -0
- lfx/graph/vertex/base.py +4 -1
- lfx/graph/vertex/param_handler.py +10 -7
- lfx/helpers/__init__.py +12 -0
- lfx/helpers/flow.py +117 -0
- lfx/inputs/input_mixin.py +24 -1
- lfx/inputs/inputs.py +13 -1
- lfx/interface/components.py +161 -83
- lfx/log/logger.py +5 -3
- lfx/services/database/__init__.py +5 -0
- lfx/services/database/service.py +25 -0
- lfx/services/deps.py +87 -22
- lfx/services/manager.py +19 -6
- lfx/services/mcp_composer/service.py +998 -157
- lfx/services/session.py +5 -0
- lfx/services/settings/base.py +51 -7
- lfx/services/settings/constants.py +8 -0
- lfx/services/storage/local.py +76 -46
- lfx/services/storage/service.py +152 -29
- lfx/template/field/base.py +3 -0
- lfx/utils/ssrf_protection.py +384 -0
- lfx/utils/validate_cloud.py +26 -0
- {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/METADATA +38 -22
- {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/RECORD +182 -150
- {lfx_nightly-0.2.0.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/WHEEL +1 -1
- lfx/components/agents/altk_agent.py +0 -366
- lfx/components/agents/cuga_agent.py +0 -1013
- lfx/components/docling/docling_remote_vlm.py +0 -284
- lfx/components/logic/run_flow.py +0 -71
- lfx/components/models/embedding_model.py +0 -195
- lfx/components/models/language_model.py +0 -144
- /lfx/components/{data → data_source}/mock_data.py +0 -0
- /lfx/components/{knowledge_bases → files_and_knowledge}/ingestion.py +0 -0
- /lfx/components/{logic → flow_controls}/data_conditional_router.py +0 -0
- /lfx/components/{logic → flow_controls}/flow_tool.py +0 -0
- /lfx/components/{logic → flow_controls}/listen.py +0 -0
- /lfx/components/{logic → flow_controls}/notify.py +0 -0
- /lfx/components/{logic → flow_controls}/pass_message.py +0 -0
- /lfx/components/{logic → flow_controls}/sub_flow.py +0 -0
- /lfx/components/{processing → models_and_agents}/prompt.py +0 -0
- /lfx/components/{helpers → processing}/create_list.py +0 -0
- /lfx/components/{helpers → processing}/output_parser.py +0 -0
- /lfx/components/{helpers → processing}/store_message.py +0 -0
- /lfx/components/{helpers → utilities}/id_generator.py +0 -0
- {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/
|
|
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/
|
|
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/
|
|
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 = "
|
|
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
|
|
18
|
-
display_name = "LLM
|
|
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/
|
|
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/
|
|
23
|
+
documentation: str = "https://docs.langflow.org/structured-output"
|
|
24
24
|
name = "StructuredOutput"
|
|
25
25
|
icon = "braces"
|
|
26
26
|
|
lfx/components/logic/__init__.py
CHANGED
|
@@ -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
|
-
|
|
9
|
+
import sys
|
|
10
|
+
from typing import Any
|
|
4
11
|
|
|
5
12
|
from lfx.components._importing import import_mod
|
|
6
13
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
"""
|
|
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],
|
|
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
|
|
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
|