langflow-base-nightly 0.5.0.dev10__py3-none-any.whl → 0.5.0.dev12__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.
- langflow/base/models/openai_constants.py +5 -3
- langflow/components/agents/agent.py +61 -4
- langflow/custom/utils.py +49 -3
- langflow/frontend/assets/{SlackIcon-BEQsp2tG.js → SlackIcon-Cd-iPC0i.js} +1 -1
- langflow/frontend/assets/{Wikipedia-CylSh2Rz.js → Wikipedia-B5O6n7F0.js} +1 -1
- langflow/frontend/assets/{Wolfram-BbLCNQCI.js → Wolfram-B1KmVRjM.js} +1 -1
- langflow/frontend/assets/{index-DyIpqQ6u.js → index-3mCR-Tl2.js} +1 -1
- langflow/frontend/assets/{index-CTIjE6ec.js → index-6yw70teP.js} +1 -1
- langflow/frontend/assets/{index-BorUWqkM.js → index-7fK3jqXA.js} +1 -1
- langflow/frontend/assets/{index-ZHQE-way.js → index-8w8XYprB.js} +1 -1
- langflow/frontend/assets/{index-CSe6UjxV.js → index-B0JZGX06.js} +1 -1
- langflow/frontend/assets/{index-lJ1V4apH.js → index-B2CCM4c7.js} +1 -1
- langflow/frontend/assets/{index-CdPp99Ov.js → index-B2Z_1lFD.js} +1 -1
- langflow/frontend/assets/{index-DysqOh2v.js → index-B7FkNOyn.js} +1 -1
- langflow/frontend/assets/{index-B1yGg3ui.js → index-BA1jLhEh.js} +31 -31
- langflow/frontend/assets/{index-N3NiikE-.js → index-BBX2kVSz.js} +1 -1
- langflow/frontend/assets/{index-DOZ4j-co.js → index-BBgfRNJR.js} +1 -1
- langflow/frontend/assets/{index-C9dL6qYU.js → index-BDFdZay1.js} +1 -1
- langflow/frontend/assets/{index-BsVHbutF.js → index-BDro7umg.js} +1 -1
- langflow/frontend/assets/{index-CDN9FxX3.js → index-BK6HLE9w.js} +1 -1
- langflow/frontend/assets/{index-TUSpXwVe.js → index-BLbBvwMG.js} +1 -1
- langflow/frontend/assets/{index-_AhGSFEp.js → index-BNWrL3Nq.js} +1 -1
- langflow/frontend/assets/{index-BUepyNwR.js → index-BOI0y4_3.js} +1 -1
- langflow/frontend/assets/{index-DufevlPT.js → index-BOT3JtBi.js} +1 -1
- langflow/frontend/assets/{index-cOLi_68F.js → index-BPJt8Ile.js} +1 -1
- langflow/frontend/assets/{index-Yrff3uIT.js → index-BPlGsMrz.js} +1 -1
- langflow/frontend/assets/{index-O3c1ky7v.js → index-BSMo_rVR.js} +1 -1
- langflow/frontend/assets/{index-DEwfBIGT.js → index-BUP8cpdy.js} +1 -1
- langflow/frontend/assets/{index-KcUnsxlf.js → index-BUfHQ67-.js} +1 -1
- langflow/frontend/assets/{index-Buf0FLlA.js → index-BWns2-go.js} +1 -1
- langflow/frontend/assets/{index-Bki1gbZ4.js → index-BXIyV5lK.js} +1 -1
- langflow/frontend/assets/{index-BSZfrTzR.js → index-BZkwz56n.js} +1 -1
- langflow/frontend/assets/{index-CoAX4KHA.js → index-BaSBldE9.js} +1 -1
- langflow/frontend/assets/{index-Br2kJx5F.js → index-Bf8t8j9X.js} +1 -1
- langflow/frontend/assets/{index-5ls6VK_c.js → index-BfYTMI38.js} +1 -1
- langflow/frontend/assets/{index-gsz-bhOF.js → index-BhR1ql7g.js} +1 -1
- langflow/frontend/assets/{index-C2fMifvM.js → index-BiYFSEAn.js} +1 -1
- langflow/frontend/assets/{index-D_AWHRfe.js → index-Bk6ndAzQ.js} +1 -1
- langflow/frontend/assets/{index-BDASu5_h.js → index-BlL8HUNA.js} +1 -1
- langflow/frontend/assets/{index-dg4h4aV9.js → index-BlPey1Ki.js} +1 -1
- langflow/frontend/assets/{index-B61eUMTR.js → index-BsMrsX7Y.js} +1 -1
- langflow/frontend/assets/{index-ArQPJTY-.js → index-Bt6jcZAU.js} +1 -1
- langflow/frontend/assets/{index-kjgyrJKk.js → index-ByKS3Reb.js} +1 -1
- langflow/frontend/assets/{index--afKjQV4.js → index-C0rt4CxC.js} +1 -1
- langflow/frontend/assets/{index-DvZ2dP1K.js → index-C1ubG8J7.js} +1 -1
- langflow/frontend/assets/{index-DgghztJk.js → index-C2eoNYzo.js} +1 -1
- langflow/frontend/assets/{index-Bxa7Zqaq.js → index-C7FLVNCj.js} +1 -1
- langflow/frontend/assets/{index-DNOP-INQ.js → index-C8p_It-q.js} +1 -1
- langflow/frontend/assets/{index-DZ4RRuo1.js → index-C9fRGeXM.js} +1 -1
- langflow/frontend/assets/{index-CdaKd40h.js → index-CBWFia1e.js} +1 -1
- langflow/frontend/assets/{index-HbhXQ4iI.js → index-CCTmOZ1g.js} +1 -1
- langflow/frontend/assets/{index-Dj6hJobz.js → index-CDtWHxP4.js} +1 -1
- langflow/frontend/assets/{index-CtzhOjCJ.js → index-CFEOHn80.js} +1 -1
- langflow/frontend/assets/{index-CogD177T.js → index-CJ1toud0.js} +1 -1
- langflow/frontend/assets/{index-CEau7eX7.js → index-CQ51i8ln.js} +1 -1
- langflow/frontend/assets/{index-C_H9PvPC.js → index-CR-CAff6.js} +1 -1
- langflow/frontend/assets/{index-BCodFIaO.js → index-CUrntRcy.js} +1 -1
- langflow/frontend/assets/{index-lp0TR1VG.js → index-CXFub5LB.js} +1 -1
- langflow/frontend/assets/{index-ChyV4bY1.js → index-CaWlxCMX.js} +1 -1
- langflow/frontend/assets/{index-ZPrp_qyL.js → index-CcLzwnrn.js} +1 -1
- langflow/frontend/assets/{index-Dgtl-Ryc.js → index-CdiZnmSW.js} +1 -1
- langflow/frontend/assets/{index-DzFPLySG.js → index-CdmrGwb4.js} +1 -1
- langflow/frontend/assets/{index-DCNa4h3y.js → index-Ch3GcMU1.js} +1 -1
- langflow/frontend/assets/{index-Cqc93Aww.js → index-CiyaGz0z.js} +1 -1
- langflow/frontend/assets/{index-BnRJS1jE.js → index-Cjhx7z0R.js} +1 -1
- langflow/frontend/assets/{index-CBGa-ML1.js → index-CjtaM5UL.js} +1 -1
- langflow/frontend/assets/{index-fU437Xuh.js → index-Cnyx1zv_.js} +1 -1
- langflow/frontend/assets/{index-CmSCL35l.js → index-Cq-gdL8y.js} +1 -1
- langflow/frontend/assets/{index-B7gZiD-W.js → index-Cq4MI2y5.js} +1 -1
- langflow/frontend/assets/{index-BRLJm4Du.js → index-Cw37ANcv.js} +1 -1
- langflow/frontend/assets/{index-k9UFhzxg.js → index-CwWRSdlX.js} +1 -1
- langflow/frontend/assets/{index-GF2LJgkR.js → index-Cx7TvKYK.js} +1 -1
- langflow/frontend/assets/{index-B2VOPfSQ.js → index-CxVYbglb.js} +1 -1
- langflow/frontend/assets/{index-DYwMDNLL.js → index-Czcvxutv.js} +1 -1
- langflow/frontend/assets/{index-GUM5ctOD.js → index-D-49kYTz.js} +1 -1
- langflow/frontend/assets/{index-DtjOwLQC.js → index-D4RRUGPu.js} +1 -1
- langflow/frontend/assets/{index-H15pIDqA.js → index-D5PS_CB4.js} +1 -1
- langflow/frontend/assets/{index-pwj4p8sb.js → index-D7g4wvHP.js} +1 -1
- langflow/frontend/assets/{index-DGV6oDTb.js → index-D7jQaHFe.js} +1 -1
- langflow/frontend/assets/{index-CJ5EUvrn.js → index-D9-bSYSJ.js} +1 -1
- langflow/frontend/assets/{index-DJzLRh66.js → index-DB5GTOxo.js} +1 -1
- langflow/frontend/assets/{index-DpMb4SyP.js → index-DD5XYrer.js} +1 -1
- langflow/frontend/assets/{index-BwWOFcx9.js → index-DGxSiTMA.js} +1 -1
- langflow/frontend/assets/{index-DXMYOwee.js → index-DH7MmlxY.js} +1 -1
- langflow/frontend/assets/{index-C9KrGJ67.js → index-DH__etxq.js} +1 -1
- langflow/frontend/assets/{index-DLoNvjqt.js → index-DIO5INGs.js} +1 -1
- langflow/frontend/assets/{index-DjNRiQay.js → index-DIacckva.js} +1 -1
- langflow/frontend/assets/{index-B5S9h8ok.js → index-DQk0_I5B.js} +1 -1
- langflow/frontend/assets/{index-C9ZDIZFW.js → index-DU2YH66I.js} +1 -1
- langflow/frontend/assets/{index-UVKuDcRW.js → index-DXGN9orR.js} +1 -1
- langflow/frontend/assets/{index-CDDBjrKl.js → index-DYEuD_-s.js} +1 -1
- langflow/frontend/assets/{index-CBOYVi1U.js → index-DYTJUdhK.js} +1 -1
- langflow/frontend/assets/{index-C3Bj4_FP.js → index-DcKifWWJ.js} +1 -1
- langflow/frontend/assets/{index-Dgd8GGgG.js → index-DdZkgdvz.js} +1 -1
- langflow/frontend/assets/{index-DaosAMPL.js → index-DeYteZja.js} +1 -1
- langflow/frontend/assets/{index-Vx9vra5E.js → index-DgfNw4kh.js} +1 -1
- langflow/frontend/assets/{index-CbN90tiv.js → index-Djj7W9O2.js} +1 -1
- langflow/frontend/assets/{index-Bpv14pFu.js → index-DjsYYwW0.js} +1 -1
- langflow/frontend/assets/{index-D8nmnanz.js → index-DkBWSKtg.js} +1 -1
- langflow/frontend/assets/{index-BlSZbUqf.js → index-DnC_DVAY.js} +1 -1
- langflow/frontend/assets/{index-Q0Ex46_F.js → index-DqdLKSt1.js} +1 -1
- langflow/frontend/assets/{index-D6qchtKo.js → index-DvvsljHV.js} +1 -1
- langflow/frontend/assets/{index-Bhm1dylP.js → index-DwRUBFIA.js} +1 -1
- langflow/frontend/assets/{index-DiYhK7Hs.js → index-DymMkWXl.js} +1 -1
- langflow/frontend/assets/{index-p77FDSRr.js → index-E-Das2ND.js} +1 -1
- langflow/frontend/assets/{index-BxPGc9G_.js → index-IS7u-AWK.js} +1 -1
- langflow/frontend/assets/{index-BtXZCxsi.js → index-JmqTXg4E.js} +1 -1
- langflow/frontend/assets/{index-ChPNbgSb.js → index-Mxd-VEGG.js} +1 -1
- langflow/frontend/assets/{index-BymhxBmN.js → index-NiPHCs9R.js} +1 -1
- langflow/frontend/assets/{index-uxytSC6u.js → index-Njr5X1kT.js} +1 -1
- langflow/frontend/assets/{index-gnvplQfi.js → index-OE--aySz.js} +1 -1
- langflow/frontend/assets/{index-DKho7fub.js → index-TPkBqDKK.js} +1 -1
- langflow/frontend/assets/{index-DeMmL8Mo.js → index-WV_k1wNl.js} +1 -1
- langflow/frontend/assets/{index-DYj_t4sx.js → index-WyGaeQRK.js} +1 -1
- langflow/frontend/assets/{index-DcTv_MVV.js → index-ZFy5V-_D.js} +1 -1
- langflow/frontend/assets/{index-BjcscQOG.js → index-Zl1mc460.js} +1 -1
- langflow/frontend/assets/{index-CcS86fAH.js → index-ag1C0oAb.js} +1 -1
- langflow/frontend/assets/{index-D38ii1eC.js → index-ar9TCMv3.js} +1 -1
- langflow/frontend/assets/{index-D2K8Dxca.js → index-ci6Tgpk-.js} +1 -1
- langflow/frontend/assets/{index-BTPSO7Ty.js → index-ijhn48uz.js} +1 -1
- langflow/frontend/assets/{index-D6iJ0ixS.js → index-pVelLfiC.js} +1 -1
- langflow/frontend/assets/{index-CmPIFu12.js → index-trtHEGn4.js} +1 -1
- langflow/frontend/assets/{index-YXNg_MqK.js → index-vf00qo3y.js} +1 -1
- langflow/frontend/assets/{index-DFckK5jC.js → index-wlS4KkAL.js} +1 -1
- langflow/frontend/assets/{index-DmZZmu5_.js → index-yltn8z-g.js} +1 -1
- langflow/frontend/assets/lazyIconImports-CyCY07be.js +2 -0
- langflow/frontend/assets/{use-post-add-user-CNxc7cHz.js → use-post-add-user-C6MTbdJe.js} +1 -1
- langflow/frontend/index.html +1 -1
- langflow/initial_setup/starter_projects/Basic Prompt Chaining.json +8 -2
- langflow/initial_setup/starter_projects/Basic Prompting.json +12 -3
- langflow/initial_setup/starter_projects/Blog Writer.json +20 -5
- langflow/initial_setup/starter_projects/Custom Component Generator.json +16 -4
- langflow/initial_setup/starter_projects/Document Q&A.json +16 -4
- langflow/initial_setup/starter_projects/Financial Report Parser.json +12 -3
- langflow/initial_setup/starter_projects/Hybrid Search RAG.json +24 -6
- langflow/initial_setup/starter_projects/Image Sentiment Analysis.json +16 -4
- langflow/initial_setup/starter_projects/Instagram Copywriter.json +175 -107
- langflow/initial_setup/starter_projects/Invoice Summarizer.json +17 -5
- langflow/initial_setup/starter_projects/Market Research.json +17 -5
- langflow/initial_setup/starter_projects/Meeting Summary.json +36 -9
- langflow/initial_setup/starter_projects/Memory Chatbot.json +16 -4
- langflow/initial_setup/starter_projects/News Aggregator.json +17 -5
- langflow/initial_setup/starter_projects/Nvidia Remix.json +21 -6
- langflow/initial_setup/starter_projects/Pok/303/251dex Agent.json" +13 -4
- langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json +12 -3
- langflow/initial_setup/starter_projects/Price Deal Finder.json +17 -5
- langflow/initial_setup/starter_projects/Research Agent.json +29 -8
- langflow/initial_setup/starter_projects/Research Translation Loop.json +24 -6
- langflow/initial_setup/starter_projects/SEO Keyword Generator.json +12 -3
- langflow/initial_setup/starter_projects/SaaS Pricing.json +13 -4
- langflow/initial_setup/starter_projects/Search agent.json +13 -4
- langflow/initial_setup/starter_projects/Sequential Tasks Agents.json +35 -11
- langflow/initial_setup/starter_projects/Simple Agent.json +17 -5
- langflow/initial_setup/starter_projects/Social Media Agent.json +17 -5
- langflow/initial_setup/starter_projects/Text Sentiment Analysis.json +12 -3
- langflow/initial_setup/starter_projects/Travel Planning Agents.json +19 -7
- langflow/initial_setup/starter_projects/Twitter Thread Generator.json +36 -9
- langflow/initial_setup/starter_projects/Vector Store RAG.json +33 -9
- langflow/initial_setup/starter_projects/Youtube Analysis.json +21 -6
- langflow/interface/components.py +32 -16
- {langflow_base_nightly-0.5.0.dev10.dist-info → langflow_base_nightly-0.5.0.dev12.dist-info}/METADATA +1 -1
- {langflow_base_nightly-0.5.0.dev10.dist-info → langflow_base_nightly-0.5.0.dev12.dist-info}/RECORD +164 -164
- langflow/frontend/assets/lazyIconImports-B2rERpGa.js +0 -2
- {langflow_base_nightly-0.5.0.dev10.dist-info → langflow_base_nightly-0.5.0.dev12.dist-info}/WHEEL +0 -0
- {langflow_base_nightly-0.5.0.dev10.dist-info → langflow_base_nightly-0.5.0.dev12.dist-info}/entry_points.txt +0 -0
|
@@ -8,7 +8,9 @@ OPENAI_MODELS_DETAILED = [
|
|
|
8
8
|
create_model_metadata(provider="OpenAI", name="gpt-4.1", icon="OpenAI", tool_calling=True),
|
|
9
9
|
create_model_metadata(provider="OpenAI", name="gpt-4.1-mini", icon="OpenAI", tool_calling=True),
|
|
10
10
|
create_model_metadata(provider="OpenAI", name="gpt-4.1-nano", icon="OpenAI", tool_calling=True),
|
|
11
|
-
create_model_metadata(
|
|
11
|
+
create_model_metadata(
|
|
12
|
+
provider="OpenAI", name="gpt-4.5-preview", icon="OpenAI", tool_calling=True, preview=True, not_supported=True
|
|
13
|
+
),
|
|
12
14
|
create_model_metadata(provider="OpenAI", name="gpt-4-turbo", icon="OpenAI", tool_calling=True),
|
|
13
15
|
create_model_metadata(
|
|
14
16
|
provider="OpenAI", name="gpt-4-turbo-preview", icon="OpenAI", tool_calling=True, preview=True
|
|
@@ -17,8 +19,8 @@ OPENAI_MODELS_DETAILED = [
|
|
|
17
19
|
create_model_metadata(provider="OpenAI", name="gpt-3.5-turbo", icon="OpenAI", tool_calling=True),
|
|
18
20
|
# Reasoning Models
|
|
19
21
|
create_model_metadata(provider="OpenAI", name="o1", icon="OpenAI", reasoning=True),
|
|
20
|
-
create_model_metadata(provider="OpenAI", name="o1-mini", icon="OpenAI", reasoning=True),
|
|
21
|
-
create_model_metadata(provider="OpenAI", name="o1-pro", icon="OpenAI", reasoning=True),
|
|
22
|
+
create_model_metadata(provider="OpenAI", name="o1-mini", icon="OpenAI", reasoning=True, not_supported=True),
|
|
23
|
+
create_model_metadata(provider="OpenAI", name="o1-pro", icon="OpenAI", reasoning=True, not_supported=True),
|
|
22
24
|
create_model_metadata(provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True),
|
|
23
25
|
create_model_metadata(provider="OpenAI", name="o3", icon="OpenAI", reasoning=True),
|
|
24
26
|
create_model_metadata(provider="OpenAI", name="o3-pro", icon="OpenAI", reasoning=True),
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
|
|
1
4
|
from langchain_core.tools import StructuredTool
|
|
2
5
|
|
|
3
6
|
from langflow.base.agents.agent import LCToolsAgentComponent
|
|
@@ -18,6 +21,7 @@ from langflow.custom.utils import update_component_build_config
|
|
|
18
21
|
from langflow.field_typing import Tool
|
|
19
22
|
from langflow.io import BoolInput, DropdownInput, IntInput, MultilineInput, Output
|
|
20
23
|
from langflow.logging import logger
|
|
24
|
+
from langflow.schema.data import Data
|
|
21
25
|
from langflow.schema.dotdict import dotdict
|
|
22
26
|
from langflow.schema.message import Message
|
|
23
27
|
|
|
@@ -40,6 +44,13 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
40
44
|
|
|
41
45
|
memory_inputs = [set_advanced_true(component_input) for component_input in MemoryComponent().inputs]
|
|
42
46
|
|
|
47
|
+
# Filter out json_mode from OpenAI inputs since we handle structured output differently
|
|
48
|
+
openai_inputs_filtered = [
|
|
49
|
+
input_field
|
|
50
|
+
for input_field in MODEL_PROVIDERS_DICT["OpenAI"]["inputs"]
|
|
51
|
+
if not (hasattr(input_field, "name") and input_field.name == "json_mode")
|
|
52
|
+
]
|
|
53
|
+
|
|
43
54
|
inputs = [
|
|
44
55
|
DropdownInput(
|
|
45
56
|
name="agent_llm",
|
|
@@ -51,7 +62,7 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
51
62
|
input_types=[],
|
|
52
63
|
options_metadata=[MODELS_METADATA[key] for key in MODEL_PROVIDERS_LIST] + [{"icon": "brain"}],
|
|
53
64
|
),
|
|
54
|
-
*
|
|
65
|
+
*openai_inputs_filtered,
|
|
55
66
|
MultilineInput(
|
|
56
67
|
name="system_prompt",
|
|
57
68
|
display_name="Agent Instructions",
|
|
@@ -78,7 +89,10 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
78
89
|
value=True,
|
|
79
90
|
),
|
|
80
91
|
]
|
|
81
|
-
outputs = [
|
|
92
|
+
outputs = [
|
|
93
|
+
Output(name="response", display_name="Response", method="message_response"),
|
|
94
|
+
Output(name="structured_response", display_name="Structured Response", method="json_response", tool_mode=False),
|
|
95
|
+
]
|
|
82
96
|
|
|
83
97
|
async def message_response(self) -> Message:
|
|
84
98
|
try:
|
|
@@ -114,7 +128,11 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
114
128
|
system_prompt=self.system_prompt,
|
|
115
129
|
)
|
|
116
130
|
agent = self.create_agent_runnable()
|
|
117
|
-
|
|
131
|
+
result = await self.run_agent(agent)
|
|
132
|
+
|
|
133
|
+
# Store result for potential JSON output
|
|
134
|
+
self._agent_result = result
|
|
135
|
+
# return result
|
|
118
136
|
|
|
119
137
|
except (ValueError, TypeError, KeyError) as e:
|
|
120
138
|
logger.error(f"{type(e).__name__}: {e!s}")
|
|
@@ -125,6 +143,41 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
125
143
|
except Exception as e:
|
|
126
144
|
logger.error(f"Unexpected error: {e!s}")
|
|
127
145
|
raise
|
|
146
|
+
else:
|
|
147
|
+
return result
|
|
148
|
+
|
|
149
|
+
async def json_response(self) -> Data:
|
|
150
|
+
"""Convert agent response to structured JSON Data output."""
|
|
151
|
+
# Run the regular message response first to get the result
|
|
152
|
+
if not hasattr(self, "_agent_result"):
|
|
153
|
+
await self.message_response()
|
|
154
|
+
|
|
155
|
+
result = self._agent_result
|
|
156
|
+
|
|
157
|
+
# Extract content from result
|
|
158
|
+
if hasattr(result, "content"):
|
|
159
|
+
content = result.content
|
|
160
|
+
elif hasattr(result, "text"):
|
|
161
|
+
content = result.text
|
|
162
|
+
else:
|
|
163
|
+
content = str(result)
|
|
164
|
+
|
|
165
|
+
# Try to parse as JSON
|
|
166
|
+
try:
|
|
167
|
+
json_data = json.loads(content)
|
|
168
|
+
return Data(data=json_data)
|
|
169
|
+
except json.JSONDecodeError:
|
|
170
|
+
# If it's not valid JSON, try to extract JSON from the content
|
|
171
|
+
json_match = re.search(r"\{.*\}", content, re.DOTALL)
|
|
172
|
+
if json_match:
|
|
173
|
+
try:
|
|
174
|
+
json_data = json.loads(json_match.group())
|
|
175
|
+
return Data(data=json_data)
|
|
176
|
+
except json.JSONDecodeError:
|
|
177
|
+
pass
|
|
178
|
+
|
|
179
|
+
# If we can't extract JSON, return the raw content as data
|
|
180
|
+
return Data(data={"content": content, "error": "Could not parse as JSON"})
|
|
128
181
|
|
|
129
182
|
async def get_memory_data(self):
|
|
130
183
|
# TODO: This is a temporary fix to avoid message duplication. We should develop a function for this.
|
|
@@ -171,7 +224,11 @@ class AgentComponent(ToolCallingAgentComponent):
|
|
|
171
224
|
if provider_info:
|
|
172
225
|
inputs = provider_info.get("inputs")
|
|
173
226
|
prefix = provider_info.get("prefix")
|
|
174
|
-
|
|
227
|
+
# Filter out json_mode and only use attributes that exist on this component
|
|
228
|
+
model_kwargs = {}
|
|
229
|
+
for input_ in inputs:
|
|
230
|
+
if hasattr(self, f"{prefix}{input_.name}"):
|
|
231
|
+
model_kwargs[input_.name] = getattr(self, f"{prefix}{input_.name}")
|
|
175
232
|
|
|
176
233
|
return component.set(**model_kwargs)
|
|
177
234
|
return component
|
langflow/custom/utils.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import ast
|
|
3
3
|
import asyncio
|
|
4
4
|
import contextlib
|
|
5
|
+
import hashlib
|
|
5
6
|
import inspect
|
|
6
7
|
import re
|
|
7
8
|
import traceback
|
|
@@ -32,6 +33,30 @@ from langflow.utils import validate
|
|
|
32
33
|
from langflow.utils.util import get_base_classes
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
def _generate_code_hash(source_code: str, modname: str, class_name: str) -> str:
|
|
37
|
+
"""Generate a hash of the component source code.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
source_code: The source code string
|
|
41
|
+
modname: The module name for context
|
|
42
|
+
class_name: The class name for context
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
SHA256 hash of the source code
|
|
46
|
+
|
|
47
|
+
Raises:
|
|
48
|
+
ValueError: If source_code is empty or None
|
|
49
|
+
UnicodeEncodeError: If source_code cannot be encoded
|
|
50
|
+
TypeError: If source_code is not a string
|
|
51
|
+
"""
|
|
52
|
+
if not source_code:
|
|
53
|
+
msg = f"Empty source code for {class_name} in {modname}"
|
|
54
|
+
raise ValueError(msg)
|
|
55
|
+
|
|
56
|
+
# Generate SHA256 hash of the source code
|
|
57
|
+
return hashlib.sha256(source_code.encode("utf-8")).hexdigest()[:12] # First 12 chars for brevity
|
|
58
|
+
|
|
59
|
+
|
|
35
60
|
class UpdateBuildConfigError(Exception):
|
|
36
61
|
pass
|
|
37
62
|
|
|
@@ -415,7 +440,7 @@ def add_code_field_to_build_config(build_config: dict, raw_code: str):
|
|
|
415
440
|
|
|
416
441
|
|
|
417
442
|
def build_custom_component_template_from_inputs(
|
|
418
|
-
custom_component: Component | CustomComponent, user_id: str | UUID | None = None
|
|
443
|
+
custom_component: Component | CustomComponent, user_id: str | UUID | None = None, module_name: str | None = None
|
|
419
444
|
):
|
|
420
445
|
# The List of Inputs fills the role of the build_config and the entrypoint_args
|
|
421
446
|
"""Builds a frontend node template from a custom component using its input-based configuration.
|
|
@@ -452,6 +477,13 @@ def build_custom_component_template_from_inputs(
|
|
|
452
477
|
# ! This should be removed when we have a better way to handle this
|
|
453
478
|
frontend_node.set_base_classes_from_outputs()
|
|
454
479
|
reorder_fields(frontend_node, cc_instance._get_field_order())
|
|
480
|
+
if module_name:
|
|
481
|
+
frontend_node.metadata["module"] = module_name
|
|
482
|
+
|
|
483
|
+
# Generate code hash for cache invalidation and debugging
|
|
484
|
+
code_hash = _generate_code_hash(custom_component._code, module_name, ctype_name)
|
|
485
|
+
if code_hash:
|
|
486
|
+
frontend_node.metadata["code_hash"] = code_hash
|
|
455
487
|
|
|
456
488
|
return frontend_node.to_dict(keep_name=False), cc_instance
|
|
457
489
|
|
|
@@ -459,6 +491,7 @@ def build_custom_component_template_from_inputs(
|
|
|
459
491
|
def build_custom_component_template(
|
|
460
492
|
custom_component: CustomComponent,
|
|
461
493
|
user_id: str | UUID | None = None,
|
|
494
|
+
module_name: str | None = None,
|
|
462
495
|
) -> tuple[dict[str, Any], CustomComponent | Component]:
|
|
463
496
|
"""Builds a frontend node template and instance for a custom component.
|
|
464
497
|
|
|
@@ -490,7 +523,9 @@ def build_custom_component_template(
|
|
|
490
523
|
)
|
|
491
524
|
try:
|
|
492
525
|
if "inputs" in custom_component.template_config:
|
|
493
|
-
return build_custom_component_template_from_inputs(
|
|
526
|
+
return build_custom_component_template_from_inputs(
|
|
527
|
+
custom_component, user_id=user_id, module_name=module_name
|
|
528
|
+
)
|
|
494
529
|
frontend_node = CustomComponentFrontendNode(**custom_component.template_config)
|
|
495
530
|
|
|
496
531
|
field_config, custom_instance = run_build_config(
|
|
@@ -509,6 +544,14 @@ def build_custom_component_template(
|
|
|
509
544
|
|
|
510
545
|
reorder_fields(frontend_node, custom_instance._get_field_order())
|
|
511
546
|
|
|
547
|
+
if module_name:
|
|
548
|
+
frontend_node.metadata["module"] = module_name
|
|
549
|
+
|
|
550
|
+
# Generate code hash for cache invalidation and debugging
|
|
551
|
+
code_hash = _generate_code_hash(custom_component._code, module_name, custom_component.__class__.__name__)
|
|
552
|
+
if code_hash:
|
|
553
|
+
frontend_node.metadata["code_hash"] = code_hash
|
|
554
|
+
|
|
512
555
|
return frontend_node.to_dict(keep_name=False), custom_instance
|
|
513
556
|
except Exception as exc:
|
|
514
557
|
if isinstance(exc, HTTPException):
|
|
@@ -525,6 +568,7 @@ def build_custom_component_template(
|
|
|
525
568
|
def create_component_template(
|
|
526
569
|
component: dict | None = None,
|
|
527
570
|
component_extractor: Component | CustomComponent | None = None,
|
|
571
|
+
module_name: str | None = None,
|
|
528
572
|
):
|
|
529
573
|
"""Creates a component template and instance from either a component dictionary or an existing component extractor.
|
|
530
574
|
|
|
@@ -539,7 +583,9 @@ def create_component_template(
|
|
|
539
583
|
|
|
540
584
|
component_extractor = Component(_code=component_code)
|
|
541
585
|
|
|
542
|
-
component_template, component_instance = build_custom_component_template(
|
|
586
|
+
component_template, component_instance = build_custom_component_template(
|
|
587
|
+
component_extractor, module_name=module_name
|
|
588
|
+
)
|
|
543
589
|
if not component_template["output_types"] and component_output_types:
|
|
544
590
|
component_template["output_types"] = component_output_types
|
|
545
591
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./index-
|
|
1
|
+
import{j as a}from"./index-BA1jLhEh.js";const s=l=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 54 54",width:"1em",height:"1em",...l,children:a.jsxs("g",{fill:"none",fillRule:"evenodd",children:[a.jsx("path",{fill:"#36C5F0",d:"M19.712.133a5.381 5.381 0 0 0-5.376 5.387 5.381 5.381 0 0 0 5.376 5.386h5.376V5.52A5.381 5.381 0 0 0 19.712.133m0 14.365H5.376A5.381 5.381 0 0 0 0 19.884a5.381 5.381 0 0 0 5.376 5.387h14.336a5.381 5.381 0 0 0 5.376-5.387 5.381 5.381 0 0 0-5.376-5.386"}),a.jsx("path",{fill:"#2EB67D",d:"M53.76 19.884a5.381 5.381 0 0 0-5.376-5.386 5.381 5.381 0 0 0-5.376 5.386v5.387h5.376a5.381 5.381 0 0 0 5.376-5.387m-14.336 0V5.52A5.381 5.381 0 0 0 34.048.133a5.381 5.381 0 0 0-5.376 5.387v14.364a5.381 5.381 0 0 0 5.376 5.387 5.381 5.381 0 0 0 5.376-5.387"}),a.jsx("path",{fill:"#ECB22E",d:"M34.048 54a5.381 5.381 0 0 0 5.376-5.387 5.381 5.381 0 0 0-5.376-5.386h-5.376v5.386A5.381 5.381 0 0 0 34.048 54m0-14.365h14.336a5.381 5.381 0 0 0 5.376-5.386 5.381 5.381 0 0 0-5.376-5.387H34.048a5.381 5.381 0 0 0-5.376 5.387 5.381 5.381 0 0 0 5.376 5.386"}),a.jsx("path",{fill:"#E01E5A",d:"M0 34.249a5.381 5.381 0 0 0 5.376 5.386 5.381 5.381 0 0 0 5.376-5.386v-5.387H5.376A5.381 5.381 0 0 0 0 34.25m14.336-.001v14.364A5.381 5.381 0 0 0 19.712 54a5.381 5.381 0 0 0 5.376-5.387V34.25a5.381 5.381 0 0 0-5.376-5.387 5.381 5.381 0 0 0-5.376 5.387"})]})});export{s as default};
|