lfx-nightly 0.1.13.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 +121 -29
- lfx/base/agents/altk_base_agent.py +380 -0
- lfx/base/agents/altk_tool_wrappers.py +565 -0
- lfx/base/agents/events.py +103 -35
- lfx/base/agents/utils.py +15 -2
- lfx/base/composio/composio_base.py +183 -233
- 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/datastax/__init__.py +5 -0
- lfx/{components/vectorstores/astradb.py → base/datastax/astradb_base.py} +84 -473
- lfx/base/embeddings/embeddings_class.py +113 -0
- lfx/base/io/chat.py +5 -4
- lfx/base/mcp/util.py +101 -15
- 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_input_constants.py +74 -7
- lfx/base/models/model_utils.py +100 -0
- lfx/base/models/ollama_constants.py +3 -0
- lfx/base/models/openai_constants.py +7 -0
- lfx/base/models/watsonx_constants.py +36 -0
- lfx/base/tools/run_flow.py +601 -129
- lfx/cli/commands.py +7 -4
- 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/altk/__init__.py +34 -0
- lfx/components/altk/altk_agent.py +193 -0
- lfx/components/amazon/amazon_bedrock_converse.py +1 -1
- lfx/components/apify/apify_actor.py +4 -4
- 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/{agents → cuga}/__init__.py +5 -7
- 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/__init__.py +12 -6
- lfx/components/datastax/{astra_assistant_manager.py → astradb_assistant_manager.py} +1 -0
- lfx/components/datastax/astradb_chatmemory.py +40 -0
- lfx/components/datastax/astradb_cql.py +6 -32
- lfx/components/datastax/astradb_graph.py +10 -124
- lfx/components/datastax/astradb_tool.py +13 -53
- lfx/components/datastax/astradb_vectorstore.py +134 -977
- lfx/components/datastax/create_assistant.py +1 -0
- lfx/components/datastax/create_thread.py +1 -0
- lfx/components/datastax/dotenv.py +1 -0
- lfx/components/datastax/get_assistant.py +1 -0
- lfx/components/datastax/getenvvar.py +1 -0
- lfx/components/datastax/graph_rag.py +1 -1
- lfx/components/datastax/hcd.py +1 -1
- lfx/components/datastax/list_assistants.py +1 -0
- lfx/components/datastax/run.py +1 -0
- lfx/components/deactivated/json_document_builder.py +1 -1
- 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}/ingestion.py +17 -9
- lfx/components/{knowledge_bases → files_and_knowledge}/retrieval.py +18 -10
- 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 +47 -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/ibm/watsonx.py +25 -21
- lfx/components/input_output/__init__.py +3 -1
- lfx/components/input_output/chat.py +12 -3
- lfx/components/input_output/chat_output.py +12 -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 +56 -18
- lfx/components/logic/__init__.py +126 -0
- lfx/components/mem0/mem0_chat_memory.py +11 -0
- lfx/components/mistral/mistral_embeddings.py +1 -1
- lfx/components/models/__init__.py +64 -9
- lfx/components/models_and_agents/__init__.py +49 -0
- lfx/components/{agents → models_and_agents}/agent.py +49 -6
- 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 +84 -45
- 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 +235 -14
- lfx/components/openrouter/openrouter.py +49 -147
- 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 +7 -2
- 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/__init__.py +0 -6
- lfx/components/vectorstores/local_db.py +9 -0
- lfx/components/youtube/youtube_transcripts.py +118 -30
- lfx/custom/custom_component/component.py +60 -3
- lfx/custom/custom_component/custom_component.py +68 -6
- lfx/field_typing/constants.py +1 -0
- lfx/graph/edge/base.py +45 -22
- lfx/graph/graph/base.py +5 -2
- lfx/graph/graph/schema.py +3 -2
- 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/graph/vertex/vertex_types.py +1 -1
- 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/io/schema.py +6 -0
- lfx/log/logger.py +5 -3
- lfx/schema/schema.py +5 -0
- 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.1.13.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/METADATA +38 -22
- {lfx_nightly-0.1.13.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/RECORD +210 -196
- {lfx_nightly-0.1.13.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/WHEEL +1 -1
- lfx/components/agents/cuga_agent.py +0 -1013
- lfx/components/datastax/astra_db.py +0 -77
- lfx/components/datastax/cassandra.py +0 -92
- lfx/components/logic/run_flow.py +0 -71
- lfx/components/models/embedding_model.py +0 -114
- lfx/components/models/language_model.py +0 -144
- lfx/components/vectorstores/astradb_graph.py +0 -326
- lfx/components/vectorstores/cassandra.py +0 -264
- lfx/components/vectorstores/cassandra_graph.py +0 -238
- lfx/components/vectorstores/chroma.py +0 -167
- lfx/components/vectorstores/clickhouse.py +0 -135
- lfx/components/vectorstores/couchbase.py +0 -102
- lfx/components/vectorstores/elasticsearch.py +0 -267
- lfx/components/vectorstores/faiss.py +0 -111
- lfx/components/vectorstores/graph_rag.py +0 -141
- lfx/components/vectorstores/hcd.py +0 -314
- lfx/components/vectorstores/milvus.py +0 -115
- lfx/components/vectorstores/mongodb_atlas.py +0 -213
- lfx/components/vectorstores/opensearch.py +0 -243
- lfx/components/vectorstores/pgvector.py +0 -72
- lfx/components/vectorstores/pinecone.py +0 -134
- lfx/components/vectorstores/qdrant.py +0 -109
- lfx/components/vectorstores/supabase.py +0 -76
- lfx/components/vectorstores/upstash.py +0 -124
- lfx/components/vectorstores/vectara.py +0 -97
- lfx/components/vectorstores/vectara_rag.py +0 -164
- lfx/components/vectorstores/weaviate.py +0 -89
- /lfx/components/{data → data_source}/mock_data.py +0 -0
- /lfx/components/datastax/{astra_vectorize.py → astradb_vectorize.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.1.13.dev0.dist-info → lfx_nightly-0.2.0.dev26.dist-info}/entry_points.txt +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from lfx.base.memory.model import LCChatMemoryComponent
|
|
4
|
-
from lfx.field_typing.constants import Memory
|
|
5
|
-
from lfx.inputs.inputs import MessageTextInput, SecretStrInput, StrInput
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AstraDBChatMemory(LCChatMemoryComponent):
|
|
9
|
-
display_name = "Astra DB Chat Memory"
|
|
10
|
-
description = "Retrieves and store chat messages from Astra DB."
|
|
11
|
-
name = "AstraDBChatMemory"
|
|
12
|
-
documentation: str = "https://docs.langflow.org/bundles-datastax#astra-db-chat-memory"
|
|
13
|
-
icon: str = "AstraDB"
|
|
14
|
-
|
|
15
|
-
inputs = [
|
|
16
|
-
SecretStrInput(
|
|
17
|
-
name="token",
|
|
18
|
-
display_name="Astra DB Application Token",
|
|
19
|
-
info="Authentication token for accessing Astra DB.",
|
|
20
|
-
value="ASTRA_DB_APPLICATION_TOKEN",
|
|
21
|
-
required=True,
|
|
22
|
-
advanced=os.getenv("ASTRA_ENHANCED", "false").lower() == "true",
|
|
23
|
-
),
|
|
24
|
-
SecretStrInput(
|
|
25
|
-
name="api_endpoint",
|
|
26
|
-
display_name="Astra DB API Endpoint",
|
|
27
|
-
info="API endpoint URL for the Astra DB service.",
|
|
28
|
-
value="ASTRA_DB_API_ENDPOINT",
|
|
29
|
-
required=True,
|
|
30
|
-
),
|
|
31
|
-
StrInput(
|
|
32
|
-
name="collection_name",
|
|
33
|
-
display_name="Collection Name",
|
|
34
|
-
info="The name of the collection within Astra DB where the vectors will be stored.",
|
|
35
|
-
required=True,
|
|
36
|
-
),
|
|
37
|
-
StrInput(
|
|
38
|
-
name="namespace",
|
|
39
|
-
display_name="Namespace",
|
|
40
|
-
info="Optional namespace within Astra DB to use for the collection.",
|
|
41
|
-
advanced=True,
|
|
42
|
-
),
|
|
43
|
-
MessageTextInput(
|
|
44
|
-
name="session_id",
|
|
45
|
-
display_name="Session ID",
|
|
46
|
-
info="The session ID of the chat. If empty, the current session ID parameter will be used.",
|
|
47
|
-
advanced=True,
|
|
48
|
-
),
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
def build_message_history(self) -> Memory:
|
|
52
|
-
try:
|
|
53
|
-
from astrapy.admin import parse_api_endpoint
|
|
54
|
-
from langchain_astradb.chat_message_histories import AstraDBChatMessageHistory
|
|
55
|
-
|
|
56
|
-
except ImportError as e:
|
|
57
|
-
msg = (
|
|
58
|
-
"Could not import langchain Astra DB integration package. "
|
|
59
|
-
"Please install it with `pip install langchain-astradb`."
|
|
60
|
-
)
|
|
61
|
-
raise ImportError(msg) from e
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
from astrapy.admin import parse_api_endpoint
|
|
65
|
-
|
|
66
|
-
except ImportError as e:
|
|
67
|
-
msg = "Could not import astrapy package. "
|
|
68
|
-
raise ImportError(msg) from e
|
|
69
|
-
|
|
70
|
-
return AstraDBChatMessageHistory(
|
|
71
|
-
session_id=self.session_id,
|
|
72
|
-
collection_name=self.collection_name,
|
|
73
|
-
token=self.token,
|
|
74
|
-
api_endpoint=self.api_endpoint,
|
|
75
|
-
namespace=self.namespace or None,
|
|
76
|
-
environment=parse_api_endpoint(self.api_endpoint).environment,
|
|
77
|
-
)
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
from lfx.base.memory.model import LCChatMemoryComponent
|
|
2
|
-
from lfx.field_typing.constants import Memory
|
|
3
|
-
from lfx.inputs.inputs import DictInput, MessageTextInput, SecretStrInput
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class CassandraChatMemory(LCChatMemoryComponent):
|
|
7
|
-
display_name = "Cassandra Chat Memory"
|
|
8
|
-
description = "Retrieves and store chat messages from Apache Cassandra."
|
|
9
|
-
name = "CassandraChatMemory"
|
|
10
|
-
icon = "Cassandra"
|
|
11
|
-
|
|
12
|
-
inputs = [
|
|
13
|
-
MessageTextInput(
|
|
14
|
-
name="database_ref",
|
|
15
|
-
display_name="Contact Points / Astra Database ID",
|
|
16
|
-
info="Contact points for the database (or Astra DB database ID)",
|
|
17
|
-
required=True,
|
|
18
|
-
),
|
|
19
|
-
MessageTextInput(
|
|
20
|
-
name="username", display_name="Username", info="Username for the database (leave empty for Astra DB)."
|
|
21
|
-
),
|
|
22
|
-
SecretStrInput(
|
|
23
|
-
name="token",
|
|
24
|
-
display_name="Password / Astra DB Token",
|
|
25
|
-
info="User password for the database (or Astra DB token).",
|
|
26
|
-
required=True,
|
|
27
|
-
),
|
|
28
|
-
MessageTextInput(
|
|
29
|
-
name="keyspace",
|
|
30
|
-
display_name="Keyspace",
|
|
31
|
-
info="Table Keyspace (or Astra DB namespace).",
|
|
32
|
-
required=True,
|
|
33
|
-
),
|
|
34
|
-
MessageTextInput(
|
|
35
|
-
name="table_name",
|
|
36
|
-
display_name="Table Name",
|
|
37
|
-
info="The name of the table (or Astra DB collection) where vectors will be stored.",
|
|
38
|
-
required=True,
|
|
39
|
-
),
|
|
40
|
-
MessageTextInput(
|
|
41
|
-
name="session_id", display_name="Session ID", info="Session ID for the message.", advanced=True
|
|
42
|
-
),
|
|
43
|
-
DictInput(
|
|
44
|
-
name="cluster_kwargs",
|
|
45
|
-
display_name="Cluster arguments",
|
|
46
|
-
info="Optional dictionary of additional keyword arguments for the Cassandra cluster.",
|
|
47
|
-
advanced=True,
|
|
48
|
-
is_list=True,
|
|
49
|
-
),
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
def build_message_history(self) -> Memory:
|
|
53
|
-
from langchain_community.chat_message_histories import CassandraChatMessageHistory
|
|
54
|
-
|
|
55
|
-
try:
|
|
56
|
-
import cassio
|
|
57
|
-
except ImportError as e:
|
|
58
|
-
msg = "Could not import cassio integration package. Please install it with `pip install cassio`."
|
|
59
|
-
raise ImportError(msg) from e
|
|
60
|
-
|
|
61
|
-
from uuid import UUID
|
|
62
|
-
|
|
63
|
-
database_ref = self.database_ref
|
|
64
|
-
|
|
65
|
-
try:
|
|
66
|
-
UUID(self.database_ref)
|
|
67
|
-
is_astra = True
|
|
68
|
-
except ValueError:
|
|
69
|
-
is_astra = False
|
|
70
|
-
if "," in self.database_ref:
|
|
71
|
-
# use a copy because we can't change the type of the parameter
|
|
72
|
-
database_ref = self.database_ref.split(",")
|
|
73
|
-
|
|
74
|
-
if is_astra:
|
|
75
|
-
cassio.init(
|
|
76
|
-
database_id=database_ref,
|
|
77
|
-
token=self.token,
|
|
78
|
-
cluster_kwargs=self.cluster_kwargs,
|
|
79
|
-
)
|
|
80
|
-
else:
|
|
81
|
-
cassio.init(
|
|
82
|
-
contact_points=database_ref,
|
|
83
|
-
username=self.username,
|
|
84
|
-
password=self.token,
|
|
85
|
-
cluster_kwargs=self.cluster_kwargs,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
return CassandraChatMessageHistory(
|
|
89
|
-
session_id=self.session_id,
|
|
90
|
-
table_name=self.table_name,
|
|
91
|
-
keyspace=self.keyspace,
|
|
92
|
-
)
|
lfx/components/logic/run_flow.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from lfx.base.tools.run_flow import RunFlowBaseComponent
|
|
4
|
-
from lfx.helpers import run_flow
|
|
5
|
-
from lfx.log.logger import logger
|
|
6
|
-
from lfx.schema.dotdict import dotdict
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class RunFlowComponent(RunFlowBaseComponent):
|
|
10
|
-
display_name = "Run Flow"
|
|
11
|
-
description = (
|
|
12
|
-
"Creates a tool component from a Flow that takes all its inputs and runs it. "
|
|
13
|
-
" \n **Select a Flow to use the tool mode**"
|
|
14
|
-
)
|
|
15
|
-
documentation: str = "https://docs.langflow.org/components-logic#run-flow"
|
|
16
|
-
beta = True
|
|
17
|
-
name = "RunFlow"
|
|
18
|
-
icon = "Workflow"
|
|
19
|
-
|
|
20
|
-
inputs = RunFlowBaseComponent.get_base_inputs()
|
|
21
|
-
outputs = RunFlowBaseComponent.get_base_outputs()
|
|
22
|
-
|
|
23
|
-
async def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None):
|
|
24
|
-
if field_name == "flow_name_selected":
|
|
25
|
-
build_config["flow_name_selected"]["options"] = await self.get_flow_names()
|
|
26
|
-
missing_keys = [key for key in self.default_keys if key not in build_config]
|
|
27
|
-
if missing_keys:
|
|
28
|
-
msg = f"Missing required keys in build_config: {missing_keys}"
|
|
29
|
-
raise ValueError(msg)
|
|
30
|
-
if field_value is not None:
|
|
31
|
-
try:
|
|
32
|
-
graph = await self.get_graph(field_value)
|
|
33
|
-
build_config = self.update_build_config_from_graph(build_config, graph)
|
|
34
|
-
except Exception as e:
|
|
35
|
-
msg = f"Error building graph for flow {field_value}"
|
|
36
|
-
await logger.aexception(msg)
|
|
37
|
-
raise RuntimeError(msg) from e
|
|
38
|
-
return build_config
|
|
39
|
-
|
|
40
|
-
async def run_flow_with_tweaks(self):
|
|
41
|
-
tweaks: dict = {}
|
|
42
|
-
|
|
43
|
-
flow_name_selected = self._attributes.get("flow_name_selected")
|
|
44
|
-
parsed_flow_tweak_data = self._attributes.get("flow_tweak_data", {})
|
|
45
|
-
if not isinstance(parsed_flow_tweak_data, dict):
|
|
46
|
-
parsed_flow_tweak_data = parsed_flow_tweak_data.dict()
|
|
47
|
-
|
|
48
|
-
if parsed_flow_tweak_data != {}:
|
|
49
|
-
for field in parsed_flow_tweak_data:
|
|
50
|
-
if "~" in field:
|
|
51
|
-
[node, name] = field.split("~")
|
|
52
|
-
if node not in tweaks:
|
|
53
|
-
tweaks[node] = {}
|
|
54
|
-
tweaks[node][name] = parsed_flow_tweak_data[field]
|
|
55
|
-
else:
|
|
56
|
-
for field in self._attributes:
|
|
57
|
-
if field not in self.default_keys and "~" in field:
|
|
58
|
-
[node, name] = field.split("~")
|
|
59
|
-
if node not in tweaks:
|
|
60
|
-
tweaks[node] = {}
|
|
61
|
-
tweaks[node][name] = self._attributes[field]
|
|
62
|
-
|
|
63
|
-
return await run_flow(
|
|
64
|
-
inputs=None,
|
|
65
|
-
output_type="all",
|
|
66
|
-
flow_id=None,
|
|
67
|
-
flow_name=flow_name_selected,
|
|
68
|
-
tweaks=tweaks,
|
|
69
|
-
user_id=str(self.user_id),
|
|
70
|
-
session_id=self.graph.session_id or self.session_id,
|
|
71
|
-
)
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from langchain_openai import OpenAIEmbeddings
|
|
4
|
-
|
|
5
|
-
from lfx.base.embeddings.model import LCEmbeddingsModel
|
|
6
|
-
from lfx.base.models.openai_constants import OPENAI_EMBEDDING_MODEL_NAMES
|
|
7
|
-
from lfx.field_typing import Embeddings
|
|
8
|
-
from lfx.io import (
|
|
9
|
-
BoolInput,
|
|
10
|
-
DictInput,
|
|
11
|
-
DropdownInput,
|
|
12
|
-
FloatInput,
|
|
13
|
-
IntInput,
|
|
14
|
-
MessageTextInput,
|
|
15
|
-
SecretStrInput,
|
|
16
|
-
)
|
|
17
|
-
from lfx.schema.dotdict import dotdict
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class EmbeddingModelComponent(LCEmbeddingsModel):
|
|
21
|
-
display_name = "Embedding Model"
|
|
22
|
-
description = "Generate embeddings using a specified provider."
|
|
23
|
-
documentation: str = "https://docs.langflow.org/components-embedding-models"
|
|
24
|
-
icon = "binary"
|
|
25
|
-
name = "EmbeddingModel"
|
|
26
|
-
category = "models"
|
|
27
|
-
|
|
28
|
-
inputs = [
|
|
29
|
-
DropdownInput(
|
|
30
|
-
name="provider",
|
|
31
|
-
display_name="Model Provider",
|
|
32
|
-
options=["OpenAI"],
|
|
33
|
-
value="OpenAI",
|
|
34
|
-
info="Select the embedding model provider",
|
|
35
|
-
real_time_refresh=True,
|
|
36
|
-
options_metadata=[{"icon": "OpenAI"}],
|
|
37
|
-
),
|
|
38
|
-
DropdownInput(
|
|
39
|
-
name="model",
|
|
40
|
-
display_name="Model Name",
|
|
41
|
-
options=OPENAI_EMBEDDING_MODEL_NAMES,
|
|
42
|
-
value=OPENAI_EMBEDDING_MODEL_NAMES[0],
|
|
43
|
-
info="Select the embedding model to use",
|
|
44
|
-
),
|
|
45
|
-
SecretStrInput(
|
|
46
|
-
name="api_key",
|
|
47
|
-
display_name="OpenAI API Key",
|
|
48
|
-
info="Model Provider API key",
|
|
49
|
-
required=True,
|
|
50
|
-
show=True,
|
|
51
|
-
real_time_refresh=True,
|
|
52
|
-
),
|
|
53
|
-
MessageTextInput(
|
|
54
|
-
name="api_base",
|
|
55
|
-
display_name="API Base URL",
|
|
56
|
-
info="Base URL for the API. Leave empty for default.",
|
|
57
|
-
advanced=True,
|
|
58
|
-
),
|
|
59
|
-
IntInput(
|
|
60
|
-
name="dimensions",
|
|
61
|
-
display_name="Dimensions",
|
|
62
|
-
info="The number of dimensions the resulting output embeddings should have. "
|
|
63
|
-
"Only supported by certain models.",
|
|
64
|
-
advanced=True,
|
|
65
|
-
),
|
|
66
|
-
IntInput(name="chunk_size", display_name="Chunk Size", advanced=True, value=1000),
|
|
67
|
-
FloatInput(name="request_timeout", display_name="Request Timeout", advanced=True),
|
|
68
|
-
IntInput(name="max_retries", display_name="Max Retries", advanced=True, value=3),
|
|
69
|
-
BoolInput(name="show_progress_bar", display_name="Show Progress Bar", advanced=True),
|
|
70
|
-
DictInput(
|
|
71
|
-
name="model_kwargs",
|
|
72
|
-
display_name="Model Kwargs",
|
|
73
|
-
advanced=True,
|
|
74
|
-
info="Additional keyword arguments to pass to the model.",
|
|
75
|
-
),
|
|
76
|
-
]
|
|
77
|
-
|
|
78
|
-
def build_embeddings(self) -> Embeddings:
|
|
79
|
-
provider = self.provider
|
|
80
|
-
model = self.model
|
|
81
|
-
api_key = self.api_key
|
|
82
|
-
api_base = self.api_base
|
|
83
|
-
dimensions = self.dimensions
|
|
84
|
-
chunk_size = self.chunk_size
|
|
85
|
-
request_timeout = self.request_timeout
|
|
86
|
-
max_retries = self.max_retries
|
|
87
|
-
show_progress_bar = self.show_progress_bar
|
|
88
|
-
model_kwargs = self.model_kwargs or {}
|
|
89
|
-
|
|
90
|
-
if provider == "OpenAI":
|
|
91
|
-
if not api_key:
|
|
92
|
-
msg = "OpenAI API key is required when using OpenAI provider"
|
|
93
|
-
raise ValueError(msg)
|
|
94
|
-
return OpenAIEmbeddings(
|
|
95
|
-
model=model,
|
|
96
|
-
dimensions=dimensions or None,
|
|
97
|
-
base_url=api_base or None,
|
|
98
|
-
api_key=api_key,
|
|
99
|
-
chunk_size=chunk_size,
|
|
100
|
-
max_retries=max_retries,
|
|
101
|
-
timeout=request_timeout or None,
|
|
102
|
-
show_progress_bar=show_progress_bar,
|
|
103
|
-
model_kwargs=model_kwargs,
|
|
104
|
-
)
|
|
105
|
-
msg = f"Unknown provider: {provider}"
|
|
106
|
-
raise ValueError(msg)
|
|
107
|
-
|
|
108
|
-
def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:
|
|
109
|
-
if field_name == "provider" and field_value == "OpenAI":
|
|
110
|
-
build_config["model"]["options"] = OPENAI_EMBEDDING_MODEL_NAMES
|
|
111
|
-
build_config["model"]["value"] = OPENAI_EMBEDDING_MODEL_NAMES[0]
|
|
112
|
-
build_config["api_key"]["display_name"] = "OpenAI API Key"
|
|
113
|
-
build_config["api_base"]["display_name"] = "OpenAI API Base URL"
|
|
114
|
-
return build_config
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from langchain_anthropic import ChatAnthropic
|
|
4
|
-
from langchain_openai import ChatOpenAI
|
|
5
|
-
|
|
6
|
-
from lfx.base.models.anthropic_constants import ANTHROPIC_MODELS
|
|
7
|
-
from lfx.base.models.google_generative_ai_constants import GOOGLE_GENERATIVE_AI_MODELS
|
|
8
|
-
from lfx.base.models.google_generative_ai_model import ChatGoogleGenerativeAIFixed
|
|
9
|
-
from lfx.base.models.model import LCModelComponent
|
|
10
|
-
from lfx.base.models.openai_constants import OPENAI_CHAT_MODEL_NAMES, OPENAI_REASONING_MODEL_NAMES
|
|
11
|
-
from lfx.field_typing import LanguageModel
|
|
12
|
-
from lfx.field_typing.range_spec import RangeSpec
|
|
13
|
-
from lfx.inputs.inputs import BoolInput
|
|
14
|
-
from lfx.io import DropdownInput, MessageInput, MultilineInput, SecretStrInput, SliderInput
|
|
15
|
-
from lfx.schema.dotdict import dotdict
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class LanguageModelComponent(LCModelComponent):
|
|
19
|
-
display_name = "Language Model"
|
|
20
|
-
description = "Runs a language model given a specified provider."
|
|
21
|
-
documentation: str = "https://docs.langflow.org/components-models"
|
|
22
|
-
icon = "brain-circuit"
|
|
23
|
-
category = "models"
|
|
24
|
-
priority = 0 # Set priority to 0 to make it appear first
|
|
25
|
-
|
|
26
|
-
inputs = [
|
|
27
|
-
DropdownInput(
|
|
28
|
-
name="provider",
|
|
29
|
-
display_name="Model Provider",
|
|
30
|
-
options=["OpenAI", "Anthropic", "Google"],
|
|
31
|
-
value="OpenAI",
|
|
32
|
-
info="Select the model provider",
|
|
33
|
-
real_time_refresh=True,
|
|
34
|
-
options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}],
|
|
35
|
-
),
|
|
36
|
-
DropdownInput(
|
|
37
|
-
name="model_name",
|
|
38
|
-
display_name="Model Name",
|
|
39
|
-
options=OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES,
|
|
40
|
-
value=OPENAI_CHAT_MODEL_NAMES[0],
|
|
41
|
-
info="Select the model to use",
|
|
42
|
-
real_time_refresh=True,
|
|
43
|
-
),
|
|
44
|
-
SecretStrInput(
|
|
45
|
-
name="api_key",
|
|
46
|
-
display_name="OpenAI API Key",
|
|
47
|
-
info="Model Provider API key",
|
|
48
|
-
required=False,
|
|
49
|
-
show=True,
|
|
50
|
-
real_time_refresh=True,
|
|
51
|
-
),
|
|
52
|
-
MessageInput(
|
|
53
|
-
name="input_value",
|
|
54
|
-
display_name="Input",
|
|
55
|
-
info="The input text to send to the model",
|
|
56
|
-
),
|
|
57
|
-
MultilineInput(
|
|
58
|
-
name="system_message",
|
|
59
|
-
display_name="System Message",
|
|
60
|
-
info="A system message that helps set the behavior of the assistant",
|
|
61
|
-
advanced=False,
|
|
62
|
-
),
|
|
63
|
-
BoolInput(
|
|
64
|
-
name="stream",
|
|
65
|
-
display_name="Stream",
|
|
66
|
-
info="Whether to stream the response",
|
|
67
|
-
value=False,
|
|
68
|
-
advanced=True,
|
|
69
|
-
),
|
|
70
|
-
SliderInput(
|
|
71
|
-
name="temperature",
|
|
72
|
-
display_name="Temperature",
|
|
73
|
-
value=0.1,
|
|
74
|
-
info="Controls randomness in responses",
|
|
75
|
-
range_spec=RangeSpec(min=0, max=1, step=0.01),
|
|
76
|
-
advanced=True,
|
|
77
|
-
),
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
def build_model(self) -> LanguageModel:
|
|
81
|
-
provider = self.provider
|
|
82
|
-
model_name = self.model_name
|
|
83
|
-
temperature = self.temperature
|
|
84
|
-
stream = self.stream
|
|
85
|
-
|
|
86
|
-
if provider == "OpenAI":
|
|
87
|
-
if not self.api_key:
|
|
88
|
-
msg = "OpenAI API key is required when using OpenAI provider"
|
|
89
|
-
raise ValueError(msg)
|
|
90
|
-
|
|
91
|
-
if model_name in OPENAI_REASONING_MODEL_NAMES:
|
|
92
|
-
# reasoning models do not support temperature (yet)
|
|
93
|
-
temperature = None
|
|
94
|
-
|
|
95
|
-
return ChatOpenAI(
|
|
96
|
-
model_name=model_name,
|
|
97
|
-
temperature=temperature,
|
|
98
|
-
streaming=stream,
|
|
99
|
-
openai_api_key=self.api_key,
|
|
100
|
-
)
|
|
101
|
-
if provider == "Anthropic":
|
|
102
|
-
if not self.api_key:
|
|
103
|
-
msg = "Anthropic API key is required when using Anthropic provider"
|
|
104
|
-
raise ValueError(msg)
|
|
105
|
-
return ChatAnthropic(
|
|
106
|
-
model=model_name,
|
|
107
|
-
temperature=temperature,
|
|
108
|
-
streaming=stream,
|
|
109
|
-
anthropic_api_key=self.api_key,
|
|
110
|
-
)
|
|
111
|
-
if provider == "Google":
|
|
112
|
-
if not self.api_key:
|
|
113
|
-
msg = "Google API key is required when using Google provider"
|
|
114
|
-
raise ValueError(msg)
|
|
115
|
-
return ChatGoogleGenerativeAIFixed(
|
|
116
|
-
model=model_name,
|
|
117
|
-
temperature=temperature,
|
|
118
|
-
streaming=stream,
|
|
119
|
-
google_api_key=self.api_key,
|
|
120
|
-
)
|
|
121
|
-
msg = f"Unknown provider: {provider}"
|
|
122
|
-
raise ValueError(msg)
|
|
123
|
-
|
|
124
|
-
def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:
|
|
125
|
-
if field_name == "provider":
|
|
126
|
-
if field_value == "OpenAI":
|
|
127
|
-
build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES
|
|
128
|
-
build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0]
|
|
129
|
-
build_config["api_key"]["display_name"] = "OpenAI API Key"
|
|
130
|
-
elif field_value == "Anthropic":
|
|
131
|
-
build_config["model_name"]["options"] = ANTHROPIC_MODELS
|
|
132
|
-
build_config["model_name"]["value"] = ANTHROPIC_MODELS[0]
|
|
133
|
-
build_config["api_key"]["display_name"] = "Anthropic API Key"
|
|
134
|
-
elif field_value == "Google":
|
|
135
|
-
build_config["model_name"]["options"] = GOOGLE_GENERATIVE_AI_MODELS
|
|
136
|
-
build_config["model_name"]["value"] = GOOGLE_GENERATIVE_AI_MODELS[0]
|
|
137
|
-
build_config["api_key"]["display_name"] = "Google API Key"
|
|
138
|
-
elif field_name == "model_name" and field_value.startswith("o1") and self.provider == "OpenAI":
|
|
139
|
-
# Hide system_message for o1 models - currently unsupported
|
|
140
|
-
if "system_message" in build_config:
|
|
141
|
-
build_config["system_message"]["show"] = False
|
|
142
|
-
elif field_name == "model_name" and not field_value.startswith("o1") and "system_message" in build_config:
|
|
143
|
-
build_config["system_message"]["show"] = True
|
|
144
|
-
return build_config
|