콘텐츠로 이동
AggregaAggrega
언어 선택: 한국어
이 페이지는 기계 번역되었습니다. 영어 원문 읽기.

Langflow 플로우 가져오기

이 워크스루에서는 Langflow에서 내보낸 플로우(Langflow 1.6.0에 포함된 스타터 프로젝트 Basic Prompting)를, 작성된 그대로 플로우를 담은 Langflow를 Docker Compose용으로 빌드하는 Aggregate, Release, Manifest로 가져온 다음, 이를 빌드하고 결과를 실행합니다. 아래의 모든 파일과 모든 출력 블록은 실제 실행에서 나온 것입니다. 플로우와 워크스루의 각 단계는 import-langflow 예제에 있으며, 그곳의 검사 스크립트가 가져오기를 다시 실행하여 작성하는 내용, 출력하는 내용, 그리고 이 페이지가 인용하는 블록을 그곳에 보관된 파일과 비교하고, 가져오기가 작성한 내용을 검증하고 빌드합니다.

예제 생성하기

이 페이지의 명령으로 이 가져오기를 실행하거나, AI 어시스턴트가 대신 실행하게 할 수 있습니다.

예제 이름을 딴 새 폴더에 예제를 씁니다:

Terminal window
aggrega scaffold --example import-langflow

그런 다음 이어서 실행할 명령을 출력합니다. 첫 번째 명령은 새 폴더로 이동합니다. 그 뒤의 명령은 아래와 같으며, 새 폴더 안의 source 폴더로 이동합니다. 가져오기는 여기서 실행됩니다. 이 폴더에는 플로 파일 basic-prompting.json이 들어 있으며, 이 페이지는 그 내용을 인용하지 않고 설명합니다:

Terminal window
cd import-langflow

Visual Studio Code에서 연 스캐폴드된 예제의 source 폴더로, 기본 프롬프팅 플로우의 Langflow 플로우 내보내기를 보여 줍니다.

플로우

Basic Prompting은 네 개의 노드를 연결합니다. Chat Input, Prompt, OpenAI의 gpt-4.1을 호출하는 Language Model, 그리고 Chat Output입니다. Langflow가 기본으로 제공하는 형태로는 약 54 KB 크기의 JSON 파일 하나, basic-prompting.json이며, 플로우뿐 아니라 각 컴포넌트의 소스 코드도 담고 있습니다. 그 Language Model 노드는 전역 변수 OPENAI_API_KEY에서 키를 읽으며, 그 이름의 변수가 저장되어 있지 않으면 Langflow가 이를 자체 환경에서 읽습니다.

플로우 옆에 있는 .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은 어떤 플로우도 담을 수 없는 것에 대한 답변을 담습니다. Docker Compose용 가져오기에는 그중 어느 것도 필요하지 않습니다. 각 시크릿을 Docker Compose가 셸에서 채우는 변수 참조로 연결하기 때문입니다. Kubernetes용 가져오기는 각 시크릿을 Kubernetes Secret의 이름으로 연결하는데, 그 이름은 사용자만 지정할 수 있으므로 이 파일은 해당 가져오기가 요구하는 두 Secret을 지정합니다(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"

각 답변은 Secret의 이름이며 시크릿 자체가 아니므로, 파일을 플로우와 함께 보관할 수 있습니다. 가져오기 답변 파일에서 파일 전체를 설명합니다.

가져오기는 각 노드를 작업 공간 카탈로그의 Components와 비교하여 평가하고, --target은 그 카탈로그의 Recipes로부터 Manifest 초안을 작성합니다. 작업 공간이 카탈로그 폴더를 지정하지 않으므로, 가져오기는 임포터를 받아 오는 레지스트리에서 표준 라이브러리 카탈로그를 읽습니다. 이는 게시된 카탈로그의 서명된 스냅샷으로, 첫 번째 가져오기가 받아 와서 검증한 뒤 작업 공간의 콘텐츠 캐시에 보관하며, 가져오기가 초안 옆에 작성하는 기록에 그 다이제스트로 지정됩니다. AGGREGA_CATALOG_DIRS에서 또는 workspace.catalog_dirs 아래에서 자체 카탈로그 폴더를 지정하는 작업 공간은 대신 그 폴더들을 기준으로 가져옵니다. source로 이동합니다:

Terminal window
cd source

가져오기 실행

Terminal window
aggrega import basic-prompting.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 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)

