تخطَّ إلى المحتوى
AggregaAggregaAggregaAggrega
اختر لغة: العربية
تُرجمت هذه الصفحة آليًا. اقرأ الأصل الإنجليزي.

استيراد تدفق من Langflow

يستورد هذا الشرح العملي تدفقًا مُصدَّرًا من Langflow — Basic Prompting، المشروع المبدئي الذي يشحنه Langflow 1.6.0 — إلى Aggregate و Release و Manifest تبني معًا Langflow حاملًا التدفق من أجل Docker Compose كما هي مكتوبة، ثم يبنيها ويشغّل النتيجة. يأتي كل ملف وكل كتلة إخراج أدناه من تشغيل فعلي؛ ويوجد التدفق وكل مرحلة من مراحل الشرح العملي في المثال import-langflow، حيث يعيد نص فحص برمجي تشغيل الاستيراد، ويقارن ما يكتبه وما يطبعه والكتل التي تنقلها هذه الصفحة بالملفات المحفوظة هناك، ويتحقق مما كتبه الاستيراد ويبنيه.

صُغ مسودة المثال

يمكنك تشغيل هذا الاستيراد بالأوامر الواردة في هذه الصفحة، أو اجعل مساعد الذكاء الاصطناعي يشغّله نيابةً عنك.

اكتب المثال في مجلد جديد يحمل اسمه:

Terminal window
aggrega draft --example import-langflow

ثم يطبع الأوامر التي تشغّلها بعد ذلك. ينتقل الأول إلى المجلد الجديد؛ وينتقل الذي بعده، أدناه، إلى مجلده source، حيث يعمل الاستيراد. ويحمل ذلك المجلد ملف التدفق، basic-prompting.json، الذي تصفه هذه الصفحة ولا تنقله:

Terminal window
cd import-langflow

مجلد source في المثال المصوغ مفتوحًا في Visual Studio Code، يُظهر تصدير تدفق Langflow لتدفق basic prompting.

التدفق

يسلسل Basic Prompting أربع عقد: Chat Input و Prompt و Language Model يستدعي gpt-4.1 من OpenAI، و Chat Output. وكما يشحنه Langflow، هو ملف JSON واحد، basic-prompting.json، بنحو 54 KB، يحمل الشيفرة المصدرية لكل مكوِّن إضافة إلى التدفق. وتقرأ عقدة 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 من shell لديك. أما الاستيراد من أجل Kubernetes فيرفق كل سرّ باسم Secret في Kubernetes، لا يستطيع تسميته غيرك، لذا يسمّي الملف كيانَي 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 Manifest من Recipes الخاصة بها. لا تسمّي مساحة العمل أي مجلد كتالوج، لذا يقرأ الاستيراد كتالوج المكتبة القياسية من registry الذي يجلب منه مستورِده: لقطة موقَّعة للكتالوج المطروح، تُجلب وتُتحقق وتُحفظ في ذاكرة التخزين المؤقت لمحتوى مساحة العمل عند أول استيراد، ويسمّيها ملخّصها في الملف الذي يسجّل ما كتبه الاستيراد بجانب مسوداته. وتُستورد مساحة العمل التي تسمّي مجلدات كتالوج خاصة بها — في 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 كيف عُيّن كل مكوِّن في التدفق والملفات المكتوبة، ويفيد إشعار بأن الاستيراد صاغ 3 ملفات، وتعرّف عليها بوصفها langflow.

  • سطر 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 كما صُدِّر.
  • السطران الأخيران هما عملية pull. لم يبق شيء للإجابة عنه، فنفّذ الاستيراد pull لتبعيات Release المصوغ، كما يفعل aggrega pull، وكتب 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 — هو Release الذي ينشر Aggregate باستخدام 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 هو development، قيمة افتراضية يطلب التعليق الذي فوقه تغييرها إلى البيئة التي ينشر Release فيها.
  • صورة الحاوية هي Langflow 1.6.0، وهو الإصدار الذي تشغّله Recipes الكتالوج المخصصة لمنصة Langflow. وقد اختُبر التدفق آخر مرة على Langflow 1.5.0، كما يقول التعليق؛ ويبقي الاستيراد على الإصدار الذي تشغّله Recipes بدل اتباع إصدار التدفق.
  • published_port هو 7860، المنفذ الذي يخدم عليه Langflow، فيجيب المحرر على http://127.0.0.1:7860 على جهازك. وكما يقول تعليقه، يمكن لأي عملية على هذا الجهاز الوصول إليه هناك ولا شيء غيرها؛ احذف السطر لإبقاء Langflow على شبكة مكدس Compose وحدها.
  • السرّان مرجعا متغيّر، ${LANGFLOW_ADMIN_PASSWORD} و ${OPENAI_API_KEY}، يملؤهما Docker Compose من shell لديك عند بدء مكدس Compose، فلا يحمل أي ملف أيًّا من القيمتين.

