ข้ามไปยังเนื้อหา
AggregaAggregaAggregaAggrega
เลือกภาษา: ไทย
หน้านี้ถูกแปลด้วยเครื่อง อ่านต้นฉบับภาษาอังกฤษ

นำเข้า chatflow ของ Flowise

บทแนะนำทีละขั้นตอนนี้นำเข้า chatflow ที่ส่งออกจาก Flowise — chain การสนทนาที่มีโมเดลแชตและหน่วยความจำ — เป็น Aggregate, Release และ Manifest ที่บิลด์ Flowise พร้อม chatflow สำหรับ Docker Compose ตามที่เขียนไว้ จากนั้นบิลด์สิ่งเหล่านั้นและรันสิ่งที่บิลด์ได้ ทุกไฟล์และทุกบล็อกของเอาต์พุตด้านล่างมาจากการรันจริง chatflow และแต่ละขั้นตอนของบทแนะนำอยู่ในตัวอย่าง import-flowise ซึ่งสคริปต์ตรวจสอบรันการนำเข้าอีกครั้ง เปรียบเทียบสิ่งที่นำเข้าเขียน สิ่งที่พิมพ์ และบล็อกที่หน้านี้อ้างกับไฟล์ที่เก็บไว้ที่นั่น และตรวจสอบความถูกต้องและบิลด์สิ่งที่การนำเข้าเขียน

ร่างตัวอย่าง

คุณรันการนำเข้านี้ด้วยคำสั่งในหน้านี้ได้ หรือ ให้ผู้ช่วย AI ของคุณรันให้

เขียนตัวอย่างลงในโฟลเดอร์ใหม่ที่ตั้งชื่อตามตัวอย่าง:

Terminal window
aggrega draft --example import-flowise

จากนั้นจะพิมพ์คำสั่งที่ต้องรันต่อไป คำสั่งแรกเปลี่ยนไปที่โฟลเดอร์ใหม่ คำสั่งถัดไปด้านล่างเปลี่ยนไปที่โฟลเดอร์ source ของโฟลเดอร์นั้น ซึ่งเป็นที่ที่การนำเข้ารัน โฟลเดอร์นั้นมีไฟล์ chatflow คือ support-chat.json ซึ่งหน้านี้อธิบายแทนที่จะยกมาทั้งหมด:

Terminal window
cd import-flowise

โฟลเดอร์ source ของตัวอย่างที่ร่างไว้เปิดอยู่ใน Visual Studio Code แสดงไฟล์ส่งออก chatflow ของ Flowise ของแชตสนับสนุน โดยเปิดที่โหนด ChatOpenAI

chatflow

support-chat.json ที่เขียนสำหรับบทแนะนำทีละขั้นตอนนี้ในรูปแบบที่ตัวแก้ไขของ Flowise ส่งออก chatflow มีโหนดสามโหนดและเส้นเชื่อมสองเส้นระหว่างโหนดเหล่านั้น ได้แก่โหนด ChatOpenAI ที่เลือก gpt-4o-mini โหนด Buffer Memory และโหนด Conversation Chain ที่รับทั้งสองโหนดและตอบด้วยข้อความระบบสั้นๆ โหนด ChatOpenAI ไม่เลือกข้อมูลรับรองที่จัดเก็บไว้ และปล่อย Base Path ว่าง ไคลเอนต์ OpenAI ที่ Flowise ใช้รันโหนดนั้นจึงอ่านที่อยู่และคีย์จากสภาพแวดล้อมของ Flowise

ข้างไฟล์ chatflow มี .aggrega-config.yaml ที่ทำให้โฟลเดอร์เป็นพื้นที่ทำงาน:

# The workspace key marks this directory as the workspace root, so an import run
# here writes its drafts beside support-chat.json.
workspace: {}
# The registry the importer is fetched from the first time an import needs it.
default_registry: hub.aggrega.ai