편집기에서 실행한 가져오기: 초안으로 작성된 Aggregate, Release, Manifest가 플로우 내보내기 파일 옆에 나타나고, Aggrega 출력에는 플로우의 각 컴포넌트가 어떻게 매핑되었는지와 작성된 파일이 나열되며, 알림은 가져오기가 langflow로 인식되어 3개의 파일을 초안으로 작성했음을 알려 줍니다.

  • mapped 줄은 Language Model 노드가 무엇이 되었는지를 나타냅니다. 표준 라이브러리의 OpenAI 모델인 core/ai-model/openai이며, 높은 등급에서 0.9의 점수로 일치했으므로 초안으로 작성되지 않고 참조되었습니다. 이는 자체 컴포넌트이며, 플랫폼의 model 소켓에 연결되어 있습니다. 기본적으로 초안은 Langflow를 실행하는 플랫폼에서 플로우 전체를 실행하며, 그 플랫폼의 소켓이 받는 노드(모델, 도구, 벡터 저장소)가 그러한 노드로 인식된 경우에만 자체 컴포넌트를 부여합니다.
  • 첫 번째 warn 줄은 플로우가 각 엣지의 핸들을 Langflow 편집기가 쓰는 방식대로 작성한 상태로 담긴다는 것을 나타냅니다. Langflow는 스타터 프로젝트를 엣지 핸들의 모든 콜론과 쉼표 뒤에 공백을 넣은 형태로 보관합니다. 반면 편집기는 플로우를 열 때 핸들이 자신이 쓰는 방식과 정확히 같게 작성되지 않은 엣지를 모두 버린 다음, 그 엣지 없이 플로우를 저장합니다. 이렇게 작성되면 플로우는 세 개의 연결을 가진 채로 열리고, 그 연결로 실행됩니다.
  • 노드를 지목하는 warn 줄은 플로우가 그 모델에 어떻게 도달하는지를 나타냅니다. 노드는 키를 변수 OPENAI_API_KEY에서, 주소를 OPENAI_BASE_URL에서 읽으며, 플랫폼이 모델 연결을 위해 둘 다 전달하므로 플로우는 수정할 필요가 없습니다.
  • made no choice 줄은 플랫폼의 어떤 소켓도 받지 않는 노드를 나열합니다. 이 노드들은 플로우 안에 남으며, Langflow는 플로우를 내보낸 그대로 실행합니다.
  • 마지막 두 줄은 풀입니다. 답할 것이 남지 않았으므로 가져오기는 aggrega pull과 같은 방식으로 초안 Release의 종속성을 가져오고 release.lock을 작성했습니다. 아래의 빌드에는 더 이상 필요한 것이 없습니다. warning 줄은 빌드도 출력하는 줄이며, 검증 및 빌드에서 설명합니다.

답변 파일은 이 가져오기가 요청하지 않는 두 개의 Secret을 지정합니다. 가져오기는 이들을 위해 비워 둔 것이 없으므로 어느 것도 적용하지 않고 파일을 그대로 둡니다.

작성하는 내용

Aggregate, Release, Manifest의 이름은 imported/basic-prompting입니다. 플로 자체의 이름 Basic Prompting을 basic-prompting으로 줄인 것이며, 이름이 없는 플로는 파일 이름을 따릅니다. 네임스페이스는 임포터의 target_namespace 설정이 정하며, 다른 값을 설정하지 않으면 imported입니다(설정).

aggregate.yaml — 표준 라이브러리 Langflow 플랫폼 core/ai-agent/langflow의 인스턴스 하나로, 내보낸 그대로의 플로우(단, 엣지의 핸들은 Langflow 편집기가 쓰는 방식대로 작성되며, 여기서는 그중 천 줄 이상을 생략했습니다)와 플로우가 도달하는 모델을 담고 있습니다:

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
  • 모델은 core/ai-model/openai이며, 플로우의 노드가 선택하는 모델 gpt-4.1을 사용합니다. 그 위의 주석은 노드와 유사한 카탈로그의 다른 Component를 점수와 함께 제시하며, 그것을 원하는 독자를 위한 것입니다.
  • 두 시크릿(Langflow 편집기가 요구하는 관리자 비밀번호와 플랫폼이 모델에 제시하는 OpenAI 키)은 각각이 Langflow 환경에 도착할 때 사용하는 변수 LANGFLOW_SUPERUSER_PASSWORD 및 OPENAI_API_KEY와 함께 여기에서 선언됩니다. Docker Compose에서는 Release만으로 첨부된 시크릿이 키 value 아래에 도착하므로 두 시크릿이 충돌합니다. 여기에서 선언하면 각각 자체 키를 갖습니다. 각각의 출처는 Release가 지정합니다.
  • **flow_id**는 내보낸 파일이 플로우에 부여하는 식별자입니다.

