इसे छोड़कर कंटेंट पर जाएं
AggregaAggregaAggregaAggrega
भाषा चुने: हिन्दी
इस पेज का मशीन अनुवाद किया गया है। मूल अंग्रेज़ी पढ़ें।

Dify एप्लिकेशन इम्पोर्ट करें

यह वॉकथ्रू Dify से एक्सपोर्ट किए गए एक एप्लिकेशन — एक OpenAI मॉडल पर चलने वाला चैट असिस्टेंट — को एक Aggregate, एक Release और एक Manifest में इम्पोर्ट करता है, जो एप्लिकेशन को साथ लिए हुए स्टैंडर्ड लाइब्रेरी के Dify इंस्टॉलेशन को Kubernetes के लिए, जैसे वे लिखे गए हैं वैसे ही, बिल्ड करते हैं, फिर उन्हें बिल्ड करता है और परिणाम चलाता है। नीचे की हर फ़ाइल और आउटपुट का हर ब्लॉक एक वास्तविक रन से आता है; एप्लिकेशन और वॉकथ्रू का हर चरण import-dify उदाहरण में है, जहाँ एक चेक स्क्रिप्ट इम्पोर्ट को फिर से चलाती है, वह जो लिखता है, जो प्रिंट करता है और यह पेज जिन ब्लॉकों को उद्धृत करता है, उनकी तुलना वहाँ रखी फ़ाइलों से करती है, और इम्पोर्ट द्वारा लिखी गई चीज़ों को वैलिडेट और बिल्ड करती है।

उदाहरण ड्राफ़्ट करें

आप यह इम्पोर्ट इस पेज के कमांडों से चला सकते हैं, या इसे अपने AI असिस्टेंट से चलवा सकते हैं।

उदाहरण को उसी के नाम वाले एक नए फ़ोल्डर में लिखें:

Terminal window
aggrega draft --example import-dify

फिर यह आगे चलाने के लिए कमांड प्रिंट करता है। पहला कमांड नए फ़ोल्डर में ले जाता है; उसके बाद वाला, नीचे दिया गया, उसके source फ़ोल्डर में ले जाता है, जिसमें वह है जिसे यह पेज इम्पोर्ट करता है और जहाँ इम्पोर्ट चलता है:

Terminal window
cd import-dify

ड्राफ़्ट किए गए उदाहरण का source फ़ोल्डर Visual Studio Code में खुला है, जिसमें चैट मोड में एक सपोर्ट असिस्टेंट का Dify ऐप एक्सपोर्ट दिख रहा है।

एप्लिकेशन

support-assistant.yml, जो इस वॉकथ्रू के लिए लिखा गया है, Dify के DSL में एक चैट एप्लिकेशन है, यानी वह YAML जिसे Dify किसी एप्लिकेशन के लिए एक्सपोर्ट करता है, DSL संस्करण 0.7.0 पर: एक आरंभिक कथन, एक छोटा प्रॉम्प्ट, और वह मॉडल जिससे वह उत्तर देता है, जिसका नाम उसके प्रोवाइडर के साथ दिया गया है:

model:
completion_params:
stop: []
temperature: 0.4
mode: chat
name: gpt-4o-mini
provider: langgenius/openai/openai

उसके बगल में एक .aggrega-config.yaml फ़ोल्डर को वर्कस्पेस बनाती है:

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

और import-answers.yaml उन चीज़ों के उत्तर रखती है जिन्हें कोई एप्लिकेशन नहीं रख सकता: इंस्टॉलेशन का एप्लिकेशन सीक्रेट, यानी वह कुंजी जिससे Dify सेशन पर हस्ताक्षर करता है और जिसके अंतर्गत वह अपने द्वारा संग्रहीत मॉडल-प्रोवाइडर कुंजियों को एन्क्रिप्ट करता है; और वह ओनर खाता जिसके अंतर्गत एप्लिकेशन इम्पोर्ट किया जाता है, उसका ईमेल और उसका पासवर्ड। Kubernetes पर हर सीक्रेट किसी Kubernetes Secret से पढ़ा जाता है, इसलिए उसका उत्तर उस Secret का नाम है; वही फ़ाइल Docker Compose के लिए इम्पोर्ट में भी काम आती है, जैसा Docker Compose पर दिखाता है:

# 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:
# Passed down to core/dify's secret_key parameter, which has no default; that parameter's description
# in core/dify says what the value is.
spec.parameters.secret_key: "dify-credentials"
# Email address of the installation's owner account, read only when values.app_definition is set. The
# step that imports the application creates this account when it performs Dify's first-time setup, and
# signs in as it; on an installation whose setup has already run, it names an existing account allowed
# to import applications, and the password attached to the owner_password slot is that account's.
# Required when values.app_definition is set: the build halts when it is empty. It has no default.
spec.boundaries.platform.aggregates.dify.components.api.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.boundaries.platform.aggregates.dify.components.api.features.owner_password.infra.origin: "dify-owner"

owner@example.com आपके अपने किसी ईमेल के स्थान पर है; dify-credentials और dify-owner वे Secrets हैं जिन्हें इसे चलाएं बनाता है। फ़ाइल के बिना, किसी टर्मिनल पर इम्पोर्ट तीनों मानों में से हर एक के लिए पूछता है, एक समय में एक प्रश्न, और आपके उत्तरों को एक नई उत्तर फ़ाइल में लिखता है; जहाँ कुछ भी नहीं पूछा जा सकता, वहाँ यह उस फ़ाइल को तीनों कुंजियों और खाली उत्तरों के साथ लिखता है, उन्हें सूचीबद्ध करता है, और स्टेटस 1 के साथ बाहर निकलता है। इम्पोर्ट उत्तर फ़ाइल फ़ाइल का पूरा वर्णन करती है।