และ import-answers.yaml เก็บคำตอบของสิ่งที่ chatflow ใดก็เก็บไม่ได้ Flowise ไม่โหลด chatflow จากไฟล์ตอนเริ่ม บิลด์จึงเริ่มต้น chatflow ผ่าน API ของ Flowise เองภายใต้บัญชีเจ้าของ และไม่มีไฟล์ส่งออกใดระบุบัญชีนั้น อีเมลของบัญชีคือคำตอบเดียวที่การนำเข้าสำหรับ Docker Compose ต้องใช้ การนำเข้าสำหรับ Kubernetes ต้องใช้ชื่อของ Kubernetes Secret ที่เก็บข้อมูลลับแต่ละรายการด้วย — รหัสผ่านของเจ้าของและคีย์ OpenAI — ไฟล์จึงระบุชื่อ Secrets ทั้งสองนี้ด้วย (ดู บน Kubernetes):

# Values the import could not draft from the source, keyed by the drafted file and the key path inside
# it. Write each one beside its key; an import of the same source, and a sync, read them from here and
# ask nothing. A secret is never written here: its key asks where the secret comes from — a variable
# name, ${NAME}, or the name of a Kubernetes Secret.
release.yaml:
# Email address of the platform's owner account, read only when values.flow_definition is set. The
# step that seeds the chatflow registers this account when the instance has no owner yet, which makes
# it the owner, and signs in as it; on an instance that already has one, it names an account allowed
# to import chatflows, and the password attached to the owner_password slot is that account's.
# Required when values.flow_definition is set: the build halts when it is empty. It has no default.
spec.components.flowise.infra.owner_email: "owner@example.com"
# The origin of the secret value, written by the operator in the Release. Read exactly as
# values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes
# from, never the value.
spec.components.flowise.features.owner_password.infra.origin: "flowise-owner"
# The origin of the secret value, written by the operator in the Release. Read exactly as
# values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes
# from, never the value.
spec.components.flowise.uses.model.chatopenai-0.features.credential.infra.origin: "openai-api-key"

owner@example.com แทนอีเมลของคุณเอง หากไม่มีไฟล์ การนำเข้าบนเทอร์มินัลจะถามทุกค่าทีละคำถาม โดยเรียบเรียงจากคำอธิบายเหนือคีย์ของค่านั้น และเขียนคำตอบของคุณลงในไฟล์คำตอบใหม่ เมื่อไม่มีทางถามได้ การนำเข้าจะเขียนไฟล์นั้นโดยมีคีย์และคำตอบว่าง แสดงรายการคีย์เหล่านั้น และออกด้วยสถานะ 1 ไฟล์คำตอบของการนำเข้า อธิบายไฟล์นี้อย่างครบถ้วน

การนำเข้าเทียบโหนดแต่ละโหนดกับ Components ของแค็ตตาล็อกของพื้นที่ทำงาน และ --target ร่าง Manifest จาก Recipes ของแค็ตตาล็อกนั้น พื้นที่ทำงานไม่ระบุโฟลเดอร์แค็ตตาล็อกใดเลย การนำเข้าจึงอ่านแค็ตตาล็อกของไลบรารีมาตรฐานจากรีจิสทรีที่ใช้ดึงตัวนำเข้า คือสแนปช็อตที่ลงนามของแค็ตตาล็อกที่เผยแพร่ ซึ่งการนำเข้าครั้งแรกดึงมา ตรวจสอบ และเก็บไว้ในแคชเนื้อหาของพื้นที่ทำงาน และระบุด้วยไดเจสต์ในบันทึกที่การนำเข้าเขียนไว้ข้างฉบับร่าง พื้นที่ทำงานที่ระบุโฟลเดอร์แค็ตตาล็อกของตนเอง — ใน AGGREGA_CATALOG_DIRS หรือใต้ workspace.catalog_dirs — จะนำเข้าเทียบกับโฟลเดอร์เหล่านั้นแทน เปลี่ยนไดเรกทอรีไปที่ source:

Terminal window
cd source

รันการนำเข้า

Terminal window
aggrega import support-chat.json --target compose

ที่เอาต์พุตมาตรฐาน การนำเข้าแสดงสิ่งที่เขียน:

wrote aggregate.yaml
wrote release.yaml
wrote manifest.yaml
wrote .aggrega-import.json

ที่ข้อผิดพลาดมาตรฐาน โดยที่ <workspace> แทนโฟลเดอร์ที่คุณรัน:

