-
Notifications
You must be signed in to change notification settings - Fork 8.2k
\ud83e\udd16 Fix: Add documentation/examples for file uploads via Python API #10695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughDocumentation update introducing file upload integration workflows, expanded multi-language API examples, Streamlit integration guide, and vector store API injection documentation. Adds two new Develop documentation entries to sidebar configuration with comprehensive examples for file handling and vector store operations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (7 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
docs/docs/API-Reference/api-reference-api-examples.mdx (1)
399-484: React example is functional but incomplete.The React component demonstrates the integration pattern well, but references undefined variables and functions (
FLOW_ID,FILE_COMPONENT_ID,extractChatResponse). For documentation purposes, this is acceptable as it focuses on the core integration logic.Consider adding a brief note that this is a simplified example and users should:
- Define the constants (FLOW_ID, FILE_COMPONENT_ID) from their flow configuration
- Implement
extractChatResponsesimilar to the Python client's method- Add proper error handling UI
Alternatively, add comments in the code:
// Define these constants from your Langflow flow configuration const FLOW_ID = process.env.REACT_APP_FLOW_ID; const FILE_COMPONENT_ID = process.env.REACT_APP_FILE_COMPONENT_ID; // Extract response (implementation similar to Python client) const extractChatResponse = (result) => { // ... implementation };docs/docs/Develop/streamlit-integration-example.mdx (1)
268-270: Streamlit API usage is correct; version documentation is optional.The code at line 270 correctly uses
st.rerun(), which is the current stable API in Streamlit 2025 and has been since version 1.27.0. The stable API isst.rerun()(replaces the deprecatedst.experimental_rerun).Adding a minimum Streamlit version requirement to the prerequisites or installation section would be a good practice for clarity, but is not required for correctness. The code as written is compatible with current Streamlit versions.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/docs/API-Reference/api-files.mdx(1 hunks)docs/docs/API-Reference/api-reference-api-examples.mdx(3 hunks)docs/docs/Develop/streamlit-integration-example.mdx(1 hunks)docs/docs/Develop/vector-store-api-integration.mdx(1 hunks)docs/sidebars.js(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-07-11T21:32:57.160Z
Learnt from: namastex888
Repo: langflow-ai/langflow PR: 9018
File: src/frontend/src/modals/apiModal/utils/get-curl-code.tsx:139-184
Timestamp: 2025-07-11T21:32:57.160Z
Learning: In TypeScript/JavaScript cURL code generation for Langflow, PowerShell commands must use backticks (`) for line continuation and follow the pattern: `curl --request POST \` followed by `--url`, `--header` flags on separate lines. Unix commands use backslashes (\) for line continuation. File upload commands should maintain platform-specific formatting just like other cURL commands in the codebase.
Applied to files:
docs/docs/API-Reference/api-reference-api-examples.mdx
📚 Learning: 2025-07-23T21:19:22.567Z
Learnt from: deon-sanchez
Repo: langflow-ai/langflow PR: 9158
File: src/backend/base/langflow/api/v1/mcp_projects.py:404-404
Timestamp: 2025-07-23T21:19:22.567Z
Learning: In langflow MCP projects configuration, prefer using dynamically computed URLs (like the `sse_url` variable) over hardcoded localhost URLs to ensure compatibility across different deployment environments.
Applied to files:
docs/docs/API-Reference/api-reference-api-examples.mdx
📚 Learning: 2025-10-29T03:55:50.216Z
Learnt from: ricofurtado
Repo: langflow-ai/langflow PR: 10430
File: src/backend/base/langflow/api/v2/registration.py:0-0
Timestamp: 2025-10-29T03:55:50.216Z
Learning: In the langflow project, user registration endpoints in API v2 (`src/backend/base/langflow/api/v2/registration.py`) are intentionally designed to be unauthenticated to support Desktop application initialization and onboarding flows.
Applied to files:
docs/docs/API-Reference/api-reference-api-examples.mdx
📚 Learning: 2025-08-07T20:23:23.569Z
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: The Langflow codebase has an excellent structlog implementation that follows best practices, with proper global configuration, environment-based output formatting, and widespread adoption across components. The main cleanup needed is updating starter project templates and documentation examples that still contain legacy `from loguru import logger` imports.
Applied to files:
docs/docs/Develop/streamlit-integration-example.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test Docs Build / Test Docs Build
🔇 Additional comments (15)
docs/docs/API-Reference/api-files.mdx (1)
296-302: LGTM! Helpful cross-references added.The tip block provides useful navigation to comprehensive examples and guides, well-placed after the basic file upload instructions. The links align with the new documentation being added in this PR.
docs/sidebars.js (1)
163-172: LGTM! Sidebar entries properly configured.The new documentation entries are correctly formatted and logically placed in the Develop section. The IDs match the slugs defined in the corresponding MDX files.
docs/docs/Develop/vector-store-api-integration.mdx (5)
52-157: LGTM! Well-structured example with good practices.The complete workflow example demonstrates proper error handling, clear step-by-step process, and helpful console output. The placeholder credentials and component IDs are appropriately marked as examples that users need to replace.
167-214: LGTM! Comprehensive vector store configurations.The examples cover multiple popular vector store types with appropriate configuration parameters for each, helping users understand the tweaks structure for different backends.
220-304: LGTM! Excellent advanced RAG flow example.The multi-component configuration demonstrates a realistic RAG pipeline with proper component organization and comprehensive tweaks. The component ID dictionary pattern is a good practice that improves maintainability.
358-396: LGTM! Useful debugging utility.The debug function provides clear, actionable feedback for troubleshooting flow execution issues. The hierarchical error checking pattern is well-designed.
398-423: LGTM! Comprehensive best practices guidance.The best practices section covers key areas including security, performance, and maintainability with practical, actionable recommendations.
docs/docs/Develop/streamlit-integration-example.mdx (4)
31-103: LGTM! Well-designed client class for Streamlit.The
LangflowClientclass provides a clean interface for Langflow integration with proper method separation and error handling. The implementation correctly handles Streamlit'sUploadedFileobjects in theupload_filemethod.
104-158: LGTM! Well-structured Streamlit configuration UI.The sidebar configuration provides clear inputs with helpful guidance. Good use of environment variables for defaults and proper handling of sensitive API keys with password input type.
164-191: LGTM! Robust file upload implementation.The file upload section handles multiple files with proper error handling for individual failures, progress indication, and clear user feedback. The file type restrictions are appropriate for document processing workflows.
276-323: LGTM! Clear configuration guidance.The flow configuration guide provides step-by-step instructions for setting up the integration, including a helpful visual diagram of the component flow and practical tweaks examples.
docs/docs/API-Reference/api-reference-api-examples.mdx (4)
29-136: LGTM! Excellent multi-language examples.The tabbed examples provide clear progression from cURL to synchronous and asynchronous Python implementations. The consistency across examples helps users understand the same operation in different contexts.
228-341: LGTM! Professional-quality client implementation.The
LangflowFileUploadClientclass is well-architected with proper type hints, comprehensive error handling, and thoughtful method design. Therun_flow_with_filesmethod's**component_tweaksparameter provides good extensibility for additional component configuration.
342-397: LGTM! Complete end-to-end workflow example.The
complete_workflow_examplefunction demonstrates the entire process clearly with helpful console output and proper error handling. The step-by-step structure makes it easy for users to adapt to their needs.
211-484: LGTM! Comprehensive file upload workflow documentation.The new "Complete File Upload Workflow" section significantly enhances the API documentation by providing production-ready examples that bridge the gap between basic API calls and real-world application integration. The progression from Python client to complete workflow to frontend examples is well-structured.
| ## Next Steps | ||
|
|
||
| - [Explore more Langflow API examples](../API-Reference/api-reference-api-examples) | ||
| - [Learn about file management in Langflow](../concepts-file-management) | ||
| - [Build custom Streamlit interfaces with different Langflow flows](https://github.com/langflow-ai/langflow/discussions) No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify documentation link path.
Line 372 references ../concepts-file-management, but based on the sidebar structure, the file management documentation is located at ../Develop/concepts-file-management (under the Develop section, Storage and memory subsection).
Run the following script to verify the correct path:
🏁 Script executed:
#!/bin/bash
# Find the file management documentation
fd -t f "concepts-file-management.mdx" docs/
# Check its location relative to Develop directory
fd -t f "concepts-file-management.mdx" docs/ --exec echo "Found: {}"Length of output: 100
Fix incorrect relative link path.
Line 372 references ../concepts-file-management, but since concepts-file-management.mdx is located in the same Develop directory as streamlit-integration-example.mdx, the correct relative path should be ./concepts-file-management (or simply concepts-file-management).
🤖 Prompt for AI Agents
In docs/docs/Develop/streamlit-integration-example.mdx around lines 369 to 373,
the relative link to the concepts-file-management page is incorrect (uses
../concepts-file-management) even though concepts-file-management.mdx is in the
same Develop directory; update the link to use a same-directory relative path
such as ./concepts-file-management or simply concepts-file-management so it
resolves correctly.
| ```python | ||
| def detect_flow_components(flow_id: str): | ||
| """Get component information from a flow""" | ||
|
|
||
| # First, get the flow details | ||
| response = requests.get( | ||
| f"{langflow_url}/api/v1/flows/{flow_id}", | ||
| headers={"x-api-key": api_key} | ||
| ) | ||
|
|
||
| if response.status_code == 200: | ||
| flow_data = response.json() | ||
|
|
||
| # Extract component information | ||
| vertices = flow_data.get("data", {}).get("vertices", {}) | ||
|
|
||
| component_map = {} | ||
| for vertex_id, vertex_data in vertices.items(): | ||
| component_type = vertex_data.get("type", "") | ||
| display_name = vertex_data.get("template", {}).get("display_name", "") | ||
|
|
||
| # Map common component types | ||
| if "File" in component_type: | ||
| component_map["file"] = vertex_id | ||
| elif any(store in component_type for store in ["Chroma", "Pinecone", "FAISS", "Astra"]): | ||
| component_map["vector_store"] = vertex_id | ||
| elif "Embeddings" in component_type: | ||
| component_map["embeddings"] = vertex_id | ||
| elif "Splitter" in component_type or "Text" in component_type: | ||
| component_map["text_splitter"] = vertex_id | ||
| elif "Retriever" in component_type: | ||
| component_map["retriever"] = vertex_id | ||
| elif "LLM" in component_type or "OpenAI" in component_type or "Model" in component_type: | ||
| component_map["llm"] = vertex_id | ||
|
|
||
| return component_map | ||
|
|
||
| return {} | ||
|
|
||
| # Usage | ||
| component_map = detect_flow_components(flow_id) | ||
| print("Detected components:", component_map) | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix missing function parameters.
The detect_flow_components function references langflow_url and api_key variables (lines 316, 317) that are not defined in the function parameters. This will cause a NameError when the function is called.
Apply this diff to fix the issue:
-def detect_flow_components(flow_id: str):
+def detect_flow_components(flow_id: str, langflow_url: str, api_key: str):
"""Get component information from a flow"""
# First, get the flow detailsAlso update the usage example:
# Usage
-component_map = detect_flow_components(flow_id)
+component_map = detect_flow_components(flow_id, langflow_url, api_key)
print("Detected components:", component_map)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ```python | |
| def detect_flow_components(flow_id: str): | |
| """Get component information from a flow""" | |
| # First, get the flow details | |
| response = requests.get( | |
| f"{langflow_url}/api/v1/flows/{flow_id}", | |
| headers={"x-api-key": api_key} | |
| ) | |
| if response.status_code == 200: | |
| flow_data = response.json() | |
| # Extract component information | |
| vertices = flow_data.get("data", {}).get("vertices", {}) | |
| component_map = {} | |
| for vertex_id, vertex_data in vertices.items(): | |
| component_type = vertex_data.get("type", "") | |
| display_name = vertex_data.get("template", {}).get("display_name", "") | |
| # Map common component types | |
| if "File" in component_type: | |
| component_map["file"] = vertex_id | |
| elif any(store in component_type for store in ["Chroma", "Pinecone", "FAISS", "Astra"]): | |
| component_map["vector_store"] = vertex_id | |
| elif "Embeddings" in component_type: | |
| component_map["embeddings"] = vertex_id | |
| elif "Splitter" in component_type or "Text" in component_type: | |
| component_map["text_splitter"] = vertex_id | |
| elif "Retriever" in component_type: | |
| component_map["retriever"] = vertex_id | |
| elif "LLM" in component_type or "OpenAI" in component_type or "Model" in component_type: | |
| component_map["llm"] = vertex_id | |
| return component_map | |
| return {} | |
| # Usage | |
| component_map = detect_flow_components(flow_id) | |
| print("Detected components:", component_map) | |
| ``` | |
| def detect_flow_components(flow_id: str, langflow_url: str, api_key: str): | |
| """Get component information from a flow""" | |
| # First, get the flow details | |
| response = requests.get( | |
| f"{langflow_url}/api/v1/flows/{flow_id}", | |
| headers={"x-api-key": api_key} | |
| ) | |
| if response.status_code == 200: | |
| flow_data = response.json() | |
| # Extract component information | |
| vertices = flow_data.get("data", {}).get("vertices", {}) | |
| component_map = {} | |
| for vertex_id, vertex_data in vertices.items(): | |
| component_type = vertex_data.get("type", "") | |
| display_name = vertex_data.get("template", {}).get("display_name", "") | |
| # Map common component types | |
| if "File" in component_type: | |
| component_map["file"] = vertex_id | |
| elif any(store in component_type for store in ["Chroma", "Pinecone", "FAISS", "Astra"]): | |
| component_map["vector_store"] = vertex_id | |
| elif "Embeddings" in component_type: | |
| component_map["embeddings"] = vertex_id | |
| elif "Splitter" in component_type or "Text" in component_type: | |
| component_map["text_splitter"] = vertex_id | |
| elif "Retriever" in component_type: | |
| component_map["retriever"] = vertex_id | |
| elif "LLM" in component_type or "OpenAI" in component_type or "Model" in component_type: | |
| component_map["llm"] = vertex_id | |
| return component_map | |
| return {} | |
| # Usage | |
| component_map = detect_flow_components(flow_id, langflow_url, api_key) | |
| print("Detected components:", component_map) |
🤖 Prompt for AI Agents
In docs/docs/Develop/vector-store-api-integration.mdx around lines 310 to 352,
the detect_flow_components function uses undefined globals langflow_url and
api_key; change the function signature to accept langflow_url and api_key as
parameters, replace references to the globals with those parameters, and update
the usage example to call detect_flow_components(flow_id, langflow_url, api_key)
(or pass concrete values/variables) so the function has the required inputs.
| ## Next Steps | ||
|
|
||
| - [Complete Streamlit integration example](./streamlit-integration-example) | ||
| - [Langflow API reference](../API-Reference/api-reference-api-examples) | ||
| - [Vector store documentation](../Components/components-vector-stores) | ||
| - [Best practices for RAG flows](https://github.com/langflow-ai/langflow/discussions) No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify the vector store documentation link.
Line 428 references ../Components/components-vector-stores, but based on the sidebar structure in sidebars.js, there doesn't appear to be a dedicated vector stores documentation page. Vector store components are likely covered in the bundles section or the data components section.
Run the following script to check if the referenced documentation file exists:
🏁 Script executed:
#!/bin/bash
# Check if the vector stores documentation exists
fd -t f "components-vector-stores.mdx" docs/
# Also search for vector store related documentation
fd -t f -e mdx . docs/docs/Components/ | xargs grep -l "vector store" -iLength of output: 1177
Fix broken vector store documentation link.
Line 428 references a non-existent file. The path ../Components/components-vector-stores should be ../Components/components-bundles, which contains vector store component documentation.
🤖 Prompt for AI Agents
In docs/docs/Develop/vector-store-api-integration.mdx around lines 424 to 429,
the "Vector store documentation" link points to a non-existent path
../Components/components-vector-stores; update that link to
../Components/components-bundles so it points to the actual vector store
component documentation, keeping the link text the same and preserving Markdown
list formatting.
\ud83d\udd27 Automated Fix\n\nThis PR addresses issue #10694: Add documentation/examples for file uploads via Python API\n\n### \ud83d\udccb Issue Reference\nCloses #10694\nOriginal issue: https://github.com/langflow-ai/langflow/issues/10694\n\n### \ud83e\udd16 How This Was Generated\nThis fix was automatically generated using AI-powered code analysis and remediation:\n- Tool: Kilo AI Code Assistant\n- Analysis: Analyzed the issue description and codebase context\n- Implementation: Applied targeted fixes based on best practices\n\n### \u2705 Changes Made\nPlease review the changes in the Files Changed tab. The modifications were made to address the specific requirements outlined in the issue.\n\n### \ud83e\uddea Testing\nPlease verify:\n1. The fix addresses the issue as described\n2. No regressions are introduced\n3. Code quality and style are maintained\n\n---\nGenerated by Soulcaster AI Agent\n
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.