release.yaml — Manifest로 Aggregate를 배포하는 Release입니다:

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 값은 development입니다. 이는 기본값이며, 그 위의 주석은 Release가 배포되는 환경으로 바꾸라고 안내합니다.
  • 이미지는 Langflow 1.6.0으로, 카탈로그의 Langflow용 Recipes가 실행하는 버전입니다. 주석에 적힌 대로 이 플로우는 마지막으로 Langflow 1.5.0에서 테스트되었습니다. 가져오기는 플로우의 버전을 따르지 않고 Recipes가 실행하는 버전을 유지합니다.
  • **published_port**는 Langflow가 서비스하는 포트인 7860이므로, 편집기는 사용자의 머신에서 http://127.0.0.1:7860으로 응답합니다. 주석에 적힌 대로 이 머신의 모든 프로세스는 그곳에서 접근할 수 있고 그 밖의 것은 접근할 수 없습니다. Langflow를 스택의 네트워크에만 두려면 이 줄을 삭제합니다.
  • 두 시크릿은 변수 참조 ${LANGFLOW_ADMIN_PASSWORD} 및 ${OPENAI_API_KEY}이며, 스택이 시작될 때 Docker Compose가 셸에서 채우므로 어떤 파일에도 두 값이 담기지 않습니다.

manifest.yaml — 플랫폼과 모델의 Compose Recipes, 그리고 시크릿의 변수 참조를 Compose 파일에 그대로 기록하는 구현입니다:

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은 가져오기가 작성한 내용의 기록으로, 이후의 aggrega import --sync가 이를 읽습니다. release.lock은 Release가 해석되는 모든 카탈로그 엔터티를 버전과 다이제스트로 고정합니다.

검증 및 빌드

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

검증 후 편집기에서 연 초안 Release로, Aggrega 출력과 알림이 모두 발견된 문제가 없다고 보고합니다.

초안 Release의 빌드: 탐색기에 dist 폴더가 나타나고, Aggrega 출력에는 작성된 Docker Compose 파일이 나열되며, 알림은 1개의 파일이 작성되었음을 알려 줍니다.

검증 결과는 다음과 같습니다:

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 줄은 Compose 파일에서 플로우를 담는 부분, 즉 최상위 configs 항목에 관한 것으로, 이 항목에는 빌드의 레이블을 붙일 서비스가 없습니다. notice 줄은 참고용입니다. 시크릿 Feature는 Aggregate의 values 또는 Release의 infra에서 origin을 받으며, 이 알림은 하나의 리프가 양쪽 모두에 선언되어 있음을 보고합니다. 어느 쪽도 판정을 바꾸지 않습니다.

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"

플로우는 Aggregate가 담고 있는 플로우를 보관하는 configs 항목으로부터 /app/flows/flow.json으로 Langflow에 도달하며, Langflow는 시작할 때마다 LANGFLOW_LOAD_FLOWS_PATH에서 이를 불러옵니다. 키와 비밀번호는 변수 참조이며, 스택이 시작될 때 셸에서 값이 채워집니다. Langflow의 Compose Recipe는 Release가 Langflow의 infra에 published_port를 설정한 경우에만 사용자의 머신에 포트를 게시하며, 그때도 루프백 주소 127.0.0.1에만 게시합니다. 이 설정이 없으면 서비스는 스택의 네트워크에서만 접근할 수 있습니다.

langflow--data-owner는 Langflow의 이미지를 root로 실행하여, 데이터 볼륨을 Langflow의 이미지가 실행되는 신원인 사용자 1000, 그룹 0에 넘겨준 뒤 종료합니다. Langflow는 이 서비스가 완료된 뒤에 시작됩니다. Docker는 볼륨을 root 소유로 생성하므로, 그렇게 하지 않으면 Langflow가 그곳에 데이터를 쓸 수 없습니다.

AI 어시스턴트 사용

Aggrega의 도구로 설정된 AI 어시스턴트도 같은 일을 할 수 있습니다. 다음 프롬프트를 붙여 넣으십시오.

Aggrega 도구만 사용하고, 폴더를 직접 만들지 마세요. Workspace 폴더에 아직 `import-langflow` 폴더가 없으면, `example`을 `import-langflow`로 설정하고 `dir`은 지정하지 않은 채 `scaffold` 도구를 한 번 호출하세요. 이 도구는 예제를 새 `import-langflow` 폴더에 작성하며, 그 `source` 폴더에 이 페이지에서 가져오는 내용이 들어 있습니다. 그런 다음 `workspace_root`를 `import-langflow/source`로, `source`를 `basic-prompting.json`으로, `target`을 `compose`로 설정하여 `import` 도구를 호출하세요. 이 도구는 필요한 답변을 `basic-prompting.json` 옆의 `import-answers.yaml`에서 읽고, 초안을 `import-langflow/source`에 작성하며, 초안에 필요한 것을 가져옵니다. 그런 다음 `workspace_root`를 `import-langflow/source`로, `release`를 `release.yaml`로 설정하여 `validate` 도구를 호출하고, `workspace_root`를 `import-langflow/source`로, `release`를 `release.yaml`로, `write`를 true로 설정하여 `build` 도구를 호출하세요. 빌드가 어떤 파일을 작성했는지 알려 주세요. 파일은 `import-langflow/source/dist/` 아래에 있습니다.

