Flowise|无代码 ChatBot 构建平台|LangChain

技术

picture.image

picture.image

picture.image

点击上方蓝字关注我们

前面给大家介绍了一些在线构建聊天机器人和私有化离线部署LLM模型建立知识库的方案,如Quivr结合Supabase、PrivateGPT、ChatGLM 6B 等, 基本上这些解决方案的背后整体的核心都离不开一个关键技术,就是LangChain。其次这些技术或多或少需要一定的技术开发基础,对于普通大众也希望快速借助ChatGPT构建自己的APP应用,有没有比较好的解决方案呢? 答案显然是有的。

今天就给大家介绍一款无代码平台Flowise,它基于 LangChain.js 提供了丰富的内置组件,方便我们通过拖拉拽的方式,以非常直观可视化的方式快速构建属于我们自己的聊天机器人、智能客户、知识问答等应用。同时,也可以非常方便的集成到自己的产品中去。

picture.image

一、Flowise介绍

Flowise 是一个开源项目,将永远免费供商业和个人使用。

Flowise 基于🦜️🔗 LangChain.js ,是一个非常先进的图形用户界面,用于开发基于 LLM 的应用程序。这些应用程序也称为 Gen Apps、LLM Apps、Prompt Chaining、LLM Chains 等。

Flowise 是专门为 LangChain 打造的用户界面 (UI),利用了 React-Flow 技术。其目的是提供一个无缝平台,用于轻松进行流程实验和原型设计。用户可以享受拖放组件和聊天框功能的便利,以增强他们的体验。

picture.image

picture.image

二、Flowise安装

项目地址:https://github.com/FlowiseAI/Flowise

2.1、NPM部署

picture.image

下载并安装NodeJS >= 18.15.0

1、安装 Flowise

npm install -g flowise

2、启动流程

npx flowise start

有用户名和密码(推荐)

npx flowise start --FLOWISE_USERNAME=user --FLOWISE_PASSWORD=1234

3、打开http://localhost:3000

2.2、Docker部署

picture.image

Docker Compose

1、转到docker项目根目录下的文件夹

2、创建.env文件并指定PORT(参考.env.example)

3、启动容器docker-compose up -d

4、打开http://localhost:3000

5、您可以通过以下方式将容器放下docker-compose stop

Docker Image

1、在本地构建镜像:

docker build --no-cache -t flowise .

2、运行镜像:

docker run -d --name flowise -p 3000:3000 flowise

3、停止镜像:

docker stop flowise

2.3、开发环境

picture.image

Flowise在单一的代码仓库中有三个不同的模块。

  • server: Node后端用于提供API逻辑
  • ui: React前端
  • components: LangChain组件
2.3.1、先决条件

安装Yarn

npm i -g yarn

2.3.2、安装步骤

1、克隆仓库

git clone https://github.com/FlowiseAI/Flowise.git

2、进入仓库文件夹

cd Flowise

3、安装所有模块的依赖:


      
          
  
yarn install
      
    

4、构建所有代码:

yarn build

5、启动应用程序:

yarn start

现在可以通过 http://localhost:3000 访问应用程序了。

6、若要进行开发构建:

yarn dev

任何代码更改都会自动重新加载应用程序,使用地址为 http://localhost:8080。

picture.image

三、授权

Flowise有两种授权方式:

  • 应用级别
  • 聊天流程级别

3.1、应用级别

picture.image

应用级别的授权通过用户名和密码来保护您的Flowise实例。这可以防止您的应用在部署在线时被任何人访问。

picture.image

3.2、聊天流程级别

picture.image

假设您已经构建了一个聊天流程,并且只希望特定的人能够访问和交互。您可以通过为该特定聊天流程分配API密钥来实现。

3.3、API密钥

picture.image

在仪表板中,导航到API密钥部分,您应该能够看到创建了一个DefaultKey。您也可以添加或删除任何密钥。

picture.image

