Bỏ qua để đến nội dung
AggregaAggrega
Chọn ngôn ngữ: Tiếng Việt
Trang này được dịch bằng máy. Đọc bản gốc tiếng Anh.

Nhập một luồng Langflow

Hướng dẫn từng bước này nhập một luồng được xuất từ Langflow — Basic Prompting, dự án khởi đầu đi kèm Langflow 1.6.0 — thành một Aggregate, một Release và một Manifest mà, đúng như được viết, build Langflow mang theo luồng đó cho Docker Compose, sau đó build chúng và chạy kết quả. Mọi tệp và mọi khối đầu ra bên dưới đều đến từ một lần chạy thật; luồng và từng giai đoạn của hướng dẫn nằm trong ví dụ import-langflow, nơi một script kiểm tra chạy lại quá trình nhập, so sánh những gì nó ghi, những gì nó in ra và các khối mà trang này trích dẫn với các tệp được lưu ở đó, đồng thời xác thực và build những gì quá trình nhập đã ghi.

Tạo ví dụ

Bạn có thể chạy lần nhập này bằng các lệnh trên trang này, hoặc để trợ lý AI của bạn chạy giúp bạn.

Ghi ví dụ vào một thư mục mới đặt theo tên của nó:

Terminal window
aggrega scaffold --example import-langflow

Sau đó nó in ra các lệnh cần chạy tiếp theo. Lệnh đầu tiên chuyển vào thư mục mới; lệnh sau đó, ở bên dưới, chuyển vào thư mục source của thư mục mới, nơi chạy lệnh nhập. Thư mục đó chứa tệp luồng, basic-prompting.json, mà trang này mô tả thay vì trích dẫn:

Terminal window
cd import-langflow

Thư mục source của ví dụ được tạo khung, mở trong Visual Studio Code, hiển thị bản xuất luồng Langflow của một luồng prompting cơ bản.

Luồng

Basic Prompting nối chuỗi bốn nút: một Chat Input, một Prompt, một Language Model gọi gpt-4.1 của OpenAI và một Chat Output. Ở dạng Langflow cung cấp sẵn, nó là một tệp JSON duy nhất, basic-prompting.json, khoảng 54 KB, mang mã nguồn của từng thành phần cùng với luồng. Nút Language Model của nó đọc khóa từ biến toàn cục OPENAI_API_KEY, mà Langflow đọc từ môi trường của mình khi không có biến nào mang tên đó được lưu trữ.

Bên cạnh luồng, một .aggrega-config.yaml biến thư mục thành một không gian làm việc:

# 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

