Flowise 視覺化 AI Agent 建構平台

使用 Flowise 透過拖放介面快速建構 LLM 應用、Chatbot、AI Agent,無需編寫程式碼

專案簡介

Flowise 是一個開源的低程式碼平台,讓你透過視覺化介面建構 AI 應用。支援 LangChain 和 LlamaIndex,可快速部署 Chatbot、RAG 系統和 AI Agent。

GitHub Stars: 48K+

主要功能

  • 視覺化建構 - 拖放元件設計流程
  • LangChain 整合 - 完整元件支援
  • API 部署 - 一鍵產生 API
  • 多模型 - OpenAI、Anthropic、本地模型
  • 記憶功能 - 對話歷史管理

安裝

npm 安裝

1
2
npm install -g flowise
flowise start

Docker 部署

1
2
3
docker run -d -p 3000:3000 \
  --name flowise \
  flowiseai/flowise

訪問 http://localhost:3000

Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
version: '3.8'
services:
  flowise:
    image: flowiseai/flowise
    ports:
      - "3000:3000"
    environment:
      - FLOWISE_USERNAME=admin
      - FLOWISE_PASSWORD=password
      - DATABASE_PATH=/root/.flowise
      - APIKEY_PATH=/root/.flowise
    volumes:
      - flowise-data:/root/.flowise

volumes:
  flowise-data:

基本操作

建立 Chatflow

  1. 點擊「Add New」
  2. 從側邊欄拖入元件
  3. 連接元件
  4. 設定參數
  5. 儲存並測試

核心元件類別

類別元件範例
Chat ModelsChatOpenAI、ChatAnthropic、ChatOllama
LLMsOpenAI、HuggingFace、Replicate
EmbeddingsOpenAI Embeddings、HuggingFace
Vector StoresPinecone、Chroma、FAISS
MemoryBuffer Memory、Redis Memory
ToolsCalculator、SerpAPI、Custom Tool

建構 Chatbot

簡單對話機器人

1
2
3
[Chat OpenAI] → [Conversation Chain] → [Output]
[Buffer Memory]

設定步驟

  1. 拖入 ChatOpenAI
  2. 設定 API Key 和模型
  3. 拖入 Conversation Chain
  4. 加入 Buffer Memory
  5. 連接並測試

建構 RAG 系統

流程架構

1
2
3
4
5
6
7
[PDF File] → [Recursive Text Splitter] → [OpenAI Embeddings]
[Question] → [Retrieval QA Chain] ← [In-Memory Vector Store]
              [ChatOpenAI]
               [Answer]

實作步驟

  1. 文件載入

    • 拖入 PDF File Loader
    • 上傳文件
  2. 文字切割

    • 拖入 Recursive Text Splitter
    • 設定 chunk size: 1000
    • 設定 overlap: 200
  3. 向量儲存

    • 拖入 OpenAI Embeddings
    • 拖入 In-Memory Vector Store
  4. 問答鏈

    • 拖入 Retrieval QA Chain
    • 連接 ChatOpenAI

建構 AI Agent

ReAct Agent

1
2
3
[Tools] → [ReAct Agent] → [Output]
        [ChatOpenAI]

可用工具

  • Calculator - 數學計算
  • Web Browser - 網頁瀏覽
  • SerpAPI - 網路搜尋
  • Custom Tool - 自訂工具

自訂工具

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Custom Tool 設定
{
  "name": "SecurityCheck",
  "description": "Check if a URL is secure",
  "code": `
    const url = $input;
    // 實作檢查邏輯
    return result;
  `
}

API 使用

取得 API

  1. 儲存 Chatflow
  2. 點擊「API Endpoint」
  3. 複製 API URL 和 Key

呼叫 API

1
2
3
4
curl -X POST "http://localhost:3000/api/v1/prediction/{chatflow-id}" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {api-key}" \
  -d '{"question": "What is SQL injection?"}'

Python 整合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import requests

response = requests.post(
    "http://localhost:3000/api/v1/prediction/chatflow-id",
    headers={
        "Authorization": "Bearer api-key",
        "Content-Type": "application/json"
    },
    json={"question": "Explain XSS attacks"}
)

print(response.json())

串流回應

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import requests

response = requests.post(
    "http://localhost:3000/api/v1/prediction/chatflow-id",
    headers={"Authorization": "Bearer api-key"},
    json={"question": "Hello", "streaming": True},
    stream=True
)

for chunk in response.iter_content(chunk_size=None):
    print(chunk.decode(), end="", flush=True)

嵌入網站

Embed Widget

1
2
3
4
5
6
7
<script type="module">
  import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
  Chatbot.init({
    chatflowid: "your-chatflow-id",
    apiHost: "http://localhost:3000",
  })
</script>

自訂樣式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Chatbot.init({
  chatflowid: "chatflow-id",
  apiHost: "http://localhost:3000",
  theme: {
    button: {
      backgroundColor: "#3B81F6",
      size: "medium"
    },
    chatWindow: {
      title: "Security Assistant",
      welcomeMessage: "How can I help you with security today?"
    }
  }
})

進階設定

認證

1
2
3
environment:
  - FLOWISE_USERNAME=admin
  - FLOWISE_PASSWORD=securepassword

資料庫

1
2
3
4
5
6
7
environment:
  - DATABASE_TYPE=postgres
  - DATABASE_HOST=postgres
  - DATABASE_PORT=5432
  - DATABASE_USER=flowise
  - DATABASE_PASSWORD=password
  - DATABASE_NAME=flowise

API Key 管理

1
2
environment:
  - FLOWISE_SECRETKEY_OVERWRITE=your-secret-key

相關連結

延伸閱讀

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy