-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Docs] How to contribute components #1838
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8de4812
initial-content
mendonk 429661a
nav
mendonk 40ebdd3
links
mendonk fbae9f5
Merge branch 'dev' into docs-how-to-contribute-components
mendonk 436c290
submit-to-store
mendonk a9a1259
Merge branch 'dev' into docs-how-to-contribute-components
mendonk b0a9692
fix-folder-path
mendonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import ZoomableImage from "/src/theme/ZoomableImage.js"; | ||
|
||
# How to contribute components? | ||
|
||
As of Langflow 1.0 alpha, new components are added as objects of the [CustomComponent](https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/interface/custom/custom_component/custom_component.py) class and any dependencies are added to the [pyproject.toml](https://github.com/langflow-ai/langflow/blob/dev/pyproject.toml#L27) file. | ||
|
||
## Add an example component | ||
|
||
You have a new document loader called **MyCustomDocumentLoader** and it would look awesome in Langflow. | ||
|
||
1. Write your loader as an object of the [CustomComponent](https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/interface/custom/custom_component/custom_component.py) class. You'll create a new class, `MyCustomDocumentLoader`, that will inherit from `CustomComponent` and override the base class's methods. | ||
2. Define optional attributes like `display_name`, `description`, and `documentation` to provide information about your custom component. | ||
3. Implement the `build_config` method to define the configuration options for your custom component. | ||
4. Implement the `build` method to define the logic for taking input parameters specified in the `build_config` method and returning the desired output. | ||
5. Add the code to the [/components/documentloaders](https://github.com/langflow-ai/langflow/tree/dev/src/backend/base/langflow/components) folder. | ||
6. Add the dependency to [/documentloaders/\_\_init\_\_.py](https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/components/documentloaders/__init__.py) as `from .MyCustomDocumentLoader import MyCustomDocumentLoader`. | ||
7. Add any new dependencies to the outer [pyproject.toml](https://github.com/langflow-ai/langflow/blob/dev/pyproject.toml#L27) file. | ||
8. Submit documentation for your component. For this example, you'd submit documentation to the [loaders page](https://github.com/langflow-ai/langflow/blob/dev/docs/docs/components/loaders.mdx). | ||
8. Submit your changes as a pull request. The Langflow team will have a look, suggest changes, and add your component to Langflow. | ||
|
||
## User Sharing | ||
|
||
You might want to share and test your custom component with others, but don't need it merged into the main source code. | ||
|
||
If so, you can share your component on the Langflow store. | ||
|
||
1. [Register at the Langflow store](https://www.langflow.store/login/). | ||
2. Undergo pre-validation before receiving an API key. | ||
3. To deploy your amazing component directly to the Langflow store, without it being merged into the main source code, navigate to your flow, and then click **Share**. | ||
The share window appears: | ||
|
||
<ZoomableImage | ||
alt="Docusaurus themed image" | ||
sources={{ | ||
light: "img/add-component-to-store.png", | ||
dark: "img/add-component-to-store.png", | ||
}} | ||
style={{ width: "50%", margin: "20px auto" }} | ||
/> | ||
|
||
5. Choose whether you want to flow to be public or private. | ||
You can also **Export** your flow as a JSON file from this window. | ||
When you're ready to share the flow, click **Share Flow**. | ||
You should see a **Flow shared successfully** popup. | ||
6. To confirm, navigate to the **Langflow Store** and filter results by **Created By Me**. You should see your new flow on the **Langflow Store**. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
User Sharing
You might want to share and test your custom component with others. If so, you can:
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.
Writing a pull request and waiting for review might be challenging for some. It would be beneficial to recommend using the Langflow store in this case. If there is documentation related to the Langflow store, it would be appropriate to provide a link to that document.
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.
Thanks @yamonkjd, this is good feedback. I added some info on submitting the store, wdyt?