và import-answers.yaml chứa câu trả lời cho những gì không luồng nào có thể chứa. Một lần nhập cho Docker Compose không cần câu trả lời nào trong số đó: nó gắn mỗi bí mật bằng một tham chiếu biến mà Docker Compose điền từ shell của bạn. Một lần nhập cho Kubernetes gắn mỗi bí mật bằng tên của một Secret Kubernetes, tên mà chỉ bạn mới có thể đặt, vì vậy tệp nêu tên hai Secret mà lần nhập đó yêu cầu (xem Trên 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:
# 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"

Mỗi câu trả lời là tên của một Secret, không bao giờ là chính bí mật, vì vậy tệp có thể được giữ cùng với luồng. Tệp câu trả lời nhập mô tả đầy đủ tệp này.

Quá trình nhập đối chiếu từng nút với các Components trong danh mục của không gian làm việc, và --target soạn nháp một Manifest từ các Recipes của danh mục đó. Không gian làm việc không chỉ định thư mục danh mục nào, vì vậy quá trình nhập đọc danh mục thư viện chuẩn từ registry mà từ đó nó tải trình nhập của mình về: một bản chụp nhanh có chữ ký của danh mục đã phát hành, được lần nhập đầu tiên tải về, xác minh và lưu trong bộ nhớ đệm nội dung của không gian làm việc, và được nêu tên theo digest của nó trong bản ghi mà quá trình nhập ghi bên cạnh các bản nháp. Một không gian làm việc chỉ định các thư mục danh mục riêng — trong AGGREGA_CATALOG_DIRS, hoặc dưới workspace.catalog_dirs — thì thay vào đó nhập dựa trên các thư mục đó. Chuyển vào source:

Terminal window
cd source

Chạy lệnh nhập

Terminal window
aggrega import basic-prompting.json --target compose

Trên đầu ra chuẩn, nó liệt kê những gì đã ghi:

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

Trên luồng lỗi chuẩn, với <workspace> đại diện cho thư mục nơi bạn đã chạy nó:

[… 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 differ
warn: 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 environment
made 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)

Lần nhập chạy từ trình soạn thảo: Aggregate, Release và Manifest được tạo nháp xuất hiện bên cạnh bản xuất luồng, đầu ra Aggrega liệt kê cách từng thành phần của luồng được ánh xạ và các tệp đã ghi, và một thông báo cho biết lần nhập đã tạo nháp 3 tệp, được nhận dạng là langflow.

  • Dòng mapped cho biết nút Language Model đã trở thành gì: mô hình OpenAI của thư viện chuẩn, core/ai-model/openai, được tham chiếu thay vì soạn nháp, vì nó khớp ở bậc cao, với điểm 0.9. Đây là một thành phần riêng, được nối vào socket model của nền tảng. Theo mặc định, bản nháp chạy toàn bộ luồng trên nền tảng chạy Langflow, và chỉ cấp một thành phần riêng cho một nút mà một socket của nền tảng đó nhận — một mô hình, một công cụ, một kho vector — khi nút đó được nhận diện là như vậy.
  • Dòng warn đầu tiên cho biết luồng được mang theo với các handle của mỗi cạnh được viết như trình soạn thảo của Langflow viết chúng. Langflow giữ các dự án khởi đầu của nó với một dấu cách sau mỗi dấu hai chấm và dấu phẩy trong các handle của một cạnh; trình soạn thảo của nó, khi mở một luồng, loại bỏ mọi cạnh có handle không được viết chính xác như nó viết, rồi lưu luồng mà không có cạnh đó. Được viết như vậy, luồng mở ra với ba kết nối của nó, và chạy với chúng.
  • Dòng warn nêu tên nút cho biết luồng tiếp cận mô hình đó như thế nào. Nút đọc khóa từ biến OPENAI_API_KEY, và địa chỉ từ OPENAI_BASE_URL, và nền tảng cung cấp cả hai cho kết nối mô hình, vì vậy luồng không cần chỉnh sửa.
  • Các dòng made no choice nêu tên những nút mà không socket nào của nền tảng nhận: chúng ở lại bên trong luồng, mà Langflow chạy đúng như khi được xuất.
  • Hai dòng cuối là bước pull. Không còn gì cần trả lời, nên quá trình nhập đã kéo các phụ thuộc của Release được soạn nháp, như aggrega pull làm, và ghi release.lock; bản build bên dưới không cần gì thêm. Dòng warning là dòng mà bản build cũng in ra, và Xác thực và build giải thích nó.

Tệp câu trả lời nêu tên hai Secret mà lần nhập này không yêu cầu: nó không để trống gì cho chúng, nên không áp dụng cái nào và giữ nguyên tệp.

Những gì được ghi

Aggregate, Release và Manifest được đặt tên imported/basic-prompting, theo tên riêng của luồng, Basic Prompting, rút gọn thành basic-prompting — một luồng không có tên được đặt tên theo tệp của nó — dưới namespace mà thiết lập target_namespace của trình nhập đặt ra, là imported trừ khi bạn đặt namespace khác (Thiết lập).

aggregate.yaml — một thể hiện của nền tảng Langflow trong thư viện chuẩn, core/ai-agent/langflow, mang luồng như khi được xuất, ngoại trừ các handle của các cạnh, được viết như trình soạn thảo của Langflow viết chúng, với hơn một nghìn dòng được lược bỏ ở đây, và mô hình mà luồng tiếp cận:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
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
  • Mô hình là core/ai-model/openai, với mô hình mà nút của luồng chọn, gpt-4.1. Chú thích phía trên nó nêu tên một Component khác trong danh mục mà nút giống, kèm điểm số, dành cho người đọc muốn dùng Component đó.
  • Hai bí mật — mật khẩu quản trị viên mà trình soạn thảo của Langflow yêu cầu, và khóa OpenAI mà nền tảng trình cho mô hình — được khai báo ở đây cùng với biến mà mỗi bí mật đến trong môi trường của Langflow, LANGFLOW_SUPERUSER_PASSWORD và OPENAI_API_KEY. Trên Docker Compose, một bí mật chỉ do Release gắn sẽ đến dưới khóa value, và hai bí mật sẽ xung đột; khi khai báo ở đây, mỗi bí mật có một khóa riêng. Release cho biết mỗi bí mật đến từ đâu.
  • flow_id là định danh mà bản xuất gán cho luồng.

release.yaml — Release, triển khai Aggregate với Manifest:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
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 là development, một giá trị mặc định mà chú thích phía trên nó bảo hãy đổi thành môi trường mà Release triển khai tới.
  • Image là Langflow 1.6.0, phiên bản mà các Recipes của danh mục dành cho Langflow chạy. Luồng được kiểm thử lần cuối trên Langflow 1.5.0, như chú thích cho biết; quá trình nhập giữ phiên bản mà các Recipes chạy thay vì theo phiên bản của luồng.
  • published_port là 7860, cổng mà Langflow phục vụ, vì vậy trình soạn thảo trả lời tại http://127.0.0.1:7860 trên máy của bạn. Như chú thích của nó cho biết, mọi tiến trình trên máy này đều có thể tiếp cận nó ở đó và không gì khác có thể; hãy xóa dòng này để giữ Langflow chỉ trên mạng của stack.
  • Hai bí mật là các tham chiếu biến, ${LANGFLOW_ADMIN_PASSWORD} và ${OPENAI_API_KEY}, mà Docker Compose điền từ shell của bạn khi stack khởi động, vì vậy không tệp nào chứa giá trị nào trong hai giá trị đó.

manifest.yaml — các Recipes Compose của nền tảng và mô hình, và phần hiện thực ghi tham chiếu biến của một bí mật vào tệp Compose đúng như đã viết:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/basic-prompting
version: 0.1.0
spec:
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 là bản ghi những gì quá trình nhập đã ghi, được một lệnh aggrega import --sync sau đó đọc, và release.lock ghim mọi thực thể danh mục mà Release phân giải tới, theo phiên bản và digest.

Xác thực và dựng

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

Release được tạo nháp mở trong trình soạn thảo sau khi xác thực, với đầu ra Aggrega và một thông báo đều báo cáo không tìm thấy vấn đề nào.

Bản build của Release được tạo nháp: một thư mục dist xuất hiện trong Explorer, đầu ra Aggrega liệt kê tệp Docker Compose đã ghi, và một thông báo cho biết 1 tệp đã được ghi.

Bước xác thực in ra:

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)