VS Code에서 열기

Visual Studio Code용 Aggrega 확장을 설치한 상태에서, 가져오기가 초안을 작성한 폴더 import-langflow/source를 VS Code에서 엽니다. 이 폴더에는 Release가 하나, 즉 초안으로 작성된 release.yaml만 있으므로 편집기가 이를 자동으로 선택하고, 초안을 편집하는 동안 그 Release를 기준으로 검사하여 발견한 내용을 파일과 문제 패널에 표시합니다. 명령 팔레트의 Aggrega: Show topology graph는 Release의 컴포넌트와 그 사이의 연결을 그립니다. Aggrega: Build, Aggrega: Preview build, Aggrega: Pull은 같은 Release에 대해 동작하며, 각각 작업 표시줄의 Aggrega 보기에 있는 Commands 패널의 버튼으로도 제공됩니다. Build는 폴더의 dist/에 파일을 작성합니다. 나머지 내용은 Visual Studio Code에서 Aggrega 사용하기에서 다룹니다.

실행하기

셸에서 키와 관리자 비밀번호를 설정한 다음 스택을 시작합니다:

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는 가져오기 실행 방식의 실행 단계에서 설명하듯이 프로젝트 이름을 지정합니다. --wait는 langflow--data-owner가 완료되고 Langflow가 정상 상태를 보고하면 반환됩니다.

테스트하기

published_port가 게시하는 주소인 http://127.0.0.1:7860을 열고, 설정한 비밀번호로 admin으로 로그인합니다. Basic Prompting이 세 개의 연결과 함께 편집기에 있습니다.

Langflow는 API 키에 대해서만 API를 통해 플로우를 실행하며, 이 키는 관리자가 로그인한 후 만듭니다. 로그인합니다:

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

액세스 토큰으로 키를 만든 다음:

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

그 키로 플로를 실행합니다:

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

이 실행에서는 OpenAI 키에 자리 표시자를 사용했으므로, 응답은 OpenAI의 키 거부이며, 이는 플로우가 모델 호출까지 실행되었음을 보여 줍니다:

{"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에서는 Kubernetes에서에서 설명하는 빌드를 적용한 상태에서, 적용한 네임스페이스에 있는 Langflow의 Service langflow-default로 로컬 포트를 포워딩하고 명령을 실행 상태로 둡니다:

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

다른 터미널에서 위의 세 요청은 변경 없이 같은 주소로 Langflow에 도달합니다. 이 실행에서도 자리 표시자 키에 대한 같은 거부가 반환되었습니다.

아래 명령으로 스택을 중지합니다. -v는 Langflow의 데이터 볼륨도 제거하며, 그와 함께 관리자 계정, API 키, 플로의 실행 기록도 제거됩니다:

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

Kubernetes에서

같은 플로우를 helm 타깃으로 Kubernetes용으로 가져올 수 있습니다. Docker Compose용 초안은 이미 source에 있고 가져오기는 그곳의 Aggregate를 절대 덮어쓰지 않으므로, 이 초안은 --output-dir로 별도의 폴더에 작성한 다음 그 폴더에서 검증하고 빌드합니다:

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

초안은 대상이 다른 부분에서 달라집니다. Manifest는 플랫폼을 helm/langflow에, 모델을 helm/openai에, 각 시크릿을 helm/k8s-existing-secret에 매핑하며, 이는 네임스페이스에 이미 있는 Secret에서 시크릿을 읽습니다. Release는 두 시크릿을 core/referenced-secret으로 연결하고 각각 해당 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"

응답 파일이 없으면 가져오기는 터미널에서 두 이름을 묻고 답을 새 응답 파일에 작성합니다. 아무것도 물을 수 없는 경우에는 두 키와 빈 답을 담은 그 파일을 작성하고, 상태 1과 다음 줄로 종료합니다. 여기서 <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

빌드는 작업 공간 루트인 source의 dist/helm/ 아래에 일반 Kubernetes 매니페스트를 작성하며, 이는 helm에서 보면 ../dist/helm/입니다. 적용할 네임스페이스에 두 Secret을 만들고 각각 데이터 키 value 아래에 값을 담은 다음, 가져오기 실행 방식의 실행 단계에서 설명하는 대로 폴더를 적용합니다.