Langflow 简单使用

安装

Copy
uv pip install langflow -U

运行

Copy
uv run langflow run --env-file .env

.env 配置

Copy
LANGFLOW_AUTO_LOGIN=False
LANGFLOW_SUPERUSER=admin
LANGFLOW_SUPERUSER_PASSWORD=password
LANGFLOW_SECRET_KEY=secret_key
LANGFLOW_NEW_USER_IS_ACTIVE=False
LANGFLOW_CONFIG_DIR=./config

自定义 python 代码组件

Copy
# from langflow.field_typing import Data
from langflow.custom import Component
from langflow.io import MessageTextInput, Output
from langflow.schema import Data

class CustomComponent(Component):
display_name = "ParseChatResponse"
description = "Use as a template to create your own component."
documentation: str = "https://dmentx.github.io/law-langflow/components-custom-components"
icon = "custom_components"
name = "CustomComponent"

inputs = [
MessageTextInput(name="input_value", display_name="Input Value", value="Hello, World!"),
]

outputs = [
Output(display_name="Output", name="output", method="build_output"),
]

def build_output(self) -> Data:
data = Data(text=self.input_value, character="vtuber")
self.status = data
return data