và bản dựng, với <workspace> đại diện cho thư mục chứa các bản nháp:

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

Dòng warning nói về phần của tệp Compose mang luồng, một mục configs ở cấp cao nhất, vốn không có dịch vụ nào để đặt các nhãn của bản build lên. Dòng notice mang tính tham khảo: Feature bí mật chấp nhận origin của nó từ values của Aggregate hoặc infra của Release, và thông báo cho biết một lá được khai báo ở cả hai nơi. Không dòng nào thay đổi kết luận.

dist/compose/docker-compose.yaml chứa Langflow và một dịch vụ chạy một lần trước nó:

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"

Luồng đến Langflow dưới dạng /app/flows/flow.json, từ một mục configs chứa luồng mà Aggregate mang theo, và Langflow nạp nó từ LANGFLOW_LOAD_FLOWS_PATH mỗi lần khởi động. Khóa và mật khẩu là các tham chiếu biến, được điền từ shell của bạn khi stack khởi động. Recipe Compose của Langflow chỉ công bố một cổng trên máy của bạn khi Release đặt published_port trong infra của Langflow, và khi đó chỉ trên địa chỉ loopback, 127.0.0.1; nếu không có nó, dịch vụ chỉ được tiếp cận trên mạng của stack.

langflow--data-owner chạy image của Langflow với quyền root, giao volume dữ liệu cho người dùng 1000, nhóm 0, là danh tính mà image của Langflow chạy dưới đó, rồi thoát. Langflow khởi động sau khi dịch vụ này hoàn tất: Docker tạo volume thuộc sở hữu của root, và nếu không thì Langflow không thể ghi dữ liệu của nó vào đó.

Với trợ lý AI

Một trợ lý AI được thiết lập với các công cụ của Aggrega có thể làm điều tương tự: dán prompt này vào nó.

Chỉ dùng các công cụ Aggrega, và không tự tạo thư mục nào. Nếu thư mục Workspace chưa có thư mục `import-langflow`, hãy gọi công cụ `scaffold` một lần với `example` đặt thành `import-langflow` và không có `dir`: nó ghi ví dụ vào một thư mục `import-langflow` mới, mà thư mục `source` của nó chứa những gì trang này nhập. Sau đó gọi công cụ `import` với `workspace_root` đặt thành `import-langflow/source`, `source` đặt thành `basic-prompting.json` và `target` đặt thành `compose`: nó đọc các câu trả lời cần thiết từ `import-answers.yaml` bên cạnh `basic-prompting.json`, ghi các bản nháp vào `import-langflow/source` và kéo những gì chúng cần. Sau đó gọi công cụ `validate` với `workspace_root` đặt thành `import-langflow/source` và `release` đặt thành `release.yaml`, và công cụ `build` với `workspace_root` đặt thành `import-langflow/source`, `release` đặt thành `release.yaml` và `write` đặt thành true. Cho tôi biết bản build đã ghi những tệp nào; chúng nằm trong `import-langflow/source/dist/`.

Mở trong VS Code

