นำเข้า flow ของ Langflow
บท
ร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example import-langflowจากsource ของbasic-prompting.json ซึ่ง
cd import-langflow
flow
Basic Prompting เชื่อมgpt-4.1 ของ OpenAI และ Chat Output ตามbasic-prompting.json ขนาดOPENAI_API_KEY ซึ่ง Langflow อ่าน
ข้าง flow .aggrega-config.yaml ทำให้
# The workspace key marks this directory as the workspace root, so an import run# here writes its drafts beside basic-prompting.json.workspace: {}# The registry the importer is fetched from the first time an import needs it.default_registry: hub.aggrega.aiและ import-answers.yaml เก็บ
# 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: # 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.langflow.features.admin_password.infra.origin: "langflow-admin" # 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.langflow.uses.model.languagemodelcomponent-kboja.features.credential.infra.origin: "openai-api-key"คำ
การนำ--target ร่าง Manifest จาก Recipes ของAGGREGA_CATALOG_DIRS หรือworkspace.catalog_dirs — จะsource:
cd sourceรันการนำเข้า
aggrega import basic-prompting.json --target composeที่
wrote aggregate.yamlwrote release.yamlwrote manifest.yamlwrote .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 langflow format, with drafted paths relative to <workspace>warn: the flow is carried in values.flow_definition with the handles of all 3 of its edges written as Langflow's editor writes them — the same handles, their keys in order with no space between them — since the editor compares an edge's handles with the ones it writes for the nodes the edge joins, character for character, when it opens the flow, and drops every edge whose handles differwarn: node LanguageModelComponent-kBOja reaches languagemodelcomponent-kboja through the model connection languagemodelcomponent-kboja of core/ai-agent/langflow: its field api_key names the variable OPENAI_API_KEY, which the platform delivers for this connection and Langflow reads as a global variable; no field of it gives its API's address, so the OpenAI client it runs takes OPENAI_BASE_URL, the address the platform delivers for this connection, from the environmentmade no choice for ChatInput-SzjnT (ChatInput)made no choice for Prompt-tOH5D (Prompt)made no choice for ChatOutput-8ZWWB (ChatOutput)mapped LanguageModelComponent-kBOja (LanguageModelComponent) to core/ai-model/openai as a reference, HIGH at 0.9 warning: node "langflow" (provider "compose"): artifact "langflow-flow/langflow-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)
- บรรทัด
mappedระบุว่า โหนด Language Model กลาย เป็น อะไร คือ โมเดล OpenAI ใน ไลบรารี มาตรฐาน core/ai-model/openaiซึ่งอ้างอิง แทนที่ จะ ร่าง ขึ้น ใหม่ เพราะ จับ คู่ ได้ ใน ระดับ สูง ที่ 0.9 เป็น ส่วน ประกอบ เดี่ยว ของ ตัว เอง ที่ เชื่อม โยง กับ ซ็อกเก็ต modelของแพลตฟอร์ม โดย ค่า เริ่ม ต้น ร่าง รัน flow ทั้งหมด บน แพลตฟอร์ม ที่ รัน Langflow และ ให้ ส่วน ประกอบ ของ ตัว เอง เฉพาะ โหนด ที่ ซ็อกเก็ต ของ แพลตฟอร์ม นั้น รับ ได้แก่ โมเดล เครื่อง มือ หรือ ที่ จัด เก็บ เวกเตอร์ เมื่อ รู้จัก โหนด นั้น ว่า เป็น อย่าง ใด อย่าง หนึ่ง เหล่า นี้ - บรรทัด
warnแรก ระบุว่า flow มา พร้อม แฮนเดิล ของ เส้น เชื่อม แต่ละ เส้น ที่ เขียน ตาม ที่ ตัว แก้ไข ของ Langflow เขียน Langflow เก็บ โปรเจกต์ เริ่ม ต้น ไว้ โดย มี ช่อง ว่าง หลัง ทุก เครื่องหมาย ทวิภาค และ จุลภาค ใน แฮนเดิล ของ เส้น เชื่อม ตัว แก้ไข ของ Langflow เมื่อ เปิด flow จะ ทิ้ง เส้น เชื่อม ทุก เส้น ที่ แฮนเดิล ไม่ ตรง กับ ที่ ตัว แก้ไข เขียน แล้ว บันทึก flow โดย ไม่มี เส้น เชื่อม นั้น เมื่อ เขียน เช่น นี้ flow จะ เปิด พร้อม การ เชื่อม ต่อ สาม รายการ และ รัน พร้อม การ เชื่อม ต่อ เหล่า นั้น - บรรทัด
warnที่ระบุ บอกโหนด ว่า flow เข้า ถึง โมเดล นั้น อย่างไร โหนด อ่าน คีย์ จาก ตัวแปร OPENAI_API_KEYและอ่าน ที่ อยู่ จาก OPENAI_BASE_URLและแพลตฟอร์ม ส่ง มอบ ทั้ง สอง ค่า สำหรับ การ เชื่อม ต่อ ของ โมเดล flow จึง ไม่ ต้อง แก้ไข - บรรทัด
made no choiceระบุโหนด ที่ ไม่มี ซ็อกเก็ต ใด ของ แพลตฟอร์ม รับ: โหนด เหล่า นั้น อยู่ ภายใน flow ซึ่ง Langflow รัน ตาม ที่ ส่ง ออก - สอง
บรรทัด คือสุดท้าย ขั้น ตอน pull ไม่มี คำถาม เหลือ ให้ ตอบ การนำ เข้า จึง pull การ พึ่งพา ของ Release ที่ ร่าง ไว้ เหมือน ที่ aggrega pullทำ และเขียน release.lockบิลด์ด้าน ล่าง ไม่ ต้อง ใช้ อะไร เพิ่ม บรรทัด warningเป็นบรรทัด ตรวจที่ บิลด์ พิมพ์ เช่น กัน และ สอบ อธิบายความ ถูก ต้อง และ บิลด์ บรรทัด นั้น
ไฟล์
สิ่งที่การนำเข้าเขียน
Aggregate, Release และ Manifest ตั้งimported/basic-prompting ตามBasic Prompting ที่basic-prompting (flow ที่target_namespace ของimported เว้น
aggregate.yaml ประกอบcore/ai-agent/langflow ซึ่ง
apiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: imported/basic-prompting version: 0.1.0 description: Draft Aggregate imported from a source in the langflow format.spec: components: langflow: type: core/ai-agent/langflow features: # For the compose target, the lines below declare admin_password on langflow: 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. admin_password: type: core/secret-value values: key: LANGFLOW_SUPERUSER_PASSWORD values: flow_id: '0dbee653-41ae-4e51-af2e-55757fb24be3' flow_definition: |- { "data": { "edges": [ [… omitted: the rest of the flow] } uses: model: languagemodelcomponent-kboja: target: languagemodelcomponent-kboja # For the compose target, the lines below declare credential on languagemodelcomponent-kboja: 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 languagemodelcomponent-kboja: type: core/ai-model/openai values: model: |- gpt-4.1- โมเดล คือ
core/ai-model/openaiโดยใช้ โมเดล ที่ โหนด ของ flow เลือก คือ gpt-4.1ความคิด เห็น เหนือ โมเดล ระบุ Component อีก รายการ ของ แค็ตตาล็อก ที่ โหนด คล้าย พร้อม คะแนน สำหรับ ผู้ อ่าน ที่ ต้องการ รายการ นั้น - ข้อมูล
ลับ คือสอง รายการ รหัส ผ่าน ของ ผู้ ดูแล ระบบ ที่ ตัว แก้ไข ของ Langflow ถาม หา และ คีย์ OpenAI ที่ แพลตฟอร์ม ยื่น ให้ โมเดล ประกาศ ไว้ ที่ นี่ พร้อม ตัวแปร ที่ แต่ละ รายการ มา ถึง ใน สภาพ แวดล้อม ของ Langflow คือ LANGFLOW_SUPERUSER_PASSWORDและOPENAI_API_KEYบน Docker Compose ข้อมูลลับ ที่ มี เพียง Release แนบ ไว้ จะ มา ถึง ใต้ คีย์ valueและทั้ง สอง รายการ จะ ชน กัน เมื่อ ประกาศ ที่ นี่ แต่ละ รายการ มี คีย์ ของ ตนเอง Release ระบุ ว่า แต่ละ รายการ มา จาก ที่ ใด flow_idคือตัว ระบุ ที่ การ ส่ง ออก กำหนด ให้ flow
release.yaml — Release ซึ่ง
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: imported/basic-prompting # 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 langflow format.spec: aggregate: imported/basic-prompting manifest: imported/basic-prompting components: langflow: infra: # The image running core/ai-agent/langflow, 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. The source states version "1.5.0" of the platform. image: "langflowai/langflow:1.6.0" # 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: 7860 features: admin_password: type: core/secret-value infra: # Attached by reference, never as a value: the administrator's password, read while values.require_authentication stays true, read from the variable LANGFLOW_ADMIN_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: "${LANGFLOW_ADMIN_PASSWORD}" uses: model: languagemodelcomponent-kboja: features: credential: type: core/secret-value infra: # Attached by reference, never as a value: the credential langflow presents to languagemodelcomponent-kboja 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}" languagemodelcomponent-kboja: {}environmentคือdevelopmentซึ่งเป็น ค่า เริ่ม ต้น ที่ ความ คิด เห็น ด้าน บน บอก ให้ เปลี่ยน เป็น สภาพ แวดล้อม ที่ Release ปรับ ใช้ - อิมเมจ คือ Langflow 1.6.0 ซึ่ง
เป็น เวอร์ชัน ที่ Recipes ของ แค็ตตาล็อก สำหรับ Langflow รัน flow ทดสอบ ครั้ง ล่าสุด บน Langflow 1.5.0 ตาม ที่ ความ คิด เห็น ระบุ การนำ เข้า คง เวอร์ชัน ที่ Recipes รัน ไว้ แทนที่ จะ ทำ ตาม เวอร์ชัน ของ flow published_portคือ 7860 ซึ่งเป็น พอร์ต ที่ Langflow ให้ บริการ ตัว แก้ไข จึง ตอบ ที่ http://127.0.0.1:7860บนเครื่อง ของ คุณ ตาม ที่ ความ คิด เห็น ของ บรรทัด นั้น ระบุ กระบวนการ ใด ก็ตาม บน เครื่อง นี้ เข้า ถึง ได้ที่ นั่น และ ไม่มี สิ่ง อื่น เข้า ถึง ได้ ลบ บรรทัด นั้น เพื่อ ให้ Langflow อยู่ บน เครือข่าย ของ สแตก เท่านั้น - ข้อมูล
ลับ เป็นการสอง รายการ อ้างอิง ตัวแปร คือ ${LANGFLOW_ADMIN_PASSWORD}และ${OPENAI_API_KEY}ซึ่ง Docker Compose เติมจาก shell ของ คุณ เมื่อ สแตก เริ่ม ทำงาน จึง ไม่มี ไฟล์ ใด มี ค่า ทั้ง สอง นี้
manifest.yaml — Recipes ของ Compose สำหรับ
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: imported/basic-prompting version: 0.1.0spec: mappings: components: type: core/ai-agent/langflow: compose/langflow core/ai-model/openai: compose/openai features: type: core/secret-value: compose/dotenv-secret.aggrega-import.json คือaggrega import --sync ครั้งrelease.lock ปัก
ตรวจสอบความถูกต้องและบิลด์
aggrega validate --release release.yamlaggrega build --release release.yaml

การ
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 "langflow" (provider "compose"): artifact "langflow-flow/langflow-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 เกี่ยวconfigs ระดับnotice เป็นorigin จาก values ของ Aggregate หรือ infra ของ Release และ
dist/compose/docker-compose.yaml มี Langflow และ
services: langflow: image: langflowai/langflow:1.6.0 environment: LANGFLOW_CONFIG_DIR: /app/langflow LANGFLOW_SAVE_DB_IN_CONFIG_DIR: "true" LANGFLOW_AUTO_LOGIN: "false" LANGFLOW_SUPERUSER: admin LANGFLOW_SUPERUSER_PASSWORD: ${LANGFLOW_ADMIN_PASSWORD} OPENAI_BASE_URL: https://api.openai.com/v1 OPENAI_API_KEY: ${OPENAI_API_KEY} LANGFLOW_LOAD_FLOWS_PATH: /app/flows ports: - 127.0.0.1:7860:7860 [… 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: langflow--data target: /app/langflow networks: - compose depends_on: langflow--data-owner: condition: service_completed_successfully [… omitted: the service's health check] configs: - source: langflow-flow target: /app/flows/flow.json langflow--data-owner: image: langflowai/langflow:1.6.0 entrypoint: - chown - "1000:0" - /app/langflow [… omitted: the labels the build writes on every service] volumes: - type: volume source: langflow--data target: /app/langflow networks: - compose restart: "no" user: "0"flow ไป/app/flows/flow.json จากconfigs ที่LANGFLOW_LOAD_FLOWS_PATH ทุกpublished_port ใน infra ของ Langflow และ
langflow--data-owner รัน
กับผู้ช่วย AI
ผู้
ใช้เฉพาะเครื่องมือของ Aggrega และอย่าสร้างโฟลเดอร์เอง ถ้าโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `import-langflow` เรียกเครื่องมือ `draft` หนึ่งครั้ง โดยตั้ง `example` เป็น `import-langflow` และไม่ระบุ `dir`: เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `import-langflow` ใหม่ ซึ่งโฟลเดอร์ `source` ของโฟลเดอร์นั้นเก็บสิ่งที่หน้านี้นำเข้า จากนั้นเรียกเครื่องมือ `import` โดยตั้ง `workspace_root` เป็น `import-langflow/source` ตั้ง `source` เป็น `basic-prompting.json` และตั้ง `target` เป็น `compose`: เครื่องมืออ่านคำตอบที่ต้องใช้จาก `import-answers.yaml` ข้าง `basic-prompting.json` เขียนร่างลงใน `import-langflow/source` และ pull สิ่งที่ร่างเหล่านั้นต้องใช้ จากนั้นเรียกเครื่องมือ `validate` โดยตั้ง `workspace_root` เป็น `import-langflow/source` และตั้ง `release` เป็น `release.yaml` และเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `import-langflow/source` ตั้ง `release` เป็น `release.yaml` และตั้ง `write` เป็น true บอกฉันว่าบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `import-langflow/source/dist/`เปิดใน VS Code
เมื่อimport-langflow/source ใน VS Code ซึ่งrelease.yaml ที่dist/ ของ
วิธีรัน
ตั้ง
export OPENAI_API_KEY='your OpenAI key'export LANGFLOW_ADMIN_PASSWORD='a password of your own'docker compose -p basic-prompting -f dist/compose/docker-compose.yaml up -d --wait-p ระบุ--wait คืนlangflow--data-owner เสร็จ
ทดสอบ
เปิด http://127.0.0.1:7860 ซึ่งpublished_port เผยadmin ด้วย
Langflow รัน flow ผ่าน API ให้
curl -sS -X POST http://127.0.0.1:7860/api/v1/login \ -d username=admin --data-urlencode "password=$LANGFLOW_ADMIN_PASSWORD"{"access_token":"[… omitted: the access token]","refresh_token":"[… omitted: the refresh token]","token_type":"bearer"}สร้าง
curl -sS -X POST http://127.0.0.1:7860/api/v1/api_key/ \ -H 'Authorization: Bearer <access_token>' -H 'Content-Type: application/json' -d '{"name": "test-it"}'{"name":"test-it","last_used_at":null,"total_uses":0,"is_active":true,"id":"[… omitted: the key's identifier]","api_key":"[… omitted: the key]","user_id":"[… omitted: the owner's identifier]"}และ
curl -sS -X POST 'http://127.0.0.1:7860/api/v1/run/0dbee653-41ae-4e51-af2e-55757fb24be3?stream=false' \ -H 'x-api-key: <api_key>' -H 'Content-Type: application/json' \ -d '{"input_value": "In one short sentence: what is Docker Compose?", "input_type": "chat", "output_type": "chat"}'การ
{"detail":"{\"message\":\"Error running graph: Error building Component Language Model: \\n\\nError code: 401 - {'error': {'message': 'Incorrect API key provided: sk-place*****************-key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}\",[… omitted: three empty fields, and a suggestion to update three of the flow's components]}"}เมื่อoutputs[0].outputs[0].results.message.text
บน Kubernetes เมื่อlangflow-default ใน
kubectl port-forward -n <namespace> svc/langflow-default 7860:7860จาก
หยุด-v ยัง
docker compose -p basic-prompting -f dist/compose/docker-compose.yaml down -vบน Kubernetes
flow เดียวกันhelm ร่างsource แล้ว และ--output-dir แล้ว
aggrega import basic-prompting.json --target helm --output-dir helmcd helmaggrega validate --release release.yamlaggrega build --release release.yamlร่างhelm/langflow แมปhelm/openai และhelm/k8s-existing-secret ซึ่งcore/referenced-secret โดย
features: admin_password: type: core/referenced-secret infra: # Left for the Release, since the source cannot supply it: the name of a Kubernetes Secret already in the namespace holding, under the data key value, the administrator's password, read while values.require_authentication stays true. origin: "langflow-admin"หาก<workspace> แทน
2 values the drafts leave empty are still owed, listed in the answers file <workspace>/import-answers.yaml: write each beside its key there, then run the import againบิลด์dist/helm/ ที่source ซึ่งhelm คือ ../dist/helm/ สร้าง Secrets สองvalue แล้ว