[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]
read as the flowise format, with drafted paths relative to <workspace>
warn: node chatOpenAI_0 reaches chatopenai-0 through the model connection chatopenai-0 of core/ai-agent/flowise: its Base Path is empty, so the OpenAI client Flowise runs it on reads the address the platform delivers for this connection, OPENAI_BASE_URL, and, since it selects no credential, the key delivered as OPENAI_API_KEY
info: the answers file <workspace>/import-answers.yaml also answers spec.components.flowise.features.owner_password.infra.origin in release.yaml, spec.components.flowise.uses.model.chatopenai-0.features.credential.infra.origin in release.yaml, which these drafts do not leave empty; those answers are kept there and not applied
mapped chatOpenAI_0 (chatOpenAI) to core/ai-model/openai as a reference, HIGH at 0.9
made no choice for bufferMemory_0 (bufferMemory)
made no choice for conversationChain_0 (conversationChain)
warning: node "flowise" (provider "compose"): artifact "flowise-flow/flowise-flow.yaml": skipped provenance label injection — the fragment declares no compose service. Compose carries build provenance as service labels, so a fragment contributing only top-level networks, volumes or configs carries none; the services this component emits elsewhere carry the full set.
Pull complete: <workspace>/release.lock (entities=8, source_artifacts=0, external_inputs=0)

การนำเข้าที่รันจากตัวแก้ไข: Aggregate, Release และ Manifest ที่ร่างไว้ปรากฏข้างไฟล์ส่งออก chatflow เอาต์พุต Aggrega แสดงวิธีแมปของแต่ละโหนดและไฟล์ที่เขียน และการแจ้งเตือนระบุว่าการนำเข้าร่างไฟล์ 3 ไฟล์ จำแนกได้ว่าเป็น flowise

  • บรรทัด mapped บอกว่าโหนด ChatOpenAI กลายเป็นโมเดล OpenAI ของไลบรารีมาตรฐาน คือ core/ai-model/openai ซึ่งอ้างอิงแทนการร่าง เพราะตรงกันในระดับสูงที่ 0.9 โดยเป็นส่วนประกอบของตนเอง เชื่อมโยงกับซ็อกเก็ต model ของแพลตฟอร์ม
  • บรรทัด warn บอกว่า chatflow เข้าถึงโมเดลนั้นอย่างไร โหนดอ่านที่อยู่และคีย์ที่แพลตฟอร์มส่งมอบสำหรับการเชื่อมต่อของโมเดล คีย์ที่ Release แนบกับการเชื่อมต่อจึงเป็นคีย์ที่ chatflow ใช้
  • บรรทัด info เกี่ยวกับไฟล์คำตอบ ไฟล์คำตอบตอบอีเมลของเจ้าของที่ฉบับร่างปล่อยว่างไว้ ส่วนชื่อ Secret สองชื่อตอบสิ่งที่มีเพียงการนำเข้าสำหรับ Kubernetes ที่ปล่อยว่าง จึงยังอยู่ในไฟล์โดยไม่ได้ใช้ที่นี่
  • บรรทัด made no choice บอกว่าหน่วยความจำและ chain ยังอยู่ภายใน chatflow ไม่มีซ็อกเก็ตของแพลตฟอร์มใดรับสิ่งเหล่านั้น
  • สองบรรทัดสุดท้าย คือขั้นตอน pull เมื่อทุกค่าได้คำตอบ การนำเข้า pull การพึ่งพาของ Release ที่ร่างไว้ เหมือนที่ aggrega pull ทำ และเขียน release.lock บิลด์ด้านล่างไม่ต้องใช้สิ่งใดเพิ่ม บรรทัด warning เป็นบรรทัดที่บิลด์พิมพ์ด้วยเช่นกัน และ ตรวจสอบความถูกต้องและบิลด์ อธิบายบรรทัดนั้น

สิ่งที่การนำเข้าเขียน

Aggregate, Release และ Manifest ตั้งชื่อเป็น imported/support-chat ตามชื่อไฟล์ คือ support-chat.json เพราะไฟล์ส่งออกของ Flowise ไม่มีชื่อของตนเอง ภายใต้เนมสเปซที่การตั้งค่า target_namespace ของตัวนำเข้ากำหนด คือ imported เว้นแต่คุณตั้งเนมสเปซอื่น (การตั้งค่า)