वर्कस्पेस किसी कैटलॉग फ़ोल्डर का नाम नहीं देता, इसलिए इम्पोर्ट स्टैंडर्ड लाइब्रेरी का कैटलॉग उसी रजिस्ट्री से पढ़ता है जिससे वह अपना इम्पोर्टर लाता है: प्रकाशित कैटलॉग का एक हस्ताक्षरित स्नैपशॉट, जिसे पहला इम्पोर्ट लाता है, सत्यापित करता है और वर्कस्पेस के कंटेंट कैश में रखता है, और जिसका नाम उसके डाइजेस्ट से उस रिकॉर्ड में दिया जाता है जिसे इम्पोर्ट अपने ड्राफ़्ट के बगल में लिखता है। जो वर्कस्पेस अपने स्वयं के कैटलॉग फ़ोल्डरों का नाम देता है — AGGREGA_CATALOG_DIRS में, या workspace.catalog_dirs के अंतर्गत — उन्हें पहले पढ़ता है, उनके पीछे प्रकाशित स्नैपशॉट के साथ। source में जाएँ:

Terminal window
cd source

इम्पोर्ट चलाएं

स्टैंडर्ड लाइब्रेरी का Dify इंस्टॉलेशन Kubernetes पर और Docker Compose पर रियलाइज़ होता है। यह वॉकथ्रू helm लक्ष्य का नाम देता है:

Terminal window
aggrega import support-assistant.yml --target helm

स्टैंडर्ड आउटपुट पर यह सूची देता है कि इसने क्या लिखा:

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 dify format, with drafted paths relative to <workspace>
warn: node model_config.model (model) names the model "gpt-4o-mini" of the model provider "langgenius/openai/openai", whose credentials are set inside Dify, and core/ai-agent/dify configures that for itself rather than reaching it through a socket, so the draft wires no part for it
made no choice for model_config.model (model)
Pull complete: <workspace>/release.lock (entities=25, source_artifacts=0, external_inputs=0)

एडिटर से चलाया गया इम्पोर्ट: ड्राफ़्ट किए गए Aggregate, Release और Manifest ऐप एक्सपोर्ट के बगल में दिखते हैं, Aggrega आउटपुट सूची देता है कि ड्राफ़्ट क्या वायर करता है और कौन-सी फ़ाइलें लिखी गईं, और एक नोटिफ़िकेशन बताता है कि इम्पोर्ट ने 3 फ़ाइलें ड्राफ़्ट कीं, जिन्हें dify के रूप में पहचाना गया।

  • warn पंक्ति बताती है कि मॉडल Dify के अंदर ही रहता है: Dify अपने मॉडल प्रोवाइडर, और उनकी कुंजियाँ, स्वयं कॉन्फ़िगर करता है, इसलिए ड्राफ़्ट कोई मॉडल वायर नहीं करता। Dify चलने लगे, तो आप उसका OpenAI प्रोवाइडर इंस्टॉल करते हैं और प्रोवाइडर की कुंजी सेट करते हैं, जैसा इसे जाँचें दिखाता है।
  • Pull complete पंक्ति पुल है। हर मान का उत्तर उत्तर फ़ाइल से मिल जाने पर, इम्पोर्ट ने ड्राफ़्ट किए गए Release की निर्भरताएँ पुल कीं, जैसे aggrega pull करता है, और release.lock लिखी; नीचे के बिल्ड को और कुछ नहीं चाहिए।

यह क्या लिखता है

Aggregate, Release और Manifest का नाम imported/support-assistant रखा जाता है, एप्लिकेशन के नाम के अनुसार, जो app के अंतर्गत Support assistant है, जिसे घटाकर support-assistant किया जाता है — बिना नाम वाले एप्लिकेशन का नाम उसकी फ़ाइल के अनुसार रखा जाता है — उस नेमस्पेस के अंतर्गत जिसे इम्पोर्टर की target_namespace सेटिंग निर्धारित करती है, जो imported है जब तक आप कोई दूसरा निर्धारित न करें (सेटिंग्स)।

aggregate.yaml — स्टैंडर्ड लाइब्रेरी का Dify इंस्टॉलेशन, core/dify, एक Aggregate जिसे ड्राफ़्ट aggregates के अंतर्गत संयोजित करता है, जिसमें एप्लिकेशन उसके app_definition पैरामीटर में जैसा लिखा है वैसा ही ले जाया गया है, जिसका अधिकांश भाग यहाँ छोड़ दिया गया है, और इंस्टॉलेशन का secret_key उस पैरामीटर से नीचे पास किया गया है जिसे ड्राफ़्ट घोषित करता है:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: imported/support-assistant
version: 0.1.0
description: Draft Aggregate imported from a source in the dify format.
spec:
parameters:
secret_key:
type: string
required: true
minLength: 1
description: "Passed down to core/dify's secret_key parameter, which has no default; that parameter's description in core/dify says what the value is."
aggregates:
# An import sees the Components of the workspace's catalog and none of its Aggregates, so it does not check that the catalog holds core/dify.
dify:
type: core/dify
parameters:
secret_key: "{{ .parameters.secret_key }}"
app_definition: |
app:
description: Answers questions about the support plans of a small software company.
[… omitted: the rest of the application, as exported]
version: 0.7.0