3.4、聊天流程

picture.image

导航至 Chatflow,现在您可以选择要使用的 API 密钥来保护 Chatflow。

picture.image

分配 API 密钥后,在进行 HTTP 调用时,只有提供了正确的 API 密钥所指定的 Authorization 头部,才可以访问 Chatflow API。

"Authorization": "Bearer "

以下是使用 POSTMAN 调用 API 的示例:

picture.image

3.5、设置用户名和密码

picture.image

3.5.1、NPM

1、安装Flowise

npm install -g flowise

2、用用户名和密码启动Flowise

npx flowise start --FLOWISE_USERNAME=user --FLOWISE_PASSWORD=1234

3、打开http://localhost:3000

3.5.2、Docker

1、进入docker文件夹

cd docker

2、创建.env文件并指定端口,FLOWISEUSERNAME和FLOWISEPASSWORD

PORT=3000
FLOWISE_USERNAME=user
FLOWISE_PASSWORD=1234

3、将FLOWISEUSERNAME和FLOWISEPASSWORD传递给docker-compose.yml文件:

environment:
- PORT=PORTFLOWISE_USERNAME={PORT} - FLOWISE\_USERNAME={FLOWISE_USERNAME}
- FLOWISE_PASSWORD=${FLOWISE_PASSWORD}

4、docker-compose up -d

5、打开 http://localhost:3000

6、您可以通过docker-compose stop将容器关闭

3.5.3、Git克隆(本地)

要启用应用程序级身份验证,请将FLOWISEUSERNAME和FLOWISEPASSWORD添加到packages / server中的.env文件中:

FLOWISE_USERNAME=user
FLOWISE_PASSWORD=1234

picture.image

四、应用集成

现在你已经在Flowise的聊天界面上测试了你的聊天流程,你想要“导出”它以便在其他应用程序中使用。Flowise提供了两种方法来实现这一点:

  • API
  • Embed

4.1、API

picture.image

你可以将聊天流程作为API使用,并连接到前端应用程序。

picture.image

4.2、Embed

picture.image

您也可以在您的网站上嵌入一个聊天小工具。

只需将所提供的嵌入代码复制粘贴到您html文件的标签的任何地方。

picture.image

picture.image

picture.image

五、向量数据库

5.1、Pinecone

picture.image

5.1.1、先决条件

1、注册一个帐户

2、单击“创建第一个索引”

picture.image

3、输入必填字段

索引名称 ,要创建的索引的名称。(例如:elon-musk)

维度 ,要插入索引中的向量的大小。(例如:1536)

picture.image

4、单击“创建索引”

5.1.2、设置

1、获取/创建您的API密钥

picture.image

2、将每个详细信息(API密钥、环境、索引名称)复制并粘贴到Pinecone Upsert Document节点或Pinecone Load Existing Index节点中

picture.image picture.image

3、文档可以与类别下的任何节点连接 嵌入可以与类别下的任何节点连接

4、嵌入可以与类别下的任何节点连接

5.2、Supabase

picture.image

5.2.1、先决条件

1、为Supabase注册一个帐户

2、点击“新建项目”

picture.image

3、输入必填字段

名称 ,要创建的项目名称(例如Flowise)。

数据库密码 ,用于您的postgres数据库的密码。(例如,单击“生成密码”)

picture.image

4、点击“创建新项目”,等待项目完成设置

5、单击SQL编辑器

picture.image

6、单击“新查询”

picture.image

7、复制并粘贴查询,通过Ctrl + Enter运行它或单击RUN

表名:documents

查询名称:match_documents

-- Enable the pgvector extension to work with embedding vectors
create extension vector;

-- Create a table to store your documents
create table documents (
id bigserial primary key,
content text, -- corresponds to Document.pageContent
metadata jsonb, -- corresponds to Document.metadata
embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);

