feat: add module and code hash to component's metadata#8737
feat: add module and code hash to component's metadata#8737ogabrielluiz merged 16 commits intomainfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis change propagates an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Interface
participant Utils
participant FrontendNode
Interface->>Utils: create_component_template(..., module_name)
Utils->>FrontendNode: build node template
Utils->>FrontendNode: Add module_name to metadata (if provided)
FrontendNode-->>Utils: node dict with module metadata
Utils-->>Interface: node template dict
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (27)
src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json (2)
428-430: Same check applies here – verify that thePromptComponentpath is resolvable.
565-567: Same check applies here – verify that theChatOutputpath is resolvable.src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (3)
458-460: Same verification concern as above – ensurelangflow.components.input_output.chat_output.ChatOutputresolves correctly.
830-832: Same verification concern as above – ensurelangflow.components.prompts.prompt.PromptComponentresolves correctly.
990-992: Same verification concern as above – ensurelangflow.components.helpers.memory.MemoryComponentresolves correctly.src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (2)
351-353: Same verification appliesRepeat the import-existence check for this duplicate metadata entry to avoid runtime failures.
957-959: Confirm ChatOutput module pathAs above, validate that
langflow.components.input_output.chat_output.ChatOutputis importable.src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (5)
516-518: Same concern as above – please ensure theParserComponentdotted path is correct; otherwise the frontend template will fail when deserialised.
697-699: Same verification applies toChatOutput’s module path.
1001-1003: Duplicate addition for anotherParserComponentnode – path consistency check recommended.
1196-1198:AstraDBVectorStoreComponentpath is long and easy to mis-spell; worth validating with the script above.
2559-2561: Structured-output component path: same verification needed.src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (9)
616-618: Same verification concern as above – check thatPromptComponentis importable.
793-795: Same verification concern – ensureSplitTextComponentpath is correct.
1080-1082: Same verification concern – validateChatOutputmodule path.
1396-1398: Same verification concern – validateOpenAIEmbeddingsComponentpath.
1931-1933: Same verification concern – secondOpenAIEmbeddingsComponententry.
2412-2414: Same verification concern – ensureFileComponentpath is correct.
2805-2806: Same verification concern – validateOpenAIModelComponentpath.
3376-3378: Same verification concern – checkAstraDBVectorStoreComponent(first instance).
4140-4142: Same verification concern – checkAstraDBVectorStoreComponent(second instance).src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (6)
354-356: Same validation needed for AnthropicModel component
694-696: Same validation needed for AnthropicModel component (second node)
1026-1028: Validatelangflow.components.input_output.chat_output.ChatOutputexistsBroken import here would surface only when the node is rendered.
1480-1482: ValidateStructuredOutputComponentmodule path
1822-1824: ValidateFileComponentmodule path
2117-2119: ValidateParserComponentmodule path
🧹 Nitpick comments (7)
src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json (2)
667-669: Consistency check for ChatOutput metadata
ChatOutputnow declares a module path; good for explicitness. Double-check that every starter JSON uses the same convention (with or without the class suffix) to avoid mixed behaviours in dynamic imports.
1524-1526: URLComponent path follows identical patternNo functional issue spotted, but it inherits the same import-string question as above. Align the convention across all components to prevent brittle reflection code.
src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json (1)
1162-1202: Consistency nit – Agent node still lacks"module"metadataFor completeness and to keep template-generation symmetrical, consider adding a
"metadata": {"module": "langflow.components.agents.agent.AgentComponent"}stanza to the Agent node as was done for the four others.src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json (1)
1909-1911: ChatInput metadata added – path sanity-check
"module": "langflow.components.input_output.chat.ChatInput"looks correct,
but the directory in repo is typicallyinput_output/chat.pyor
input_output/chat/chat_input.py.
Run an import or file-existence check to avoid runtime “module not found” when the
frontend relies on this metadata.src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (1)
839-841: StructuredOutput component metadata added – good, confirm consistency.
langflow.components.processing.structured_output.StructuredOutputComponentresolves to the existing implementation.
Consider adding the same field to any sibling processing components for consistency.src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json (1)
1-2132: ```shell
#!/usr/bin/env bashScan all starter project JSONs for nodes missing metadata.module
python3 << 'EOF'
import json, glob, os
for file in glob.glob("src/backend/base/langflow/initial_setup/starter_projects/*.json"):
try:
data = json.load(open(file))
except json.JSONDecodeError:
continue
for node in data.get("nodes", []):
node_data = node.get("data", {})
node_info = node_data.get("node", {})
metadata = node_info.get("metadata", {})
if "module" not in metadata:
print(f"{file}: node {node_data.get('id')} missing metadata.module")
EOF</blockquote></details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)</summary><blockquote> `282-284`: **Consider de-duplicating hard-coded module strings** The identical module paths now appear in many starter-project JSONs; a future refactor could break all of them. If feasible, generate these values automatically from the backend template utilities instead of materialising them in every flow file. Also applies to: 579-581, 752-754, 866-868, 1025-1027, 1328-1330, 1674-1676 </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 6c76957f3e5ed11073144f9d45286f644917ae72 and 043e1e84542bd0df31269420eb57d6f05f3d86e1. </details> <details> <summary>📒 Files selected for processing (33)</summary> * `src/backend/base/langflow/custom/utils.py` (6 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json` (5 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json` (5 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Diet Analysis.json` (7 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json` (6 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json` (7 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Market Research.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json` (11 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json` (7 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json` (7 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json` (7 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Search agent.json` (3 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json` (8 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json` (6 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json` (4 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json` (9 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json` (10 hunks) * `src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json` (7 hunks) * `src/backend/base/langflow/interface/components.py` (3 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (1)</summary> <details> <summary>`src/backend/**/*component*.py`: In your component class, set the 'icon' attribute to a string matching the frontend icon mapping exactly (case-sensitive).</summary> > `src/backend/**/*component*.py`: In your component class, set the 'icon' attribute to a string matching the frontend icon mapping exactly (case-sensitive). 📄 Source: CodeRabbit Inference Engine (.cursor/rules/icons.mdc) List of files the instruction was applied to: - `src/backend/base/langflow/interface/components.py` </details> </details><details> <summary>🧬 Code Graph Analysis (2)</summary> <details> <summary>src/backend/base/langflow/custom/utils.py (3)</summary><blockquote> <details> <summary>src/backend/base/langflow/custom/custom_component/component.py (1)</summary> * `Component` (94-1641) </details> <details> <summary>src/backend/base/langflow/custom/custom_component/custom_component.py (2)</summary> * `CustomComponent` (35-537) * `user_id` (173-176) </details> <details> <summary>src/backend/base/langflow/template/frontend_node/base.py (1)</summary> * `to_dict` (108-113) </details> </blockquote></details> <details> <summary>src/backend/base/langflow/interface/components.py (1)</summary><blockquote> <details> <summary>src/backend/base/langflow/custom/utils.py (1)</summary> * `create_component_template` (516-540) </details> </blockquote></details> </details> </details> <details> <summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary> * GitHub Check: Optimize new Python code in this PR * GitHub Check: Update Starter Projects </details> <details> <summary>🔇 Additional comments (118)</summary><blockquote> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json (2)</summary> `350-352`: **Same concern for ChatInput** Ensure the loader can handle `"langflow.components.input_output.chat.ChatInput"` when the final token is a class. Apply the same verification or trim the class segment. --- `193-195`: Let’s locate where the JSON “metadata” field is consumed and how its `module` value is passed into the import logic: ```shell #!/usr/bin/env bash # Find any code reading JSON starter projects rg -n "initial_setup" -n src/backend/base/langflow rg -n "starter_projects" -n src # Find where metadata.module is referenced rg -n "metadata" -n src/backend/base/langflow # Inspect component import logic in interface/components.py around the importlib call sed -n '1,200p' src/backend/base/langflow/interface/components.pysrc/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json (4)
876-878: To locate the actual definition ofChatInput, let’s search the entire codebase for its class declaration:#!/bin/bash # Search for the ChatInput class definition across all .py files rg -g '*.py' -n "class ChatInput"
306-308: I want to locate the actual file name and confirm the class definition. Let’s search for anychat*output*.pyfile and look forclass ChatOutputacross the repo:#!/bin/bash # Locate any chat*output*.py files echo "Files matching *chat*output*.py:" fd --type f -g '*chat*output*.py' echo # Find where ChatOutput is defined echo "Occurrences of class ChatOutput:" grep -R -n "class ChatOutput" .
669-671: ```shell
#!/bin/bash
set -eecho "=== Listing all needle.py files ==="
fd --type f needle.py || echo "No needle.py files found"echo -e "\n=== Listing directories named 'needle' ==="
fd --type d -I needle || echo "No 'needle' directories found"echo -e "\n=== Searching for class definitions of NeedleComponent ==="
rg -n "class\s+NeedleComponent" -n . || echo "No class definitions for NeedleComponent found"echo -e "\n=== Searching for any references to NeedleComponent ==="
rg -n "NeedleComponent" -n . || echo "No references to NeedleComponent found"--- `173-175`: ```shell #!/bin/bash # List all Python files with “prompt” in their name or path echo "=== Python files containing 'prompt' in their path ===" fd -t f prompt echo # Search for the PromptComponent class definition across the repo echo "=== Locations of class PromptComponent ===" rg -n "class PromptComponent"src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json (1)
124-126: ```shell
#!/bin/bash1. Locate the langflow package root
echo "Locating 'langflow' package directory:"
find src -type d -name langflow2. Verify that prompt.py exists at the expected path
echo -e "\nChecking for prompt.py:"
find src -type f -path "*/langflow/components/prompts/prompt.py"3. Test importability with the correct PYTHONPATH
echo -e "\nTesting imports with PYTHONPATH=src/backend/base:"
PYTHONPATH=src/backend/base python - <<'PY'
import sys, importlib
targets = [
"langflow.components.prompts.prompt.PromptComponent",
"langflow.components.input_output.chat_output.ChatOutput",
]
for target in targets:
mod_path, _, cls = target.rpartition(".")
try:
mod = importlib.import_module(mod_path)
getattr(mod, cls)
print(f"✓ {target}")
except Exception as e:
print(f"✗ {target} -> {e}", file=sys.stderr)
sys.exit(1)
PY</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (4)</summary> `553-555`: **Validate `ChatInput` metadata path** `langflow.components.input_output.chat.ChatInput` again mixes the file (`chat.py`) with the class. If the loader treats the last token as a class this is fine; otherwise change to the pure module path or introduce a separator (e.g. `chat:ChatInput`) for clarity. --- `894-896`: **`ChatOutput` metadata – verify importability** Same concern as above: ensure that `langflow.components.input_output.chat_output.ChatOutput` corresponds to an importable module (file `chat_output.py`) **and** that the class `ChatOutput` is defined within it. --- `1198-1200`: **`SaveToFileComponent` path looks OK but still sanity-check** The file is expected to live at `langflow/components/processing/save_file.py` and expose `SaveToFileComponent`. Running an automated check now avoids broken starter projects later. ```shell #!/bin/bash # Minimal check for the four new paths added in this JSON. declare -a expected=( "langflow/components/agentql/agentql_api.py" "langflow/components/input_output/chat.py" "langflow/components/input_output/chat_output.py" "langflow/components/processing/save_file.py" ) for path in "${expected[@]}"; do if [ ! -f "$path" ]; then echo "❌ Missing $path"; fi done
198-200: Confirm module pathlangflow.components.agentql.agentql_api.AgentQLactually resolvesThe string appends the class name (
AgentQL) to the module path.
If the importer expects the module only (e.g.langflow.components.agentql.agentql_api) this will raise
ModuleNotFoundErrorat runtime. Please double-check howmetadata.moduleis parsed before merging.#!/bin/bash # Verify that the python file exists and that the class is defined. fd -t f agentql_api.py | head -n 5 rg -n "class AgentQL" $(fd -t f agentql_api.py)src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json (11)
341-343: Adds explicit module metadata – looks correctPath points to
assemblyai_poll_transcript.AssemblyAITranscriptionJobPoller, which matches the class name and folder layout.
No issues spotted.
490-492: Module tag for “Parse Data” node is consistentModule string matches the existing Python file (
parse_data.py) and class (ParseDataComponent).
660-662: Prompt component metadata added
langflow.components.prompts.prompt.PromptComponentis the canonical location – good.
815-817: ChatOutput (LTpUg) metadataModule path is correct; no further action needed.
1119-1121: ChatOutput (m5kak) metadataSame accuracy as above; 👍
1423-1425: ChatOutput (SLRFg) metadataConsistent with other ChatOutput nodes.
1728-1730: Prompt (qm57P) node now carries module infoMatches prompt component path; fine.
1903-1905: MemoryComponent module tag
langflow.components.helpers.memory.MemoryComponentis accurate.
2232-2234: ChatInput module metadataConfirmed correct (
input_output.chat.ChatInput).
2650-2651: AssemblyAITranscriptionJobCreator module tagPath matches the file/class naming pattern.
3177-3179: TypeConverterComponent metadataCorrectly references
processing.converter.TypeConverterComponent.src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (8)
417-419: Verify ChatOutput module pathSame comment as above – double-check that
langflow.components.input_output.chat_outputexists in the codebase.
727-729: Verify ChatInput module pathConfirm that
langflow.components.input_output.chatis the actual package containingChatInput.
1062-1064: Verify ParserComponent module path
langflow.components.processing.parsershould containParserComponent.
1236-1238: Verify LoopComponent module pathMake sure
langflow.components.logic.loopis importable.
1355-1357: Verify TypeConverterComponent module path (node #1)Double-check
langflow.components.processing.converterexists.
1778-1780: Verify TypeConverterComponent module path (node #2)Same as above for the second instance.
1-1905: Automated check for all new module pathsTo save time, execute the following script once; it imports every newly-added module and exits non-zero on failure.
#!/bin/bash python - <<'PY' import importlib, sys, textwrap modules = [ "langflow.components.search.arxiv.ArXivComponent", "langflow.components.input_output.chat_output.ChatOutput", "langflow.components.input_output.chat.ChatInput", "langflow.components.processing.parser.ParserComponent", "langflow.components.logic.loop.LoopComponent", "langflow.components.processing.converter.TypeConverterComponent", ] failed = [] for full in modules: pkg = ".".join(full.split(".")[:-1]) try: importlib.import_module(pkg) except ModuleNotFoundError as e: failed.append(f"{full} -> {e}") if failed: print("❌ The following module paths are not importable:") print("\n".join(failed)) sys.exit(1) print("✅ All module paths import correctly.") PY
257-259: ```shell
#!/bin/bashShow package configuration in pyproject.toml to verify how the langflow package is defined
sed -n '1,200p' pyproject.toml
</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json (4)</summary> `454-456`: **Same caution on `ChatOutput` metadata** Confirm that `langflow.components.input_output.chat_output.ChatOutput` is importable; otherwise the node will not render in the playground. --- `767-769`: **Verify Tavily component path** Double-check that `langflow.components.tavily.tavily_search.TavilySearchComponent` exists; a typo here silently breaks the starter flow. --- `1167-1169`: **Verify AgentQL component path** Ensure `langflow.components.agentql.agentql_api.AgentQL` is the actual qualified name of the class; starter-project loading relies on it. --- `139-141`: **Ensure the declared `module` path actually resolves** The component will be located through the value you just added: `langflow.components.input_output.chat.ChatInput` If this dotted path cannot be imported at runtime the starter project will fail to load the node. Please verify that the corresponding Python file *and* class exist in the repo. ```shell #!/usr/bin/env bash # Quick sanity-check for all newly added module paths modules=( "langflow.components.input_output.chat" "langflow.components.input_output.chat_output" "langflow.components.tavily.tavily_search" "langflow.components.agentql.agentql_api" ) for m in "${modules[@]}"; do echo ">> checking ${m}" # list at least one file that matches the module († turns dots into / and appends .py) fp="$(echo "${m}" | tr '.' '/')".py if [[ -f "${fp}" ]]; then echo " OK – file ${fp} found" else echo " MISSING – expected file ${fp}" >&2 fi donesrc/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (7)
307-309: Explicitmodulemetadata looks correct – please double-check the fully-qualified path exists
langflow.components.prompts.prompt.PromptComponentmatches the current package layout, so the addition should play nicely with the new template-building utility.
Just run a quick grep across the repo (or import in a REPL) to be sure the dotted path hasn’t moved or been renamed since the refactor.
467-469: Good addition forChatInput; identical warning about path validityNothing else to flag here.
764-766: Metadata in second Prompt node mirrors the first – no issuesDuplication is expected across nodes; just keep an eye on module relocations in future PRs.
978-980: ConsistentPromptComponentmodule referenceLooks fine.
1109-1111: Another Prompt node – path consistentNo further comments.
1276-1278:TavilySearchComponentmetadata path matches file treeUseful for dynamic loading; nothing to change.
1676-1678:ChatOutputmetadata added – LGTMAll good; same verification note applies.
src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json (3)
831-833: APIRequest component metadata inserted correctly
"module": "langflow.components.data.api_request.APIRequestComponent"matches the concrete class shown later in this file.
Looks fine.
430-432: To locate the actual definition and file path of ChatOutput, let’s search all Python files for its class and any matching filenames:#!/bin/bash # Find where ChatOutput is defined rg "class ChatOutput" -n -g "*.py" || true # Check for files named ChatOutput.py or chat_output.py fd ChatOutput.py || true fd chat_output.py || true
114-116: ```shell
#!/bin/bashBroadly search for ChatInput class definitions across the repository
rg -n 'class ChatInput' -C 2
</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (6)</summary> `256-258`: **Explicit module metadata added – looks correct** The `"metadata": { "module": "langflow.components.data.file.FileComponent" }` entry accurately identifies the backend implementation for the File component. No issues spotted. --- `549-551`: **Prompt‐module mapping is correct** `langflow.components.prompts.prompt.PromptComponent` matches the Prompt implementation. All good here. --- `699-701`: **Consistent metadata for second Prompt node** The module path mirrors the previous Prompt node – consistency maintained. --- `847-849`: **Third Prompt node metadata – OK** Same module path, no discrepancies detected. --- `1006-1008`: **ChatOutput node now carries correct module reference** `langflow.components.input_output.chat_output.ChatOutput` is the expected fully-qualified class path. Looks good. --- `1316-1318`: **Second ChatOutput node metadata consistent** Matches the first ChatOutput node’s module path – no further action needed. </details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Search agent.json (2)</summary> `105-107`: **Verify module path value** Great to see the new `metadata.module` injected, but please double-check that `langflow.components.scrapegraph.scrapegraph_search_api.ScrapeGraphSearchApi` is the exact importable path that `importlib.import_module()` (or equivalent) will later use. A mismatch will cause runtime import errors. --- `591-593`: **Confirm `ChatOutput` module path** `ChatOutput` is usually defined in `chat_output.py`, so `langflow.components.input_output.chat_output.ChatOutput` looks correct. Just ensure this mirrors the actual file layout to avoid lazy-import issues. </details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (1)</summary> `150-152`: To pinpoint whether the module paths in your JSON align with the actual class locations, let’s locate each class definition in the repo: ```shell #!/bin/bash # Locate class definitions for metadata.module entries echo "🔍 Searching for ChatInput class..." rg -n "class ChatInput" src/backend/base/langflow/components echo "🔍 Searching for ChatOutput class..." rg -n "class ChatOutput" src/backend/base/langflow/components echo "🔍 Searching for PromptComponent class..." rg -n "class PromptComponent" src/backend/base/langflow/components echo "🔍 Searching for MemoryComponent class..." rg -n "class MemoryComponent" src/backend/base/langflow/componentsThis will confirm the correct file paths and module names. If they differ, we can update the JSON to match.
src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json (5)
2909-2911: Possible case/segment mismatch inYfinanceComponentpath
langflow.components.search.yahoo.YfinanceComponentThe file that defines
YfinanceComponentis usuallysearch/yahoo.py
(notyahoo/YfinanceComponent.py). Make sure the dotted path reflects the
actual package structure, otherwise dynamic imports will break.
3122-3124: CalculatorComponent metadata LGTMPath
langflow.components.helpers.calculator_core.CalculatorComponentaligns
with the existing helper namespace – looks consistent with the codebase.
3278-3280: Confirm tavily component path
langflow.components.tavily.tavily_search.TavilySearchComponent– please
verify the intermediate package (tavily) exists; earlier versions located
this undersearch/tavily_search.py.
3677-3679: ChatOutput metadata – importability checkSame comment as above: ensure that
langflow.components.input_output.chat_output.ChatOutput
matches the actual file path (ofteninput_output/chat_output.py).
1450-1452: ```shell
#!/usr/bin/env bashVerify init.py presence for module imports
for dir in src/backend/base/langflow
src/backend/base/langflow/components
src/backend/base/langflow/components/prompts; do
if [ -f "$dir/init.py" ]; then
echo "Found init: $dir/init.py"
else
echo "Missing init: $dir/init.py"
fi
doneConfirm PromptComponent definition
grep -n "class PromptComponent" src/backend/base/langflow/components/prompts/prompt.py || echo "PromptComponent class not found"
</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Diet Analysis.json (7)</summary> `388-391`: **`selected_output` configuration looks consistent** `"selected_output": "message"` correctly corresponds to the only declared output of the ChatInput node. Nothing else to flag. --- `521-524`: **Prompt node output selection is correct** `"selected_output": "prompt"` matches the `outputs` array. No further action needed. --- `898-900`: **Selected output for NovitaModel is coherent** `"text_output"` is present in the component’s outputs list. Looks good. --- `944-946`: ```shell #!/bin/bash set -e echo "Searching for chat_output.py files in the repository..." fd chat_output.py 2>/dev/null || find . -type f -name "chat_output.py" echo -e "\nSearching for class ChatOutput definitions in Python files..." rg -n "class ChatOutput" -A2 --glob "*.py"
576-578: ```shell
#!/bin/bash
set -eecho "1) Searching for the NovitaModelComponent class definition across the repo"
rg -n "class NovitaModelComponent" . || echo "No class definition found"echo -e "\n2) Listing any files or modules with 'novita' in the name"
find . -type f -iname "novita.py" -print || echo "No files matching novita.py"echo -e "\n3) Checking for 'languagemodels' vs 'language_models' directories"
find . -type d ( -iname "languagemodels" -o -iname "language_models" ) -print--- `121-123`: ```shell #!/bin/bash # Search only Python files for ChatInput class definition rg -n "class ChatInput" -g "*.py" . echo "-----" # Locate chat.py files in the codebase if command -v fd > /dev/null; then fd chat.py else find . -type f -name "chat.py" fi
434-436: ```shell
#!/bin/bashInspect the prompts package initialization
sed -n '1,50p' src/backend/base/langflow/components/prompts/init.py
Inspect how PromptComponent is imported in its unit test
sed -n '1,50p' src/backend/tests/unit/components/prompts/test_prompt_component.py
</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (1)</summary> `229-231`: ```shell #!/usr/bin/env bash # Verify that module files exist and their classes are defined. # Base path to langflow package BASE="src/backend/base/langflow" # Check file existence for mod in \ "components/prompts/prompt.py" \ "components/input_output/chat.py" \ "components/input_output/chat_output.py"; do if [ -f "${BASE}/${mod}" ]; then echo "✅ File exists: ${BASE}/${mod}" else echo "❌ File missing: ${BASE}/${mod}" fi done # Check class definitions echo echo "Checking class definitions:" rg "class PromptComponent" -n "${BASE}/components/prompts/prompt.py" || echo "❌ PromptComponent class not found" rg "class ChatInput" -n "${BASE}/components/input_output/chat.py" || echo "❌ ChatInput class not found" rg "class ChatOutput" -n "${BASE}/components/input_output/chat_output.py" || echo "❌ ChatOutput class not found"src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (3)
498-500:Chat Outputnode metadata added – path appears accurate.The path
langflow.components.input_output.chat_output.ChatOutputmatches the file name that contains the component.
No functional risk spotted; just keep it in sync if files are moved.
1175-1177: TavilySearch component now declares its module path – 👍Path
langflow.components.tavily.tavily_search.TavilySearchComponentseems correct.
No issues detected.
198-200:Chat Inputnode now carries amodulepath – looks correct, but validate it exists.The dotted path
langflow.components.input_output.chat.ChatInputaligns with the current package layout.
Please run the verification script below to be sure no future refactors break this reference.#!/bin/bash # Verify that ChatInput class is reachable at the declared path rg --no-heading -n $'^class ChatInput' | head -n 5src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json (5)
179-181: Module path looks correct.
langflow.components.prompts.prompt.PromptComponentmatches the canonical location for the Prompt component – no concerns.
468-470: ConfirmChatOutputpath.Likewise, double-check that
langflow.components.input_output.chat_output.ChatOutput
exports the expectedChatOutputclass.
A mismatch will break dynamic component loading.
790-792: Parser component path sanity check.Ensure
langflow.components.processing.parser.ParserComponent
is still the definitive location (there were recent moves fromprocessing.parsers).
353-355: ```shell
#!/usr/bin/env bash
set -eSearch for the TextInputComponent class definition
rg "class TextInputComponent" -n .
Search for files named after the component
fd TextInputComponent --extension py
--- `976-978`: Let’s locate the actual definition of `URLComponent` in the codebase to confirm the correct import path: ```shell #!/bin/bash set -e echo "Searching for class URLComponent definitions..." rg --heading --context 2 "class URLComponent" -n echo "Looking for any occurrences of URLComponent..." rg -n "URLComponent"src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json (2)
2272-2273: Align ChatOutput metadata path with file systemSame pattern as above: file is
chat_output.py, notchat_outputpackage. Fix to ensure lazy-loading works.- "module": "langflow.components.input_output.chat_output.ChatOutput" + "module": "langflow.components.input_output.chat_output.ChatOutput"(Note: if the file is actually
chat_output.pythe path remains the same; if it lives in achatsub-package adjust accordingly.)Likely an incorrect or invalid review comment.
239-241: ```shell
#!/usr/bin/env bashLocate memory.py in the repo
echo "=== Finding memory.py ==="
find . -type f -name "memory.py"List init.py files under langflow package tree
echo -e "\n=== Listing init.py under src/backend/base/langflow ==="
find src/backend/base/langflow -type f -name "init.py"Test dynamic import by adding src/backend/base to PYTHONPATH
echo -e "\n=== Testing import with src/backend/base on sys.path ==="
python - <<'PY'
import os, sys, traceback
root = os.getcwd()
base_path = os.path.join(root, 'src', 'backend', 'base')
sys.path.insert(0, base_path)
try:
mod = import("langflow.components.helpers.memory", fromlist=["MemoryComponent"])
print("Import succeeded:", mod)
print("Has MemoryComponent:", hasattr(mod, "MemoryComponent"))
except Exception:
traceback.print_exc()
sys.exit(1)
PY</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (2)</summary> `643-645`: **Confirm ChatInput module path** Double-check that the ChatInput component still lives at `langflow/components/input_output/chat.py` and exports `ChatInput`; internal refactors can silently break this reference. --- `146-148`: ```shell #!/bin/bash # Add the directory containing the langflow package to PYTHONPATH for imports export PYTHONPATH="src/backend/base" python - <<'PY' import importlib, sys modules = [ "langflow.components.apify.apify_actor.ApifyActorsComponent", "langflow.components.input_output.chat.ChatInput", "langflow.components.input_output.chat_output.ChatOutput", ] for m in modules: mod, cls = m.rsplit(".", 1) try: pkg = importlib.import_module(mod) getattr(pkg, cls) print(f"SUCCESS: {m}") except (ImportError, AttributeError) as e: print(f"FAILED: {m} -> {e}", file=sys.stderr) PYsrc/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json (4)
236-238: ConfirmChatInputmodule path actually exists
"module": "langflow.components.input_output.chat.ChatInput"assumes the class lives inlangflow/components/input_output/chat.py(or an__init__.pythat re-exports it).
In Langflow the file is often namedchat_input.py. If the path is wrong, component hydration will fail at runtime.#!/bin/bash # Verify that a Python file defining class ChatInput exists rg -n $'^class ChatInput' | head -n 20
878-880: Prompt component path check
langflow.components.prompts.prompt.PromptComponentlooks correct, but double-check to avoid
breaking template loading.#!/bin/bash rg -n $'^class PromptComponent' | head -n 20
1008-1010: StructuredOutput component path checkVerify that
langflow.components.processing.structured_output.StructuredOutputComponent
matches the actual package structure.#!/bin/bash rg -n $'^class StructuredOutputComponent' | head -n 20
543-545: ValidateChatOutputmetadata pathSame concern as above: make sure
langflow.components.input_output.chat_output.ChatOutput
is the real importable path.#!/bin/bash # Locate ChatOutput class rg -n $'^class ChatOutput' | head -n 20src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json (9)
285-287: Module metadata correctly added for ChatInput
Explicitly linking the node tolangflow.components.input_output.chat.ChatInputwill help the frontend/editor resolve the implementation with zero guessing.
596-598: Module metadata added for TextInput-i5Z2Y
Change is consistent with the new convention adopted across starter projects.
713-715: Module metadata added for ChatOutput
Accurately referenceschat_output.ChatOutput. Good.
1021-1023: Module metadata added for TextInput-OAt8o
Looks correct and aligned with other text inputs.
1128-1130: Module metadata added for TextInput-58oH9
Consistent with convention.
1235-1237: Module metadata added for TextInput-3nKXg
No issues spotted.
1342-1344: Module metadata added for TextInput-rIJMY
Matches the rest of the updates.
1449-1451: Module metadata added for TextInput-MlxGC
Good job keeping the naming uniform.
1604-1606: Module metadata added for PromptComponent
Properly points tolangflow.components.prompts.prompt.PromptComponent.src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)
282-284: ```shell
#!/usr/bin/env bash
set -euo pipefailVerify all metadata.module entries in Instagram Copywriter starter JSON
python3 - <<'EOF'
import json, os, sysjson_file = "src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json"
with open(json_file) as f:
data = json.load(f)modules = set()
def traverse(obj):
if isinstance(obj, dict):
md = obj.get("metadata", {})
mod = md.get("module")
if mod:
modules.add(mod)
for v in obj.values():
traverse(v)
elif isinstance(obj, list):
for v in obj:
traverse(v)traverse(data)
failed = False
for mod in sorted(modules):
cls = mod.split(".")[-1]
module_path = mod.rsplit(".", 1)[0].replace(".", os.sep) + ".py"
if not os.path.isfile(module_path):
print(f"❌ Missing file for module {mod}: {module_path}")
failed = True
else:
content = open(module_path).read()
if f"class {cls}" not in content:
print(f"❌ Class {cls} not found in {module_path}")
failed = True
else:
print(f"✅ Verified {mod} → {module_path}")if failed:
sys.exit(1)
EOF</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json (3)</summary> `1293-1295`: **StructuredOutput metadata added – looks good** The path `langflow.components.processing.structured_output.StructuredOutputComponent` matches the usual layout; no issues spotted. --- `152-154`: **Confirm the `ChatOutput` module path resolves at runtime** The new metadata entry looks correct, but a bad import string here will break template loading at startup. Please double-check that `langflow.components.input_output.chat_output.ChatOutput` exists in the repo (file name and package path are case-sensitive). ```shell #!/bin/bash # Verify ChatOutput class is defined exactly once in the expected module path. rg -n "class ChatOutput" | head -5
466-468: ```shell
#!/bin/bash
echo "Searching for directories named 'input_output' under src"
find src -type d -name 'input_output'
echo ""
echo "Listing Python files under those directories"
find src -type f -path '/input_output/.py' | grep '.py$'
echo ""
echo "Searching for class ChatInput in Python code under src"
rg -n --type py "class ChatInput" src</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (1)</summary> `207-209`: **Add-on looks right, but double-check the module path actually resolves** The new `"module": "langflow.components.input_output.chat.ChatInput"` entry will be used later for dynamic imports. A typo here will only surface at runtime, so better to verify the file/class exist under that dotted path. </details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (1)</summary> `178-180`: ```bash #!/usr/bin/env bash # Find where starter_projects JSON files are loaded grep -R -n "starter_projects" -C2 src/backend/base/langflow # Find code that reads JSON files in initial_setup grep -R -n "initial_setup" -C2 src/backend/base/langflowsrc/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json (3)
408-410: ```shell
#!/bin/bash
echo "Searching for PromptComponent class definitions..."
rg -n "class PromptComponent" -t py || echo "❌ No class definition found"
echo
echo "Listing all files referencing PromptComponent..."
rg -l "PromptComponent" -t py || echo "❌ No references found"--- `616-618`: Let’s locate where `ChatOutput` is defined (filename and class) to confirm the JSON metadata path: ```shell #!/bin/bash # 1. Find any file named chat_output.py echo "Searching for chat_output.py:" find . -type f -name "chat_output.py" || echo "❌ chat_output.py not found" echo # 2. Search for class ChatOutput definitions anywhere echo "Searching for class ChatOutput:" rg -n "class ChatOutput" --max-count 50 || echo "❌ No ChatOutput class found"
120-122: ```shell
#!/bin/bashLocate ChatInput class definition in the repository
rg -n "class ChatInput" -t py
</details> <details> <summary>src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (1)</summary> `118-120`: **LGTM! Consistent module metadata additions.** The explicit module metadata entries are correctly formatted and follow a consistent pattern across all components. These additions align with the broader effort to standardize module metadata across starter projects for better component identification. Also applies to: 371-373, 715-717 </details> <details> <summary>src/backend/base/langflow/interface/components.py (3)</summary> `13-13`: **LGTM! Import supports new conditional logic.** The `BASE_COMPONENTS_PATH` import is correctly added and necessary for the enhanced component loading logic. --- `136-140`: **LGTM! Correct module name construction.** The full module name construction properly combines the module path with the class name, enabling accurate module metadata propagation to component templates as intended. --- `175-178`: ```shell #!/bin/bash # Display the definition and context of aget_component_metadata in components.py echo "Extracting the start of src/backend/base/langflow/interface/components.py for context:" sed -n '1,200p' src/backend/base/langflow/interface/components.py echo -e "\nSearching for the exact definition of aget_component_metadata:" rg -n "async def aget_component_metadata" -n -C5 src/backend/base/langflow/interface/components.pysrc/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (1)
321-323: I’ll locate where each component actually lives in the repo:#!/bin/bash echo "=== Searching for component filenames ===" components=("ChatInput" "ChatOutput" "PromptComponent" "SplitTextComponent" "OpenAIEmbeddingsComponent" "OpenAIModelComponent" "FileComponent" "AstraDBVectorStoreComponent") for comp in "${components[@]}"; do echo echo ">> find file *${comp}.py" fd -i "${comp}.py" || echo "No matches for ${comp}.py" done echo echo "=== Searching for class definitions ===" for comp in "${components[@]}"; do echo echo ">>> rg \"class ${comp}\" -n" rg "class ${comp}" -n || echo "No class ${comp} found" donesrc/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json (4)
230-232: ChatInput module metadata looks correctThe fully-qualified path (
langflow.components.input_output.chat.ChatInput) matches the standard package layout and will help the loader resolve the class unambiguously.
1577-1579: SearchComponent metadata – path sanity-check
langflow.components.search.search.SearchComponentcontains a duplicated “search” segment, which is fine only if the package layout issearch/search.py. Validate to avoid import errors.#!/bin/bash fd -t f search.py src | while read -r f; do echo "Found: $f" rg -n "class SearchComponent" "$f" done
1420-1422: CalculatorComponent path addition – verify presence
langflow.components.helpers.calculator_core.CalculatorComponentaligns with the helper package naming, but please confirm the file really lives underhelpers/calculator_core.py.#!/bin/bash fd -t f calculator_core.py src | while read -r f; do echo "Found: $f" rg -n "class CalculatorComponent" "$f" done
530-532: Please double-check the ChatOutput module path
langflow.components.input_output.chat_output.ChatOutputlooks right, but the repo previously located the class ininput_output.chat_output.chat_output.#!/bin/bash # Verify that the target file exists and contains the ChatOutput class fd -t f chat_output.py src | while read -r f; do echo "Found: $f" rg -n "class ChatOutput" "$f" donesrc/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (1)
340-342: Module metadata paths LGTMAll newly-added
"metadata": {"module": ...}entries reference the expected fully-qualified module for each component (BatchRunComponent,YouTubeCommentsComponent,PromptComponent,ChatOutput,YouTubeTranscriptsComponent,ChatInput,ConditionalRouterComponent).
This explicit linkage will help the loader resolve implementations without relying on naming heuristics.No structural or naming issues spotted. 👍
Also applies to: 557-559, 1313-1315, 1492-1494, 1801-1803, 2047-2049, 2448-2450
src/backend/base/langflow/custom/utils.py (7)
402-403: LGTM! Good addition of optional module_name parameter.The function signature change maintains backward compatibility with the optional parameter and proper type annotation.
439-441: LGTM! Proper conditional metadata assignment.The implementation correctly guards the metadata assignment and follows the expected pattern of only setting the module when provided.
447-448: LGTM! Consistent parameter addition.The function signature change maintains the same pattern as the previous function with proper type annotation.
479-481: LGTM! Proper parameter propagation.The function correctly passes through the
module_nameparameter to the nested function call, maintaining the data flow.
500-502: LGTM! Consistent metadata handling.The implementation mirrors the same conditional pattern used in the other function, ensuring consistent behavior across the codebase.
519-519: LGTM! Consistent function signature update.The parameter addition follows the established pattern and maintains backward compatibility.
534-536: LGTM! Complete parameter propagation chain.The function properly passes the
module_nameparameter through tobuild_custom_component_template, completing the propagation chain from the top-level function.src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)
228-230: ```shell
#!/bin/bashVerify package structure for import path
dirs=(
"src/backend/base/langflow"
"src/backend/base/langflow/components"
"src/backend/base/langflow/components/input_output"
)
for d in "${dirs[@]}"; do
if [ -f "$d/init.py" ]; then
echo "init.py found in $d"
else
echo "init.py missing in $d"
fi
doneConfirm text.py exists
if [ -f "src/backend/base/langflow/components/input_output/text.py" ]; then
echo "text.py exists"
else
echo "text.py missing"
fi</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
src/backend/base/langflow/initial_setup/starter_projects/Search agent.json
Show resolved
Hide resolved
src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
Show resolved
Hide resolved
src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
Show resolved
Hide resolved
|
@coderabbitai review, please |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll review this PR for you! Let me first examine the actual code changes to provide a thorough analysis. 🏁 Script executed: Length of output: 146 🏁 Script executed: Length of output: 53599 @ogabrielluiz, I've reviewed the code changes in this PR. Here's my analysis focusing on the Python implementation (following the learning that JSON files are autogenerated and shouldn't be reviewed): ✅ Strengths1. Clean Parameter Propagation 2. Proper Metadata Handling if module_name:
frontend_node.metadata["module"] = module_name
# Generate code hash for cache invalidation and debugging
code_hash = _generate_code_hash(custom_component._code, module_name, ctype_name)
if code_hash:
frontend_node.metadata["code_hash"] = code_hashNice addition of code hashing for cache invalidation - this will help with debugging and tracking component changes. 🔍 Areas for Improvement1. Component Loading Logic Complexity if settings_service.settings.lazy_load_components:
# Partial loading mode - just load component metadata
logger.debug("Using partial component loading")
component_cache.all_types_dict = await aget_component_metadata(settings_service.settings.components_path)
elif (
settings_service.settings.components_path
and BASE_COMPONENTS_PATH not in settings_service.settings.components_path
):
# Traditional full loading
component_cache.all_types_dict = await aget_all_types_dict(settings_service.settings.components_path)Suggestion: Consider extracting this logic into a separate method like 2. Dictionary Merging Logic # merge the dicts
component_cache.all_types_dict = {
**langflow_components["components"],
**components_dict,
}Issue: This merging approach may not handle nested dictionaries properly and could overwrite entire component categories rather than merging individual components. Recommendation: Use the existing from langflow.custom.directory_reader.utils import merge_nested_dicts_with_renaming
# Safer merging approach
component_cache.all_types_dict = merge_nested_dicts_with_renaming(
langflow_components["components"],
components_dict
)3. Module Name Construction full_module_name = f"{modname}.{name}"This creates very long module names like 🚨 Potential Issues1. Cache Reset Side Effect component_cache.all_types_dict = {}The explicit reset of the cache dictionary seems unnecessary and could cause issues if multiple threads are accessing the cache simultaneously. 2. Error Handling except (UnicodeEncodeError, TypeError, ValueError) as e:
logger.warning(f"Could not generate hash for {class_name} in {modname}: {e}") # Changed from debug📋 Questions & Clarifications
🎯 Overall AssessmentThis is a solid enhancement that adds valuable metadata to component templates. The parameter propagation is clean and the code hash addition is thoughtful. The main areas for improvement are around the component loading logic complexity and dictionary merging safety. The changes support better component introspection and debugging capabilities, which aligns well with the framework's evolution toward more sophisticated component management. ✏️ Learnings added
🧠 Learnings used |
…e hashes and module references for ChatInput and ChatOutput components. This enhances traceability and consistency across the project configurations.
| logger.debug(f"Could not generate hash for {class_name} in {modname}: {e}") | ||
| # Fallback: hash the module name + class name as a weak identifier | ||
| fallback_str = f"{modname}.{class_name}" | ||
| return hashlib.sha256(fallback_str.encode("utf-8")).hexdigest()[:12] |
There was a problem hiding this comment.
Same question -- what's the downstream consequences if we allow this fallback
There was a problem hiding this comment.
The user would be able to fake a component with dangerous code and eval it because the name is safe.
|
|
||
| def build_custom_component_template_from_inputs( | ||
| custom_component: Component | CustomComponent, user_id: str | UUID | None = None | ||
| custom_component: Component | CustomComponent, user_id: str | UUID | None = None, module_name: str | None = None |
There was a problem hiding this comment.
Should we expect a non null module name?
There was a problem hiding this comment.
In this case we don't always have that info for this function.
There was a problem hiding this comment.
When we are processing a CustomComponent there's no module to reference. We may have a generic one (e.g. MyCustomComponentClass -> langflow.components.custom_component.my_custom_component_class.py) as we prepare for the new export.
| def build_custom_component_template( | ||
| custom_component: CustomComponent, | ||
| user_id: str | UUID | None = None, | ||
| module_name: str | None = None, |
…ing and clarity - Simplified the logic to generate a SHA256 hash of the source code. - Added explicit error handling for empty source code, encoding issues, and type errors. - Updated docstring to reflect changes in argument descriptions and added information about raised exceptions.
- Introduced tests for the _generate_code_hash function, covering basic hash generation, error handling for empty and None source, hash consistency, and uniqueness for different code. - Added tests to verify metadata addition in template building functions, ensuring that module names and code hashes are correctly included in the metadata of custom components.
) * feat: filter out base components path in custom component loading * revert changes to allow testing the function * feat: add module_name parameter to custom component template functions * feat: include full module name in component template creation * feat: add module metadata to various starter project JSON files * feat: add code hash generation for custom component templates * test: add unit tests for code hash and module metadata functionality * feat: add code hash to metadata in various starter project JSON files * feat: refactor code hash generation to accept source code and class name * feat: implement loading strategy for custom components in settings service * Update metadata for various starter project JSON files to include code hashes and module references for ChatInput and ChatOutput components. This enhances traceability and consistency across the project configurations. * refactor: improve _generate_code_hash function for better error handling and clarity - Simplified the logic to generate a SHA256 hash of the source code. - Added explicit error handling for empty source code, encoding issues, and type errors. - Updated docstring to reflect changes in argument descriptions and added information about raised exceptions. * test: add unit tests for metadata functionality in custom utils - Introduced tests for the _generate_code_hash function, covering basic hash generation, error handling for empty and None source, hash consistency, and uniqueness for different code. - Added tests to verify metadata addition in template building functions, ensuring that module names and code hashes are correctly included in the metadata of custom components. --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Summary by CodeRabbit
New Features
Refactor
Chores