इंस्टॉलेशन दस घटकों से बना है — Dify का API सर्वर, उसका वर्कर, उसका शेड्यूलर, उसका वेब फ़्रंटएंड, उसका कोड सैंडबॉक्स, उसका प्लगइन रनटाइम, एक इग्रेस प्रॉक्सी, PostgreSQL, एक Redis-संगत कैश और Weaviate — जो एक-दूसरे से वायर किए गए हैं, और एप्लिकेशन का इम्पोर्ट एक चरण है जिसे उसके API सर्वर का Recipe रेंडर करता है। उसके एप्लिकेशन सीक्रेट का core/dify में कोई डिफ़ॉल्ट नहीं है, इसलिए ड्राफ़्ट secret_key को अपने स्वयं के पैरामीटर के रूप में, बिना डिफ़ॉल्ट के, घोषित करता है, और उसे नीचे पास करता है ताकि Release उसे पूरा करे। इंस्टॉलेशन के अन्य क्रेडेंशियल वे डिफ़ॉल्ट बनाए रखते हैं जो core/dify उन्हें देता है, जैसा इसे चलाएं बताता है।

release.yaml — Release, जो इंस्टॉलेशन को एक बाउंड्री, platform, में रूट करता है, और जो एप्लिकेशन प्रदान नहीं कर सकता उसे उत्तर फ़ाइल से पूरा करता है:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: imported/support-assistant
# 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 dify format.
spec:
aggregate: imported/support-assistant
manifest: imported/support-assistant
parameters:
# Left for the Release, since the source cannot supply it: secret_key, which the drafted Aggregate declares and passes down to core/dify; that parameter's description there says what the value is
secret_key: "dify-credentials"
boundaries:
platform:
aggregates:
dify:
components:
api:
infra:
# Lets the installation reach Dify's plugin marketplace, which the plugin serving the application's model, such as OpenAI's, is installed from.
marketplace_enabled: true
# Left for the Release, since the source cannot supply it: components.api.infra.owner_email, the email of the installation's owner account the application is imported under, on the api component of core/dify
owner_email: "owner@example.com"
features:
owner_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 owner account's password.
origin: "dify-owner"
worker:
infra:
# Lets the installation reach Dify's plugin marketplace, which the plugin serving the application's model, such as OpenAI's, is installed from.
marketplace_enabled: true
scheduler:
infra:
# Lets the installation reach Dify's plugin marketplace, which the plugin serving the application's model, such as OpenAI's, is installed from.
marketplace_enabled: true
  • environment development है, एक डिफ़ॉल्ट जिसे, उसके ऊपर की टिप्पणी के अनुसार, उस एनवायरनमेंट में बदलना है जिसमें Release डिप्लॉय होता है।
  • secret_key उस Secret का नाम है जो एप्लिकेशन सीक्रेट रखता है, dify-credentials, उस डेटा कुंजी के अंतर्गत जिसका नाम इंस्टॉलेशन देता है, secret-key: Manifest हर क्रेडेंशियल नेमस्पेस में पहले से मौजूद किसी Secret से पढ़ता है।
  • ओनर खाता इंस्टॉलेशन के api घटक पर सेट किया जाता है, उस रूटिंग प्रविष्टि में जो इंस्टॉलेशन को उसकी बाउंड्री में रखती है: उसका ईमेल, और उसका पासवर्ड, जो एक core/referenced-secret के रूप में अटैच है जो उसे रखने वाले Secret, dify-owner, का नाम डेटा कुंजी value के अंतर्गत देता है। उत्तरित मानों के ऊपर की टिप्पणियाँ बताती हैं कि इम्पोर्ट उन्हें ड्राफ़्ट क्यों नहीं कर सका।
  • marketplace_enabled API सर्वर, api, उसके वर्कर और उसके शेड्यूलर पर, हर लक्ष्य पर, true है: इंस्टॉलेशन Dify के वेंडर की किसी भी चीज़ तक तब तक नहीं पहुँचता जब तक Release उसकी अनुमति न दे, और जिस OpenAI प्रोवाइडर से एप्लिकेशन उत्तर देता है वह एक प्लगइन है जिसे Dify अपने प्लगइन मार्केटप्लेस से इंस्टॉल करता है, जैसा इसे जाँचें दिखाता है। तीनों में से हर एक अपनी स्वयं की सेटिंग पढ़ता है।

manifest.yaml — इंस्टॉलेशन द्वारा संयोजित हर घटक के लिए एक Helm Recipe, और वह रियलाइज़ेशन जो नेमस्पेस में पहले से मौजूद किसी Secret से क्रेडेंशियल पढ़ता है:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/support-assistant
version: 0.1.0
spec:
mappings:
components:
type:
core/datastore/postgres: helm/postgres
core/datastore/redis: helm/redis
core/datastore/weaviate: helm/weaviate
core/ai-agent/dify-ssrf-proxy: helm/dify-ssrf-proxy
core/ai-agent/dify-sandbox: helm/dify-sandbox
core/ai-agent/dify-plugin-daemon: helm/dify-plugin-daemon
core/ai-agent/dify: helm/dify
core/ai-agent/dify-worker: helm/dify-worker
core/ai-agent/dify-worker-beat: helm/dify-worker-beat
core/ai-agent/dify-web: helm/dify-web
features:
type:
core/referenced-secret: helm/k8s-existing-secret

--target ड्राफ़्ट द्वारा संयोजित इंस्टॉलेशन के घटक प्रकारों को भी उसी तरह मैप करता है जैसे अपने घटक प्रकारों को। जहाँ कैटलॉग एक प्रकार के लिए कई Helm Recipes पेश करता है, जैसा वह PostgreSQL के लिए करता है, वहाँ यह उस Recipe को मैप करता है जिसका नाम प्रकार के अनुसार है, helm/postgres।

.aggrega-import.json इस बात का रिकॉर्ड है कि इम्पोर्ट ने क्या लिखा, जिसे बाद में कोई aggrega import --sync पढ़ता है, और release.lock हर उस कैटलॉग एंटिटी को, संस्करण और डाइजेस्ट के साथ, पिन करती है जिस पर Release रिज़ॉल्व होता है।