Khi đã cài tiện ích mở rộng Aggrega cho Visual Studio Code, hãy mở thư mục import-langflow/source trong VS Code, nơi lần nhập đã ghi các bản nháp. Thư mục chứa một Release, tức release.yaml được tạo nháp, vì vậy trình soạn thảo chọn nó cho bạn, và kiểm tra các bản nháp theo Release đó khi bạn chỉnh sửa, đánh dấu những gì nó tìm thấy trong tệp và trong bảng Problems. Aggrega: Show topology graph, trong Command Palette, vẽ các thành phần của Release và các kết nối giữa chúng. Aggrega: Build, Aggrega: Preview build và Aggrega: Pull hoạt động trên cùng Release đó, và mỗi lệnh cũng là một nút trên bảng Commands của chế độ xem Aggrega trong thanh hoạt động; Build ghi các tệp của nó vào dist/ của thư mục. Dùng Aggrega trong Visual Studio Code trình bày phần còn lại.

Chạy thử

Đặt khóa và mật khẩu quản trị viên trong shell của bạn, rồi khởi động stack:

Terminal window
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 đặt tên cho dự án, như bước chạy của Cách một lần nhập diễn ra giải thích. --wait trả về khi langflow--data-owner đã hoàn tất và Langflow báo cáo trạng thái khỏe mạnh.

Kiểm thử

Mở http://127.0.0.1:7860, địa chỉ mà published_port công bố, và đăng nhập với tư cách admin bằng mật khẩu bạn đã đặt: Basic Prompting nằm trong trình soạn thảo với ba kết nối của nó.

Langflow chỉ chạy một luồng qua API của nó cho một khóa API, mà quản trị viên tạo sau khi đăng nhập. Đăng nhập:

Terminal window
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"}

tạo một khóa bằng access token:

Terminal window
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]"}

và chạy luồng bằng khóa đó:

Terminal window
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"}'

Lần chạy đã dùng một giá trị giữ chỗ cho khóa OpenAI, nên câu trả lời là việc OpenAI từ chối khóa, điều này cho thấy luồng đã chạy đến tận lệnh gọi mô hình:

{"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]}"}

Với khóa của bạn, câu trả lời mang nội dung trả lời của mô hình tại outputs[0].outputs[0].results.message.text.

Trên Kubernetes, với bản build mà Trên Kubernetes mô tả đã được áp dụng, hãy chuyển tiếp một cổng cục bộ tới Service của Langflow, langflow-default, trong namespace bạn đã áp dụng vào, và để lệnh tiếp tục chạy:

Terminal window
kubectl port-forward -n <namespace> svc/langflow-default 7860:7860

Từ một terminal khác, ba yêu cầu ở trên đến được Langflow tại cùng địa chỉ, không thay đổi; lần chạy nhận được cùng sự từ chối khóa giữ chỗ.

Dừng stack bằng lệnh dưới đây. -v cũng xóa volume dữ liệu của Langflow, và cùng với nó là tài khoản quản trị viên, khóa API và lịch sử chạy của luồng:

Terminal window
docker compose -p basic-prompting -f dist/compose/docker-compose.yaml down -v

Trên Kubernetes

Cùng luồng đó được nhập cho Kubernetes với target helm. Các bản nháp cho Docker Compose đã nằm sẵn trong source, và lần nhập không bao giờ ghi đè một Aggregate ở đó, vì vậy hãy tạo các bản nháp này vào một thư mục riêng bằng --output-dir, rồi xác thực và build từ đó:

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

Các bản nháp khác nhau ở những chỗ target khác nhau. Manifest ánh xạ nền tảng sang helm/langflow, mô hình sang helm/openai, và mỗi secret sang helm/k8s-existing-secret, thành phần đọc secret đó từ một Secret đã có trong namespace. Release gắn hai secret dưới dạng core/referenced-secret, mỗi secret nêu tên Secret đó, và các tên này chính là nội dung mà tệp câu trả lời lưu giữ:

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"

Nếu không có tệp câu trả lời, quá trình nhập sẽ hỏi cả hai tên tại terminal và ghi câu trả lời của bạn vào một tệp câu trả lời mới. Ở nơi không thể hỏi gì, nó ghi tệp đó với cả hai khóa và câu trả lời trống, rồi kết thúc với trạng thái 1 và dòng này, trong đó <workspace> đại diện cho thư mục bạn đã chạy nó:

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

Bản build ghi các manifest Kubernetes thuần trong dist/helm/ tại thư mục gốc của workspace, source, mà từ helm là ../dist/helm/. Hãy tạo hai Secrets trong namespace bạn áp dụng vào, mỗi Secret giữ giá trị của nó dưới khóa dữ liệu value, rồi áp dụng thư mục như bước chạy của Cách một lần nhập chạy giải thích.