aggregate.yaml — อินสแตนซ์หนึ่งของแพลตฟอร์ม Flowise ของไลบรารีมาตรฐาน คือ core/ai-agent/flowise ที่ถือ chatflow ตามที่ส่งออก ซึ่งที่นี่ตัดส่วนใหญ่ออก และโมเดลที่เชื่อมโยงกับซ็อกเก็ต model ของแพลตฟอร์มนั้น:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: imported/support-chat
version: 0.1.0
description: Draft Aggregate imported from a source in the flowise format.
spec:
components:
flowise:
type: core/ai-agent/flowise
features:
# For the compose target, the lines below declare owner_password on flowise: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none.
owner_password:
type: core/secret-value
values:
key: OWNER_PASSWORD
values:
# chatflow_id is derived from the exported flow, which gives no identifier of its own.
chatflow_id: '40d9f5c5-5187-54c1-a9f5-a8dac92f88bb'
flow_definition: |
{
"nodes": [
[… omitted: the chatflow's nodes, as exported, up to the Conversation Chain's inputs]
"inputs": {
"model": "{{"{{"}}chatOpenAI_0.data.instance}}",
"memory": "{{"{{"}}bufferMemory_0.data.instance}}",
[… omitted: the rest of the chatflow, as exported]
}
uses:
model:
chatopenai-0:
target: chatopenai-0
# For the compose target, the lines below declare credential on chatopenai-0: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none.
features:
credential:
type: core/secret-value
values:
key: OPENAI_API_KEY
# swap to core/ai-model/azure-openai (score 0.4000) by setting type: core/ai-model/azure-openai
chatopenai-0:
type: core/ai-model/openai
values:
model: |-
gpt-4o-mini
  • โมเดล คือ core/ai-model/openai พร้อมโมเดลที่โหนดเลือก คือ gpt-4o-mini ความคิดเห็นด้านบนระบุ Component อีกรายการของแค็ตตาล็อกที่โหนดคล้าย พร้อมคะแนน
  • ข้อมูลลับสองรายการ — รหัสผ่านของบัญชีเจ้าของที่ใช้เริ่มต้น chatflow และคีย์ OpenAI ที่แพลตฟอร์มแสดงต่อโมเดล — ประกาศไว้ที่นี่พร้อมตัวแปรที่แต่ละรายการมาถึงภายใต้สภาพแวดล้อมของ Flowise คือ OWNER_PASSWORD และ OPENAI_API_KEY บน Docker Compose ข้อมูลลับที่มีเพียง Release แนบจะมาถึงภายใต้คีย์ value และทั้งสองจะชนกัน เมื่อประกาศไว้ที่นี่ แต่ละรายการจึงมีคีย์ของตนเอง Release บอกว่าแต่ละรายการมาจากที่ใด
  • chatflow_id สร้างจาก chatflow เพราะไฟล์ส่งออกจากตัวแก้ไขของ Flowise ไม่มีตัวระบุของตนเอง chatflow หนึ่งจึงให้ตัวระบุเดียวเสมอ chatflow ของ Flowise เขียน {{<node id>.data.instance}} สำหรับทุกการเชื่อมต่อระหว่างสองโหนด และข้อความของ Aggregate ถูกอ่านเป็นเทมเพลต ฉบับร่างจึงเขียน {{ แต่ละตัวเป็น {{"{{"}} ซึ่งบิลด์เปลี่ยนกลับเป็นปีกกาสองตัว

release.yaml — Release ซึ่งปรับใช้ Aggregate ด้วย Manifest:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: imported/support-chat
# environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to.
environment: development
version: 0.1.0
description: Draft Release imported from a source in the flowise format.
spec:
aggregate: imported/support-chat
manifest: imported/support-chat
components:
flowise:
infra:
# The image running core/ai-agent/flowise, at the version this importer drafts, which the catalog's Recipes for it are known to run; the import does not raise or lower it to follow the source.
image: "flowiseai/flowise:3.1.3"
# Left for the Release, since the source cannot supply it: infra.owner_email, the email address of the platform's owner account, required while values.flow_definition is set
owner_email: "owner@example.com"
# Published on this machine's loopback address, 127.0.0.1: reachable from this machine only, by any process running on it. Delete this line to keep the service internal.
published_port: 3000
features:
owner_password:
type: core/secret-value
infra:
# Attached by reference, never as a value: the owner account's password, required while values.flow_definition is set, read from the variable FLOWISE_OWNER_PASSWORD, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value.
origin: "${FLOWISE_OWNER_PASSWORD}"
uses:
model:
chatopenai-0:
features:
credential:
type: core/secret-value
infra:
# Attached by reference, never as a value: the credential flowise presents to chatopenai-0 on its model connection, read from the variable OPENAI_API_KEY, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value.
origin: "${OPENAI_API_KEY}"
chatopenai-0: {}
  • environment คือ development ซึ่งเป็นค่าเริ่มต้นที่ความคิดเห็นด้านบนบอกให้เปลี่ยนเป็นสภาพแวดล้อมที่ Release ปรับใช้
  • อิมเมจ คือ Flowise 3.1.3 ซึ่งเป็นเวอร์ชันที่ Recipes ของแค็ตตาล็อกสำหรับ Flowise รัน
  • published_port คือ 3000 ซึ่งเป็นพอร์ตที่ Flowise ให้บริการ จึงตอบที่ http://127.0.0.1:3000 บนเครื่องของคุณ ตามที่ความคิดเห็นของบรรทัดนั้นบอก กระบวนการใดก็ตามบนเครื่องนี้เข้าถึงได้ที่นั่น และไม่มีสิ่งอื่นเข้าถึงได้ ลบบรรทัดนั้นเพื่อให้ Flowise อยู่บนเครือข่ายของสแตกเท่านั้น
  • owner_email คือคำตอบจากไฟล์คำตอบ ความคิดเห็นด้านบนบอกว่าเหตุใดการนำเข้าจึงร่างค่านี้ไม่ได้
  • ข้อมูลลับสองรายการ เป็นการอ้างอิงตัวแปร คือ ${FLOWISE_OWNER_PASSWORD} และ ${OPENAI_API_KEY} ซึ่ง Docker Compose เติมจาก shell ของคุณเมื่อสแตกเริ่มทำงาน จึงไม่มีไฟล์ใดเก็บค่าทั้งสองไว้

manifest.yaml — Recipes ของ Compose สำหรับแพลตฟอร์มและโมเดล และการทำให้เป็นรูปธรรมที่เขียนการอ้างอิงตัวแปรของข้อมูลลับลงในไฟล์ Compose ตามที่เขียนไว้:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/support-chat
version: 0.1.0
spec:
mappings:
components:
type:
core/ai-agent/flowise: compose/flowise
core/ai-model/openai: compose/openai
features:
type:
core/secret-value: compose/dotenv-secret

.aggrega-import.json คือบันทึกของสิ่งที่การนำเข้าเขียน ซึ่ง aggrega import --sync ครั้งต่อมาอ่าน และ release.lock ปักหมุดเอนทิตีแค็ตตาล็อกทุกรายการที่ Release หาค่าไปถึง ด้วยเวอร์ชันและไดเจสต์

ตรวจสอบความถูกต้องและบิลด์

Terminal window
aggrega validate --release release.yaml
aggrega build --release release.yaml

Release ที่ร่างไว้เปิดอยู่ในตัวแก้ไขหลังตรวจสอบความถูกต้อง โดยเอาต์พุต Aggrega และการแจ้งเตือนต่างรายงานว่าไม่พบปัญหา

การบิลด์ Release ที่ร่างไว้: โฟลเดอร์ dist ปรากฏใน Explorer เอาต์พุต Aggrega แสดงไฟล์ Docker Compose ที่เขียน และการแจ้งเตือนระบุว่าเขียนไฟล์แล้ว

การตรวจสอบความถูกต้องพิมพ์:

notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)

และบิลด์ โดย <workspace> แทนโฟลเดอร์ที่เก็บฉบับร่าง:

warning: node "flowise" (provider "compose"): artifact "flowise-flow/flowise-flow.yaml": skipped provenance label injection — the fragment declares no compose service. Compose carries build provenance as service labels, so a fragment contributing only top-level networks, volumes or configs carries none; the services this component emits elsewhere carry the full set.
notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
[… omitted: a total build time, which differs per run]
Build completed: 1 file written to <workspace>/dist

บรรทัด warning เกี่ยวกับส่วนของไฟล์ Compose ที่ถือ chatflow คือรายการ configs ระดับบนสุด ซึ่งไม่มีบริการให้ใส่ป้ายกำกับของบิลด์ บรรทัด notice เป็นข้อมูลเชิงแนะนำ Feature ข้อมูลลับรับ origin จาก values ของ Aggregate หรือ infra ของ Release และข้อแนะนำนั้นรายงานว่ามีค่าปลายทางหนึ่งค่าประกาศในทั้งสองที่ ทั้งสองบรรทัดไม่เปลี่ยนคำตัดสิน

dist/compose/docker-compose.yaml มีสองบริการ คือ Flowise เอง:

flowise:
image: flowiseai/flowise:3.1.3
environment:
DATABASE_PATH: /home/node/.flowise
SECRETKEY_PATH: /home/node/.flowise
OPENAI_BASE_URL: https://api.openai.com/v1
OPENAI_API_KEY: ${OPENAI_API_KEY}
ports:
- 127.0.0.1:3000:3000
[… omitted: the labels the build writes on every service, naming the Aggregate, the component, the environment and the compiler's version]
volumes:
- type: volume
source: flowise--data
target: /home/node
networks:
- compose
[… omitted: the service's health check]

และบริการที่เริ่มต้น chatflow เมื่อ Flowise รายงานว่าทำงานปกติ แล้วออก:

flowise-flow-seed:
image: flowiseai/flowise:3.1.3
entrypoint:
- node
- /seed/seed.js
environment:
FLOWISE_URL: http://127.0.0.1:3000
OWNER_EMAIL: owner@example.com
OWNER_PASSWORD: ${FLOWISE_OWNER_PASSWORD}
CHATFLOW_ID: 40d9f5c5-5187-54c1-a9f5-a8dac92f88bb
CHATFLOW_NAME: 40d9f5c5-5187-54c1-a9f5-a8dac92f88bb
[… omitted: the labels the build writes on every service]
network_mode: service:flowise
depends_on:
flowise:
condition: service_healthy
restart: "no"
configs:
- source: flowise-flow
target: /seed/flow.json
- source: flowise-flow-seed
target: /seed/seed.js

บริการนี้ลงทะเบียนบัญชีเจ้าของบน Flowise ใหม่ หรือลงชื่อเข้าใช้ด้วยบัญชีนั้น และเขียน chatflow ที่ chatflow_id คีย์และรหัสผ่านเป็นการอ้างอิงตัวแปร ซึ่งเติมจาก shell ของคุณเมื่อสแตกเริ่มทำงาน Recipe ของ Compose สำหรับ Flowise เผยแพร่พอร์ตบนเครื่องของคุณเฉพาะเมื่อ Release ตั้ง published_port ไว้ใน infra ของ Flowise และเผยแพร่บนที่อยู่ loopback 127.0.0.1 เท่านั้น หากไม่มี บริการจะเข้าถึงได้บนเครือข่ายของสแตกเท่านั้น

กับผู้ช่วย AI

ผู้ช่วย AI ที่ ตั้งค่าด้วยเครื่องมือของ Aggrega ทำสิ่งเดียวกันได้: วางพรอมต์นี้ลงไป

ใช้เฉพาะเครื่องมือของ Aggrega และอย่าสร้างโฟลเดอร์เอง ถ้าโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `import-flowise` เรียกเครื่องมือ `draft` หนึ่งครั้ง โดยตั้ง `example` เป็น `import-flowise` และไม่ระบุ `dir`: เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `import-flowise` ใหม่ ซึ่งโฟลเดอร์ `source` ของโฟลเดอร์นั้นเก็บสิ่งที่หน้านี้นำเข้า จากนั้นเรียกเครื่องมือ `import` โดยตั้ง `workspace_root` เป็น `import-flowise/source` ตั้ง `source` เป็น `support-chat.json` และตั้ง `target` เป็น `compose`: เครื่องมืออ่านคำตอบที่ต้องใช้จาก `import-answers.yaml` ข้าง `support-chat.json` เขียนร่างลงใน `import-flowise/source` และ pull สิ่งที่ร่างเหล่านั้นต้องใช้ จากนั้นเรียกเครื่องมือ `validate` โดยตั้ง `workspace_root` เป็น `import-flowise/source` และตั้ง `release` เป็น `release.yaml` และเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `import-flowise/source` ตั้ง `release` เป็น `release.yaml` และตั้ง `write` เป็น true บอกฉันว่าบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `import-flowise/source/dist/`

เปิดใน VS Code

เมื่อติดตั้ง ส่วนขยาย Aggrega สำหรับ Visual Studio Code แล้ว เปิดโฟลเดอร์ import-flowise/source ใน VS Code ซึ่งเป็นที่ที่การนำเข้าเขียนร่างไว้ โฟลเดอร์มี Release หนึ่งรายการคือ release.yaml ที่ร่างไว้ ตัวแก้ไขจึงเลือก Release นั้นให้คุณ และตรวจสอบร่างเทียบกับ Release นั้นขณะที่คุณแก้ไข โดยทำเครื่องหมายสิ่งที่พบในไฟล์และในแผง Problems Aggrega: Show topology graph ใน Command Palette วาดส่วนประกอบของ Release และการเชื่อมต่อระหว่างส่วนประกอบเหล่านั้น Aggrega: Build, Aggrega: Preview build และ Aggrega: Pull ทำงานกับ Release เดียวกัน และแต่ละคำสั่งยังเป็นปุ่มบนแผง Commands ของมุมมอง Aggrega ในแถบกิจกรรม Build เขียนไฟล์ลงใน dist/ ของโฟลเดอร์ ใช้ Aggrega ใน Visual Studio Code ครอบคลุมส่วนที่เหลือ

วิธีรัน

ตั้งค่าคีย์และรหัสผ่านของเจ้าของใน shell ของคุณ เริ่ม Flowise แล้วรัน seed:

Terminal window
export OPENAI_API_KEY='your OpenAI key'
export FLOWISE_OWNER_PASSWORD='a password of your own'
docker compose -p support-chat -f dist/compose/docker-compose.yaml up -d --wait flowise
docker compose -p support-chat -f dist/compose/docker-compose.yaml up flowise-flow-seed

-p ระบุชื่อโปรเจกต์ ตามที่ขั้นตอนรันใน วิธีที่การนำเข้าทำงาน อธิบายไว้ --wait คืนการทำงานเมื่อ Flowise รายงานว่าทำงานปกติ โดยระบุ flowise เพียงตัวเดียว เพราะนับคอนเทนเนอร์ที่ออกจากการทำงานแล้วว่าเป็นความล้มเหลว ส่วน seed ออกจากการทำงานตามที่ออกแบบไว้ คำสั่งที่สองรัน seed พิมพ์บันทึกของ seed และคืนการทำงานเมื่อ seed ออก:

flowise-flow-seed-1 | registered the owner account owner@example.com
flowise-flow-seed-1 | imported chatflow 40d9f5c5-5187-54c1-a9f5-a8dac92f88bb as "40d9f5c5-5187-54c1-a9f5-a8dac92f88bb"
flowise-flow-seed-1 exited with code 0

ถ้าโปรแกรมอื่นบนเครื่องของคุณรับฟังที่ 127.0.0.1:3000 อยู่แล้ว คำสั่งแรกจะหยุดพร้อมข้อความ failed to bind host port 127.0.0.1:3000/tcp: address already in use ตั้ง published_port เป็นพอร์ตที่ว่าง แล้วบิลด์อีกครั้ง การรันด้านล่างก็ทำเช่นนั้น โดยใช้ 3002 และใช้พอร์ตนั้นแทน 3000

ทดสอบ

เปิด http://127.0.0.1:3000 ซึ่งเป็นที่อยู่ที่ published_port เผยแพร่ แล้วลงชื่อเข้าใช้ด้วยอีเมลและรหัสผ่านของเจ้าของ: chatflow ของ seed อยู่ใน Flowise

chatflow ที่ไม่ตั้งคีย์ API ของตัวเองจะตอบที่เอนด์พอยต์การทำนายโดยไม่ต้องใช้คีย์ ลองถามคำถามกับ chatflow:

Terminal window
curl -sS -X POST http://127.0.0.1:3000/api/v1/prediction/40d9f5c5-5187-54c1-a9f5-a8dac92f88bb \
-H 'Content-Type: application/json' -d '{"question": "In one short sentence: what is Docker Compose?"}'

การรันใช้ค่าตัวแทนแทนคีย์ OpenAI คำตอบจึงเป็นการที่ OpenAI ปฏิเสธคีย์นั้น ซึ่งแสดงว่า chatflow รันไปได้ถึงการเรียกโมเดล:

{"statusCode":500,"success":false,"message":"401 Unauthorized – check your API key and ensure it has access to the requested model.","stack":{}}

เมื่อใช้คีย์ของคุณ การตอบกลับจะมีคำตอบอยู่ที่ text

บน Kubernetes เมื่อนำบิลด์ที่ บน Kubernetes อธิบายไปใช้แล้วและ seed Job ของบิลด์เสร็จสมบูรณ์ ส่งต่อพอร์ตภายในเครื่องไปยัง Service ของ Flowise คือ flowise-default ในเนมสเปซที่คุณนำไปใช้ และปล่อยให้คำสั่งรันต่อไป:

Terminal window
kubectl port-forward -n <namespace> svc/flowise-default 3000:3000

จากเทอร์มินัลอื่น คำถามข้างต้นไปถึง chatflow ที่ที่อยู่เดิมโดยไม่ต้องแก้ไข การรันได้รับการปฏิเสธคีย์ตัวแทนเช่นเดียวกัน

หยุดสแตกด้วยคำสั่งด้านล่าง -v ยังลบวอลุ่มข้อมูลของ Flowise ไปด้วย รวมถึงบัญชีเจ้าของและ chatflow ที่ seed เขียนไว้:

Terminal window
docker compose -p support-chat -f dist/compose/docker-compose.yaml down -v

บน Kubernetes

chatflow เดียวกันนำเข้าสำหรับ Kubernetes ได้ด้วยเป้าหมาย helm ร่างสำหรับ Docker Compose อยู่ใน source แล้ว และการนำเข้าไม่เขียนทับ Aggregate ที่นั่นเลย จึงร่างชุดนี้ลงในโฟลเดอร์ของตัวเองด้วย --output-dir แล้วตรวจสอบความถูกต้องและบิลด์จากโฟลเดอร์นั้น:

Terminal window
aggrega import support-chat.json --target helm --output-dir helm
cd helm
aggrega validate --release release.yaml
aggrega build --release release.yaml

ร่างต่างกันตรงที่เป้าหมายต่างกัน Manifest แมปแพลตฟอร์มไปยัง helm/flowise แมปโมเดลไปยัง helm/openai และแมปข้อมูลลับแต่ละรายการไปยัง helm/k8s-existing-secret ซึ่งอ่านข้อมูลลับนั้นจาก Secret ที่มีอยู่แล้วในเนมสเปซ Release แนบรหัสผ่านของเจ้าของและคีย์ OpenAI เป็น core/referenced-secret โดยแต่ละรายการระบุชื่อ Secret ของตน และนำคำตอบทั้งสามมาจากไฟล์คำตอบ ได้แก่ อีเมลของเจ้าของ flowise-owner และ openai-api-key

บิลด์เขียนแมนิเฟสต์ Kubernetes แบบธรรมดาไว้ใต้ dist/helm/ ที่รูทของพื้นที่ทำงาน คือ source ซึ่งจาก helm คือ ../dist/helm/ สร้าง Secrets สองรายการในเนมสเปซที่คุณนำไปใช้ โดยแต่ละรายการเก็บค่าไว้ใต้คีย์ข้อมูล value แล้วนำโฟลเดอร์ไปใช้ตามที่ขั้นตอนรันใน วิธีที่การนำเข้าทำงาน อธิบายไว้