वैलिडेट और बिल्ड करें

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

वैलिडेट करने के बाद एडिटर में खुला ड्राफ़्ट किया गया Release, जिसमें Aggrega आउटपुट और एक नोटिफ़िकेशन दोनों बताते हैं कि कोई समस्या नहीं मिली।

ड्राफ़्ट किए गए Release का बिल्ड: Explorer में एक dist फ़ोल्डर दिखता है, Aggrega आउटपुट Dify इंस्टॉलेशन के Kubernetes मैनिफ़ेस्ट की सूची देता है, और एक नोटिफ़िकेशन बताता है कि 24 फ़ाइलें लिखी गईं।

वैलिडेशन प्रिंट करता है:

notice: LINT: Feature "core/referenced-secret" at core/referenced-secret: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> उस फ़ोल्डर के स्थान पर है जिसमें ड्राफ़्ट हैं:

notice: LINT: Feature "core/referenced-secret" at core/referenced-secret: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: 24 files written to <workspace>/dist

notice पंक्ति सलाहकारी है: सीक्रेट Feature अपना origin Aggregate के values से या Release के infra से स्वीकार करता है, और नोटिस बताता है कि एक लीफ़ दोनों में घोषित है। यह कोई निर्णय नहीं बदलती।

बिल्ड इंस्टॉलेशन के Kubernetes मैनिफ़ेस्ट dist/boundaries/platform/helm/ के अंतर्गत लिखता है। उनमें वह Job है जो एप्लिकेशन को इम्पोर्ट करता है, dify.api/dify-app-import.job.yaml। यह Dify के API सर्वर के उत्तर देने की प्रतीक्षा करता है, जहाँ Dify का पहली बार का सेटअप नहीं चला है वहाँ उसे उस ओनर खाते के रूप में करता है जिसका नाम Release देता है, और एप्लिकेशन को इम्पोर्ट करता है:

spec:
podFailurePolicy:
rules:
- action: FailJob
onExitCodes:
containerName: import
operator: In
values: [2]
template:
spec:
restartPolicy: Never
containers:
- name: import
image: "langgenius/dify-api:1.17.0"
command: ["python", "/seed/import.py"]
env:
- name: DIFY_API_URL
value: "http://dify-zdapi-default:5001"
- name: OWNER_EMAIL
value: "owner@example.com"
- name: OWNER_PASSWORD
valueFrom:
secretKeyRef:
name: "dify-owner"
key: "value"
volumeMounts:
- name: seed
mountPath: /seed
readOnly: true
volumes:
- name: seed
configMap:
name: dify-zdapi-app

एप्लिकेशन स्वयं उसके बगल वाले ConfigMap में है। जब Dify उसे अस्वीकार करता है जो चरण उसे भेजता है, अनुरोध टाइमआउट या रेट लिमिट के अलावा किसी क्लाइंट-एरर जवाब के साथ, या यह रिपोर्ट करके कि इम्पोर्ट विफल हुआ, तो चरण वह संदेश प्रिंट करता है जो Dify का जवाब रखता है और स्टेटस 2 के साथ बाहर निकलता है, जैसा वह तब करता है जब परिभाषा app.name के अंतर्गत किसी एप्लिकेशन का नाम नहीं देती; Job की podFailurePolicy उसी प्रयास पर Job को विफल कर देती है, क्योंकि पुनः प्रयास भी उसी तरह अस्वीकार होगा; कोई भी अन्य विफलता, जैसे सर्वर का लगभग दस मिनट के भीतर उत्तर न देना, फिर से आज़माई जाती है।

AI असिस्टेंट के साथ

Aggrega के टूल के साथ सेट अप किया गया AI असिस्टेंट भी यही कर सकता है: यह प्रॉम्प्ट उसमें पेस्ट करें।

केवल Aggrega टूल का उपयोग करें, और स्वयं कोई फ़ोल्डर न बनाएं। यदि Workspace फ़ोल्डर में अभी कोई `import-dify` फ़ोल्डर नहीं है, तो `draft` टूल को एक बार कॉल करें, `example` को `import-dify` पर सेट करके और बिना `dir` के: यह उदाहरण को एक नए `import-dify` फ़ोल्डर में लिखता है, जिसके `source` फ़ोल्डर में वह है जिसे यह पेज इम्पोर्ट करता है। फिर `import` टूल को कॉल करें, `workspace_root` को `import-dify/source` पर, `source` को `support-assistant.yml` पर और `target` को `helm` पर सेट करके: यह जिन उत्तरों की आवश्यकता है उन्हें `support-assistant.yml` के बगल में `import-answers.yaml` से पढ़ता है, अपने ड्राफ़्ट `import-dify/source` में लिखता है और जो उन्हें चाहिए उसे पुल करता है। फिर `validate` टूल को कॉल करें, `workspace_root` को `import-dify/source` पर और `release` को `release.yaml` पर सेट करके, और `build` टूल को, `workspace_root` को `import-dify/source` पर, `release` को `release.yaml` पर और `write` को true पर सेट करके। मुझे बताएं कि बिल्ड ने कौन-सी फ़ाइलें लिखीं; वे `import-dify/source/dist/` के अंतर्गत हैं।

इसे VS Code में खोलें