manifest.yaml — Recipes من نوع Compose للمنصة وللنموذج، والتحقيق الذي يكتب مرجع متغيّر السرّ في ملف 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 في 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 "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 السرّ 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"

يصل التدفق إلى Langflow باسم /app/flows/flow.json، من إدخال configs يحمل التدفق الذي يحمله Aggregate، ويحمّله Langflow من LANGFLOW_LOAD_FLOWS_PATH عند كل بدء. والمفتاح وكلمة المرور مرجعا متغيّر، يُملآن من shell لديك عند بدء مكدس Compose. ولا يطرح Recipe من نوع Compose لمنصة Langflow منفذًا على جهازك إلا حيث يضبط Release قيمة published_port في infra لمنصة Langflow، ثم على عنوان loopback، 127.0.0.1، وحده؛ ومن دونه يُوصل إلى الخدمة على شبكة مكدس Compose وحدها.

تشغّل langflow--data-owner صورة Langflow بصفة root، وتعطي وحدة تخزين البيانات للمستخدم 1000 ومجموعة المستخدمين 0، الهوية التي تعمل بها صورة Langflow، ثم تنتهي. ويبدأ Langflow بعد أن تكتمل: ينشئ Docker وحدة التخزين مملوكة للمستخدم root، ولن يستطيع Langflow كتابة بياناته هناك لولا ذلك.

مع مساعد الذكاء الاصطناعي

يستطيع مساعد الذكاء الاصطناعي المُعَدّ بأدوات Aggrega أن يفعل الشيء نفسه: الصق هذا الموجِّه فيه.

استخدم أدوات Aggrega وحدها، ولا تنشئ أي مجلد بنفسك. إن لم يكن في مجلد مساحة العمل مجلد `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

مع امتداد Aggrega لمحرر Visual Studio Code المثبَّت، افتح المجلد import-langflow/source في VS Code، حيث كتب الاستيراد مسوداته. يضم المجلد Release واحدًا هو release.yaml المصوغ، فيحدده المحرر لك، ويتحقق من المسودات مقابل ذلك Release أثناء تحريرك لها، ويعلّم ما يجده في الملف وفي لوحة Problems. يرسم Aggrega: Show topology graph، في لوحة الأوامر، مكوِّنات Release والاتصالات بينها. وتعمل Aggrega: Build و Aggrega: Preview build و Aggrega: Pull على Release نفسه، وكلٌّ منها زر أيضًا في لوحة Commands من عرض Aggrega في شريط الأنشطة؛ ويكتب Build ملفاته في dist/ داخل المجلد. ويغطي استخدام Aggrega في Visual Studio Code ما تبقى.

شغِّله

اضبط المفتاح وكلمة مرور المسؤول في shell لديك، ثم ابدأ مكدس Compose:

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 أنه بحالة سليمة.

اختبره

افتح http://127.0.0.1:7860، العنوان الذي يطرحه published_port، وسجّل الدخول بصفتك 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، أعِد توجيه منفذ محلي إلى Service في Langflow، langflow-default، في مساحة الأسماء التي طبّقت عليها، واترك الأمر يعمل:

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

من طرفية أخرى، تصل الطلبات الثلاثة أعلاه إلى Langflow على العنوان نفسه، دون تغيير؛ وقد حصل التشغيل على رفض المفتاح المؤقت نفسه.

أوقف مكدس Compose بالأمر أدناه. ويزيل -v أيضًا وحدة تخزين بيانات Langflow، ومعها حساب المسؤول ومفتاح API وسجل تشغيلات التدفق:

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

على Kubernetes

يُستورد التدفق نفسه من أجل Kubernetes بالهدف helm. مسودات 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

يكتب البناء ملفات بيان Kubernetes عادية تحت dist/helm/ في جذر مساحة العمل، source، ومن helm يكون مساره ../dist/helm/. أنشئ كيانَي Secret في مساحة الأسماء التي تطبّق عليها، يحمل كلٌّ منهما قيمته تحت مفتاح البيانات value، ثم طبّق المجلد كما تشرح خطوة التشغيل في كيف يعمل الاستيراد.