-- Create a function to search for documents
create function match_documents (
query_embedding vector(1536),
match_count int DEFAULT null,
filter jsonb DEFAULT '{}'
) returns table (
id bigint,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
where metadata @> filter
order by documents.embedding <=> query_embedding
limit match_count;
end;

![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/e2e7d91e78ac4041ab877855cdacee72~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=Z1HbKSY2eKrEh3rpn0%2Bipb8WIi0%3D) **5.2.2、设置** ============= 1、点击项目设置 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/17a0bc3331f84f6194f8e2f344384ad8~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=Cu35QlN%2BYBV0T1UXygwHjn01I5o%3D) 2、获取您的项目网址和API密钥 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/aa5ccbb9859444d6800ad23bf7d1d8cf~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=%2BmM1X9SQTW3zduubGM5YLVMEYCo%3D) 3、将每个细节(API密钥、网址、表名、查询名称)复制并粘贴到Supabase Upsert文档节点或Supabase加载现有节点中 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/8316ce7b6146439b80f1d71c1bbf5a89~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=R8gUZQBloYarxlPEWipmdQ9gLyM%3D) ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/e9b0136f1fb24e7abec69ee3619f19ed~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=fv90AaaorArs5Ps42ZPK5rjQfh8%3D) 4、文档可以连接到文档加载器类别下的任何节点 5、嵌入可以连接到嵌入类别下的任何节点 5.3、Chroma ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) **5.3.1、先决条件** =============== 1、下载并安装Docker和Git 2、使用终端克隆Chroma的存储库 git clone https://github.com/chroma-core/chroma.git 3、更改目录路径到您克隆的Chroma cd chroma ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/542de623670043cbbc5981fd6b86ed51~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=WoQtWYK0W1a4CAJA8denAmo6TW0%3D) 4、运行docker compose来构建Chroma镜像和容器 docker-compose up -d --build ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/6b54a738c8264c44880068ca01846741~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=4%2BeDMDObtJuZ3QtGjvZ%2Fnop0w%2BY%3D) **5.3.2、设置** ============= 1、将收集名称输入到Chroma Upsert Document节点或Chroma Load Existing Index节点中(例如elon-musk)。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/7074fb252ec94f23a85f86c371cf5687~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=fhfuz9nQlvuNh4jF8qnyc6Xid8I%3D) ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/5f1e7b6423d74891bdf33e84fc157987~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=4DRkAZ69nRcJPo8E4UdemDTah68%3D) 2、文档可以与“文档加载器”类别下的任何节点连接。 3、嵌入可以与“嵌入”类别下的任何节点连接。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/79e58be43ac243a1a97ecd8c56ac258b~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=c4fUTjSb2dVuGtPf6oGADYBTq0s%3D) 六、构建LLM Apps LLM应用程序构建生态系统中出现了许多构建块,包括提示工程、代理、链式、语义搜索、聊天模型、向量存储和各种可以分配给代理以执行操作的工具。 这些新方法使得构建灵活的对话界面变得更加容易。使用基于LLM的聊天流,对话设计和构建过程不再需要过度细致,不必处理太多的例外情况、闲聊(小聊天)或修复路径等细节问题,因为这些问题可以转移到LLM的弹性上。 需要注意的是,尽管Flowise免费使用,但也需要考虑托管成本和所有第三方API调用所产生成本。这些成本可能会随着用户数量增加而迅速上升,并且取决于这些系统被利用的程度。 另一个需要考虑的因素是延迟,以及需要访问地理上分散的系统等等。 Flowise确实是一个非常直观的LLM应用程序开发框架。尽管我在使用Flowise进行原型制作的早期阶段,但我确实感受到Flowise比LangFlow更加全面完整的开发UI。 6.1、聊天面板 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) 下面您可以看到仪表板,其中包括API密钥、市场和聊天流程。请注意,列出了构成聊天流程的开发组件。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/9d9adf842e2541ac94699fca323da4f5~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=Zv30SPMxSQIX8NGhPlSTMl%2FGMUQ%3D) 6.2、应用市场 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) Flowise还提供了一个应用市场,其中包含相当数量的预配置应用程序,可以帮助用户快速构建可工作的原型。这些预配置应用程序可以缩短开发时间,使用户能够更快地获得所需的结果。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/1478c0dbbdf64897a0d0d742c13fcb2e~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=tulRFOyuGFMOJk6Z%2FdMspU9jnWA%3D) 6.3、天气机器人 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) 下面的应用程序是一个基本的天气机器人,可能是可以编写的最简单的LLM链,只有三个组件:OpenAI连接器、提示模板和将两者连接起来的LLM链。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/afc1e72675ca4edf9da22af98e422b7c~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=NRmzMEqIgC1U7%2BRQov7oik%2B6Q2c%3D) 6.4、翻译机器人 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) 下面的应用程序展示了一个基本的翻译机器人,它还说明了提示词如何被格式化。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/187fdd766acf42bb9ace105fa524dd27~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=MUjYWQHGibUw%2B7f54Tw6qm8sPN4%3D) 6.5、综合机器人 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/de9e474e63a8466d9ae36937f421e2c2~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=blvjOihoplhyZWsZmKrATHhZGfE%3D) 下面是一个综合知识对话机器人,它利用了OpenAI、Serp API和具有对话记忆功能。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/ce11d69e247c442586ef1bc4a7fda6f1~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=qk6oN%2FmX6dK5X9qPnihJ0859dpU%3D) ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/79e58be43ac243a1a97ecd8c56ac258b~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=c4fUTjSb2dVuGtPf6oGADYBTq0s%3D) 七、ChatPDF APP 我们前面有介绍过很多种实现文档聊天的方案,比如 **Quivr结合Supabase、PrivateGPT、ChatGLM 6B** 等多种不同的解决方案,基本上都涉及到不同程度的应用开发,今天我们来使用Flowise无代码快速构建一个PDF文档聊天机器人。不写一句代码,直接拖拉拽的方式即可实现类似的效果。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/5ae2f99da2504283a36d258b12b710f6~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=%2FH9IdMS4Jg%2FXEjdFHQ35oN1OZMY%3D) 根据上述文档问答的流程架构图,我们在Flowise中将上述流程配置出来,如下图所示: ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/c411de284b9b452d9d093ac52d0813c0~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=3pqecCbE7RWM0T7oYLN%2BtPfk5rc%3D) 只需要配置好OpenAI key、设置Chunk Size、Chunk Overlap即可进行使用。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/bde7622fd87348cf829077fff251e8ed~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=lnkZvsrkLJK8M0spkGJFeQ14CuU%3D) ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/79e58be43ac243a1a97ecd8c56ac258b~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=c4fUTjSb2dVuGtPf6oGADYBTq0s%3D) 八、总结 **Flowise** 和 **LangChain** 是两个基于LLM(大型语言模型)的应用构建工具。本文主要介绍了如何利用Flowise和LangChain快速构建LLM应用。 通过结合Flowise和LangChain,开发者可以快速构建基于LLM的自然语言处理应用,实现文本分析、问答、文本生成等功能。Flowise提供了易用的界面和丰富的API接口,帮助开发者快速将自然语言处理任务集成到应用中。LangChain提供了多语言支持和统一的平台,帮助开发者在多个语言和领域中实现自然语言处理应用。结合Flowise和LangChain,开发者可以更加高效地构建基于LLM的自然语言处理应用,为用户提供更加智能和便捷的服务。 ![picture.image](https://p3-volc-community-sign.byteimg.com/tos-cn-i-tlddhu82om/ad159b35e3d24c0fb5f8d50bd09ebcf7~tplv-tlddhu82om-image.image?=&rk3s=8031ce6d&x-expires=1745711829&x-signature=l24YHqmFRRhd96eAWhARrk3wo6g%3D)
0
0
0
0
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论