Visual Studio Code के लिए Aggrega एक्सटेंशन इंस्टॉल होने पर, VS Code में फ़ोल्डर import-dify/source खोलें, जहाँ इम्पोर्ट ने अपने ड्राफ़्ट लिखे। फ़ोल्डर में एक Release है, ड्राफ़्ट किया गया release.yaml, इसलिए एडिटर उसे आपके लिए चुन लेता है; जब Docker Compose पर compose में एक दूसरा Release ड्राफ़्ट कर चुका हो, तो Aggrega: Select Release… वह Release चुनता है जिस पर एडिटर काम करता है। जब आप ड्राफ़्ट संपादित करते हैं तो एडिटर उन्हें चयनित Release के विरुद्ध जाँचता है, और जो कुछ उसे मिलता है उसे फ़ाइल में और Problems पैनल में चिह्नित करता है। कमांड पैलेट में Aggrega: Show topology graph चयनित Release के घटकों और उनके बीच के कनेक्शनों को बनाता है। Aggrega: Build, Aggrega: Preview build और Aggrega: Pull उसी Release पर काम करते हैं, और हर एक एक्टिविटी बार में Aggrega व्यू के Commands पैनल पर एक बटन भी है; Build अपनी फ़ाइलें फ़ोल्डर के dist/ में लिखता है। बाकी सब Visual Studio Code में Aggrega का उपयोग करें में है।

इसे चलाएं

मैनिफ़ेस्ट लागू करने से पहले, वे Secrets बनाएं जिन्हें वे पढ़ते हैं। जो वर्कलोड किसी ऐसे Secret का नाम देता है जो मौजूद नहीं है, वह शुरू नहीं होता। दो Secrets वह रखते हैं जिसका नाम उत्तर फ़ाइल ने दिया: dify-owner, जो ओनर का पासवर्ड value के अंतर्गत रखता है, और dify-credentials, जो एप्लिकेशन सीक्रेट secret-key के अंतर्गत रखता है। इंस्टॉलेशन के चार अन्य क्रेडेंशियल — उसका डेटाबेस पासवर्ड और तीन कुंजियाँ जिन्हें उसके घटक एक-दूसरे को प्रस्तुत करते हैं — वे डिफ़ॉल्ट बनाए रखते हैं जो core/dify उन्हें देता है, और Kubernetes पर हर डिफ़ॉल्ट उस Secret का नाम है जिससे मैनिफ़ेस्ट उसे पढ़ते हैं: db-password के अंतर्गत dify-db-password-for-evaluation-only, code-execution-key के अंतर्गत dify-code-execution-key-for-evaluation-only, plugin-daemon-key के अंतर्गत dify-plugin-daemon-key-for-evaluation-only, और inner-api-key के अंतर्गत dify-inner-api-key-for-evaluation-only। इन चारों को भी बनाएं, हर एक में अपना स्वयं का मान रखकर; उन्हें दूसरे नाम वाले Secrets से पढ़ने के लिए, Aggregate की dify प्रविष्टि में, parameters के अंतर्गत, नाम core/dify को db_password, code_execution_key, plugin_daemon_key और inner_api_key के रूप में पास करें।

ओनर का पासवर्ड अपने शेल में DIFY_OWNER_PASSWORD के रूप में सेट करें, क्योंकि नीचे आप उसी से साइन इन करते हैं। Dify कम से कम आठ अक्षरों का ऐसा ओनर पासवर्ड लेता है जिसमें एक अक्षर और एक अंक हो: कोई और पासवर्ड देने पर, जैसे ही Dify सेटअप अस्वीकार करता है, इम्पोर्ट Job विफल हो जाता है, और उसका लॉग first-time setup was refused with HTTP 422: Validation error for parameter 'payload' पढ़ता है, जो वह जवाब है जो Dify किसी अस्वीकृत ओनर खाते को देता है। नीचे का wait Job के पूरा होने की प्रतीक्षा करता है, और एक विफल Job कभी पूरा नहीं होता, इसलिए वह तब अपने टाइमआउट तक चलता है; उसके साथ एक दूसरे टर्मिनल में kubectl wait --for=condition=failed job/dify-zdapi-app-import --timeout=15m चलाएं, और वह wait Job के विफल होते ही लौट आता है। Job और dify-owner Secret को हटाएं, Dify द्वारा स्वीकार्य पासवर्ड के साथ Secret फिर से बनाएं, और फिर से लागू करें।

बाकी पाँच Secrets में से हर एक के लिए एक फ़ाइल लिखें, जिसमें एक पंक्ति हो: डेटा कुंजी, =, और आपका अपना एक मान — secret-key= के साथ dify-credentials.env, db-password= के साथ db-password.env, code-execution-key= के साथ code-execution-key.env, plugin-daemon-key= के साथ plugin-daemon-key.env और inner-api-key= के साथ inner-api-key.env। फिर छहों Secrets बनाएं। तब मान क्लस्टर में होते हैं, इसलिए फ़ाइलें हटा दें:

Terminal window
printf 'value=%s\n' "$DIFY_OWNER_PASSWORD" > dify-owner.env
kubectl create secret generic dify-owner --from-env-file=dify-owner.env
kubectl create secret generic dify-credentials --from-env-file=dify-credentials.env
kubectl create secret generic dify-db-password-for-evaluation-only --from-env-file=db-password.env
kubectl create secret generic dify-code-execution-key-for-evaluation-only --from-env-file=code-execution-key.env
kubectl create secret generic dify-plugin-daemon-key-for-evaluation-only --from-env-file=plugin-daemon-key.env
kubectl create secret generic dify-inner-api-key-for-evaluation-only --from-env-file=inner-api-key.env
rm dify-owner.env dify-credentials.env db-password.env code-execution-key.env plugin-daemon-key.env inner-api-key.env

मैनिफ़ेस्ट लागू करें, जैसा इम्पोर्ट कैसे चलता है का रन चरण बताता है — -R dify.api/ और dify.proxy/ में मौजूद Job और दो ConfigMaps तक पहुँचता है — फिर इम्पोर्ट Job की प्रतीक्षा करें और उसका लॉग पढ़ें, और प्लगइन रनटाइम की प्रतीक्षा करें:

Terminal window
kubectl apply -R -f dist/boundaries/platform/helm/
kubectl wait --for=condition=complete job/dify-zdapi-app-import --timeout=15m
kubectl logs job/dify-zdapi-app-import
kubectl rollout status statefulset/dify-zdplugins
service/dify-zdapi-default created
deployment.apps/dify-zdapi created
[… omitted: a line for each of the other Services, Deployments and StatefulSets]
job.batch/dify-zdapi-app-import created
configmap/dify-zdapi-app created
configmap/dify-zdproxy-config created
job.batch/dify-zdapi-app-import condition met
first-time setup done: owner account owner@example.com
imported 'Support assistant' as application 7e03e85c-b13f-4ddc-b539-040470a61d4c
partitioned roll out complete: 1 new pods have been updated...

लॉग एप्लिकेशन के पहचानकर्ता का नाम देता है, जिसकी इसे जाँचें को आवश्यकता है।

इसे जाँचें

Dify का API http://127.0.0.1:5001 पर उत्तर देता है। Kubernetes पर, जिस नेमस्पेस में आपने लागू किया उसमें API सर्वर की Service, dify-zdapi-default, पर एक लोकल पोर्ट फ़ॉरवर्ड करें, और कमांड को एक दूसरे टर्मिनल में चलता छोड़ दें:

Terminal window
kubectl port-forward -n <namespace> svc/dify-zdapi-default 5001:5001

Docker Compose पर, जैसा Docker Compose पर दिखाता है वैसे शुरू करने पर, Release API को पहले से उसी पते पर प्रकाशित करता है, और कंसोल को http://127.0.0.1:3001 पर। http://127.0.0.1:3001/signin खोलें, कंसोल का साइन-इन पेज; / वहीं रीडायरेक्ट करता है। पेज अपने अनुरोध http://127.0.0.1:5001 पर API को भेजता है, और Dify का API किसी ब्राउज़र को केवल उन पेजों के लिए उत्तर देता है जो उस पते से परोसे जाते हैं जिसका नाम ड्राफ़्ट किया गया console_url देता है, http://127.0.0.1:3001, इसलिए वहीं ओनर के रूप में साइन इन करें। किसी अन्य पते पर खोलने पर, कंसोल के अनुरोधों को ऐसा कोई उत्तर नहीं मिलता और ब्राउज़र हर जवाब को अस्वीकार कर देता है; कंसोल को किसी दूसरे पोर्ट पर प्रकाशित करें तो उसके साथ console_url भी बदलें।

एप्लिकेशन API के माध्यम से भी, बिना किसी ब्राउज़र के, उत्तर देता है। ऐसे टर्मिनल में जहाँ DIFY_OWNER_PASSWORD सेट है, ओनर के रूप में साइन इन करें। कंसोल API पासवर्ड को Base64-एन्कोड करके लेता है, और साइन इन करने से सेशन cookies.txt में रह जाता है। बाद का हर कंसोल अनुरोध सेशन को वापस भेजता है, उसी फ़ाइल के CSRF टोकन के साथ एक X-CSRF-Token हेडर में; इसके बिना अनुरोध CSRF token is missing or invalid. के साथ अस्वीकार होता है।

Terminal window
printf '{"email": "owner@example.com", "password": "%s"}' "$(printf %s "$DIFY_OWNER_PASSWORD" | base64 | tr -d '\n')" |
curl -sS -c cookies.txt http://127.0.0.1:5001/console/api/login -H 'Content-Type: application/json' -d @-
CSRF=$(awk '$6 == "csrf_token" {print $7}' cookies.txt)
{"result":"success"}

Dify के मॉडल प्रोवाइडर प्लगइन हैं, और नए इंस्टॉलेशन में कोई नहीं होता। Dify का OpenAI प्रोवाइडर इंस्टॉल करें, संस्करण 1.1.0 पर, वही जिसे रन ने इंस्टॉल किया; प्लगइन रनटाइम उसे Dify के मार्केटप्लेस से लाता है, जिस तक ड्राफ़्ट किया गया marketplace_enabled इंस्टॉलेशन को पहुँचने देता है, इसलिए इंस्टॉलेशन का इंटरनेट तक पहुँचना आवश्यक है:

Terminal window
curl -sS -b cookies.txt -H "X-CSRF-Token: $CSRF" -H 'Content-Type: application/json' \
http://127.0.0.1:5001/console/api/workspaces/current/plugin/install/marketplace \
-d '{"plugin_unique_identifiers": ["langgenius/openai:1.1.0@1ded02acee56efd5788c86fd447d792e4923e959554a4942f440c7859d164340"]}'
{"all_installed":false,"task_id":"01a1dc0a-653d-756b-a104-e5d6d1e43695","task":null}

Release से marketplace_enabled हटा देने पर, Dify इसके बजाय अनुरोध को {"code":"invalid_param","message":"marketplace is not enabled","status":400} के साथ अस्वीकार करता है। इंस्टॉलेशन बैकग्राउंड में चलता है। जवाब जिस task_id का नाम देता है उसके साथ उसका टास्क पूछते रहें, जब तक उसका status success न हो:

Terminal window
curl -sS -b cookies.txt -H "X-CSRF-Token: $CSRF" \
http://127.0.0.1:5001/console/api/workspaces/current/plugin/tasks/<task id>
{"task":{"id":"01a1dc0a-653d-756b-a104-e5d6d1e43695",[… omitted: when it was created and last updated],"status":"success","total_plugins":1,"completed_plugins":1,"plugins":[{"plugin_unique_identifier":"langgenius\/openai:1.1.0@1ded02acee56efd5788c86fd447d792e4923e959554a4942f440c7859d164340",[… omitted: the plugin's status, its icon and its names in four languages]}]}}

प्रोवाइडर की कुंजी openai.json में {"credentials": {"openai_api_key": "your OpenAI key"}} के रूप में लिखें, उसे सेट करें, और फ़ाइल हटा दें:

Terminal window
curl -sS -b cookies.txt -H "X-CSRF-Token: $CSRF" -H 'Content-Type: application/json' \
http://127.0.0.1:5001/console/api/workspaces/current/model-providers/langgenius/openai/openai/credentials \
-d @openai.json
rm openai.json

Dify कुंजी को रखने से पहले प्रोवाइडर को एक अनुरोध भेजकर उसकी जाँच करता है, और प्रोवाइडर द्वारा स्वीकार की गई कुंजी के लिए {"result":"success"} उत्तर देता है। रन ने एक प्लेसहोल्डर सेट किया, और Dify ने उसे OpenAI के उत्तर के साथ अस्वीकार कर दिया:

{"code":"invalid_param","message":"Error 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}","status":400}

कोई एप्लिकेशन उसकी अपनी API कुंजी के साथ किए गए अनुरोधों का उत्तर देता है। एक कुंजी बनाएं, उस चरण के लॉग से एप्लिकेशन के पहचानकर्ता के साथ जो उसे इम्पोर्ट करता है — Docker Compose पर, docker compose -p support-assistant -f ../dist/boundaries/platform/compose/docker-compose.yaml logs dify-zdapi-app-import:

Terminal window
curl -sS -X POST -b cookies.txt -H "X-CSRF-Token: $CSRF" \
http://127.0.0.1:5001/console/api/apps/<application id>/api-keys
{"id":"8d6c1eb1-cf61-4825-9b04-f32689ed0489","type":"app","token":"[… omitted: the key]","last_used_at":null,"created_at":1794693042}

और कुंजी, यानी जवाब के token, के साथ एप्लिकेशन को एक संदेश भेजें:

Terminal window
curl -sS http://127.0.0.1:5001/v1/chat-messages \
-H 'Authorization: Bearer <app key>' -H 'Content-Type: application/json' \
-d '{"inputs": {}, "query": "In one short sentence: what does a support plan cover?", "response_mode": "blocking", "user": "test-it"}'

प्लेसहोल्डर अस्वीकार होने पर मॉडल के पास कोई कुंजी नहीं होती, और Dify यही बताता है:

{"code":"provider_not_initialize","message":"Model gpt-4o-mini credentials is not initialized.","status":400}

Kubernetes पर और Docker Compose पर चले रनों को एक जैसे जवाब मिले। प्रोवाइडर द्वारा स्वीकार की गई कुंजी के साथ, जवाब answer पर मॉडल का उत्तर रखता है।

Kubernetes पर, पोर्ट फ़ॉरवर्ड रोकें, फिर जो आपने लागू किया उसे, Secrets को और सेशन फ़ाइल को हटा दें:

Terminal window
kubectl delete -R -f dist/boundaries/platform/helm/
kubectl delete secret dify-owner dify-credentials dify-db-password-for-evaluation-only dify-code-execution-key-for-evaluation-only dify-plugin-daemon-key-for-evaluation-only dify-inner-api-key-for-evaluation-only
kubectl delete pvc data-dify-zddb-0 storage-dify-zdplugins-0 data-dify-zdvector-0
rm cookies.txt

जब कोई StatefulSet हटाया जाता है, तो Kubernetes उसके द्वारा बनाए गए वॉल्यूम क्लेम बनाए रखता है, इसलिए तीसरा कमांड उन्हें हटाता है, और उनके साथ डेटाबेस, इंस्टॉल किया गया प्लगइन और वेक्टर स्टोर भी। Docker Compose पर, docker compose -p support-assistant -f ../dist/boundaries/platform/compose/docker-compose.yaml down -v स्टैक और उसके वॉल्यूम हटाता है।

Docker Compose पर

वही एप्लिकेशन compose लक्ष्य के साथ, उसी उत्तर फ़ाइल से, Docker Compose के लिए इम्पोर्ट होता है। Kubernetes के लिए ड्राफ़्ट पहले से source में हैं, इसलिए Compose वाले ड्राफ़्ट --output-dir के साथ एक अलग फ़ोल्डर में ड्राफ़्ट करें; इम्पोर्ट फिर भी एप्लिकेशन के बगल वाली उत्तर फ़ाइल ही पढ़ता है:

Terminal window
aggrega import support-assistant.yml --target compose --output-dir compose

Docker Compose में नाम देने के लिए कोई Secret नहीं है, इसलिए compose के लिए ड्राफ़्ट एप्लिकेशन सीक्रेट और ओनर का पासवर्ड स्वयं लिखता है, हर एक को एक वेरिएबल संदर्भ के रूप में जिसे Docker Compose उस व्यक्ति के एनवायरनमेंट से भरता है जो स्टैक शुरू करता है। वहाँ केवल ओनर का ईमेल बकाया है। इम्पोर्ट दोनों Secret नाम उत्तर फ़ाइल में रखता है, उन्हें लागू किए बिना, और स्टैंडर्ड एरर पर यह बताता है:

info: the answers file <workspace>/import-answers.yaml also answers spec.boundaries.platform.aggregates.dify.components.api.features.owner_password.infra.origin in release.yaml, spec.parameters.secret_key in release.yaml, which these drafts do not leave empty; those answers are kept there and not applied

ड्राफ़्ट किया गया Release एप्लिकेशन सीक्रेट DIFY_SECRET_KEY से और ओनर का पासवर्ड DIFY_OWNER_PASSWORD से पढ़ता है, और API को लूपबैक पते के पोर्ट 5001 पर और फ़्रंटएंड, console, को 3001 पर प्रकाशित करता है:

parameters:
# Passed by reference, never as a value: secret_key, which the drafted Aggregate declares and passes down to core/dify; that parameter's description there says what the value is; it is read from the variable DIFY_SECRET_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.
secret_key: "${DIFY_SECRET_KEY}"
[… omitted: the boundary, the marketplace switch, and the owner's email, answered as above]
# 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: 5001
console_url: "http://127.0.0.1:3001"
features:
owner_password:
type: core/referenced-secret
infra:
# Attached by reference, never as a value: the owner account's password, read from the variable DIFY_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: "${DIFY_OWNER_PASSWORD}"
[… omitted: the worker and the scheduler, each with the marketplace switch, as above]
console:
infra:
# 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: 3001

हर पोर्ट केवल आपकी मशीन से पहुँच योग्य है, जैसा उसकी टिप्पणी कहती है, और कोई पंक्ति हटाने पर वह सेवा केवल स्टैक के नेटवर्क पर रहती है। फ़्रंटएंड अपने कंटेनर के अंदर 3000 पर सुनता है और 3001 पर प्रकाशित होता है, ताकि वह 3000 प्रकाशित करने वाले किसी दूसरे उदाहरण के बगल में चल सके। API सर्वर का console_url वह पता है जिस पर फ़्रंटएंड प्रकाशित होता है, इसलिए फ़्रंटएंड के लिए आप जो पोर्ट बदलते हैं वह वहाँ भी बदला जाता है।

Manifest हर घटक को उसके Compose Recipe पर और core/referenced-secret को compose/dotenv-referenced-secret पर मैप करता है, जो हर संदर्भ को Compose फ़ाइल में जैसा है वैसा ही लिखता है। नए फ़ोल्डर से वैलिडेट और बिल्ड करें:

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

बिल्ड वर्कस्पेस रूट पर dist के अंतर्गत लिखता है, और वर्कस्पेस अब भी source है, यानी .aggrega-config.yaml रखने वाला फ़ोल्डर: Compose फ़ाइल source/dist/boundaries/platform/compose/docker-compose.yaml है, जो compose से ../dist/boundaries/platform/compose/docker-compose.yaml है, और compose के अंदर कोई dist फ़ोल्डर नहीं लिखा जाता। फ़ाइल दोनों में से किसी मान के बजाय SECRET_KEY: ${DIFY_SECRET_KEY} और OWNER_PASSWORD: ${DIFY_OWNER_PASSWORD} रखती है। स्टैक शुरू करने से पहले दोनों वेरिएबल अपने शेल में, या Compose फ़ाइल के बगल में एक .env फ़ाइल में, सेट करें।

इंस्टॉलेशन के चार अन्य क्रेडेंशियल वे डिफ़ॉल्ट बनाए रखते हैं जो core/dify उन्हें देता है, और Docker Compose पर हर डिफ़ॉल्ट स्वयं मान है, जो Compose फ़ाइल में जैसा है वैसा ही लिखा जाता है: DB_PASSWORD: dify-db-password-for-evaluation-only, डेटाबेस पर POSTGRES_PASSWORD भी वही, और इसी तरह dify-code-execution-key-for-evaluation-only, dify-plugin-daemon-key-for-evaluation-only और dify-inner-api-key-for-evaluation-only। कैटलॉग के हर पाठक के पास ये डिफ़ॉल्ट हैं, इसलिए ये केवल मूल्यांकन के लिए हैं। किसी एक को बदलने के लिए, ड्राफ़्ट किए गए Aggregate में उसके लिए एक स्ट्रिंग पैरामीटर घोषित करें, उसे dify प्रविष्टि के parameters में core/dify द्वारा उसके लिए दिए गए नाम के अंतर्गत नीचे पास करें — db_password, code_execution_key, plugin_daemon_key या inner_api_key — जैसे ड्राफ़्ट secret_key को पास करता है, और उसे Release के parameters के अंतर्गत पूरा करें। db_password: "${DIFY_DB_PASSWORD}" लिखने वाला Release ऐसी Compose फ़ाइल बिल्ड करता है जो DB_PASSWORD: ${DIFY_DB_PASSWORD} और POSTGRES_PASSWORD: ${DIFY_DB_PASSWORD} रखती है, जो ऊपर के दो वेरिएबल की तरह एनवायरनमेंट से भरे जाते हैं।

स्टैक compose से शुरू करें, ऐसे ओनर पासवर्ड के साथ जिसे Dify स्वीकार करता है, जैसा इसे चलाएं बताता है:

Terminal window
export DIFY_SECRET_KEY='a long random value of your own'
export DIFY_OWNER_PASSWORD='a password of your own'
docker compose -p support-assistant -f ../dist/boundaries/platform/compose/docker-compose.yaml up -d --wait

रन में --wait लगभग एक मिनट में लौट आया, जब हर सर्वर ने स्वस्थ होने की सूचना दी। एप्लिकेशन को इम्पोर्ट करने वाला चरण उनके साथ चलता है और इम्पोर्ट कर लेने पर बाहर निकल जाता है; तब उसका लॉग यह पढ़ता है:

first-time setup done: owner account owner@example.com
imported 'Support assistant' as application 7fae73f4-826b-4918-a623-a3383aa0da8c

इसे जाँचें दोनों प्रकाशित पोर्ट पर इंस्टॉलेशन तक पहुँचता है।