CrewAI प्रोजेक्ट इम्पोर्ट करें
यह वॉकथ्रू एक CrewAI प्रोजेक्ट के एजेंट और टास्क की घोषणाएँ इम्पोर्ट करता है — दो एजेंटों का एक crew, जो सपोर्ट प्लान के बारे में किसी ग्राहक के प्रश्न का उत्तर देता है — और crew को Docker Compose के लिए बिल्ड करता है। इम्पोर्ट हर वह फ़ाइल ड्राफ़्ट करता है जिसे बिल्ड पढ़ता है: दोनों एजेंट और उनका मॉडल, वह कुंजी जो हर एजेंट मॉडल को एक वेरिएबल संदर्भ के रूप में प्रस्तुत करता है, और हर एक के रियलाइज़ेशन। यह उस एक मान के लिए एक बार पूछता है जो कोई घोषणा नहीं रखती, यानी वह इमेज जिसमें crew का प्रोग्राम चलता है। नीचे की हर फ़ाइल और आउटपुट का हर ब्लॉक एक वास्तविक रन से आता है; घोषणाएँ और वॉकथ्रू का हर चरण import-crewai उदाहरण में है, जहाँ एक चेक स्क्रिप्ट इम्पोर्ट को फिर से चलाती है, वह जो लिखता है, जो प्रिंट करता है और यह पेज जिन ब्लॉकों को उद्धृत करता है, उनकी तुलना वहाँ रखी फ़ाइलों से करती है, और इम्पोर्ट द्वारा लिखी गई चीज़ों को वैलिडेट और बिल्ड करती है।
उदाहरण ड्राफ़्ट करें
आप यह इम्पोर्ट इस पेज के कमांडों से चला सकते हैं, या इसे अपने AI असिस्टेंट से चलवा सकते हैं।
उदाहरण को उसी के नाम वाले एक नए फ़ोल्डर में लिखें:
aggrega draft --example import-crewaiफिर यह आगे चलाने के लिए कमांड प्रिंट करता है। पहला कमांड नए फ़ोल्डर में ले जाता है; उसके बाद वाला, नीचे दिया गया, उसके source फ़ोल्डर में ले जाता है, जिसमें वह है जिसे यह पेज इम्पोर्ट करता है और जहाँ इम्पोर्ट चलता है:
cd import-crewai
प्रोजेक्ट
CrewAI प्रोजेक्ट अपने crew का व्यवहार एक प्रोग्राम में रखता है और अपने एजेंट और अपने टास्क कॉन्फ़िगरेशन फ़ाइलों में घोषित करता है। यह प्रोजेक्ट, जो इस वॉकथ्रू के लिए लिखा गया है, CrewAI के क्लासिक लेआउट में है, और इम्पोर्ट उसकी दो घोषणा फ़ाइलें पढ़ता है, जो src/support_brief/config/ के अंतर्गत हैं। प्रोग्राम — क्लासिक प्रोजेक्ट की crew.py, और वे टूल जिन्हें वह परिभाषित करता है — कभी नहीं पढ़ा जाता, इसलिए उदाहरण में केवल घोषणाएँ हैं।
agents.yaml दोनों एजेंटों को घोषित करती है, दोनों OpenAI के gpt-4o-mini पर:
researcher: role: > Support plan researcher goal: > Find what each support plan of the company covers, and what it costs backstory: > You keep the company's support plans at your fingertips and answer from them alone. llm: openai/gpt-4o-mini verbose: true
writer: role: > Support reply writer goal: > Turn the researcher's findings into a short, friendly reply to the customer backstory: > You write replies customers can act on, in plain words. llm: openai/gpt-4o-minitasks.yaml हर एक को एक टास्क सौंपती है:
research_task: description: > Find the support plans that answer the customer's question: {question} expected_output: > The plans that apply, each with what it covers and what it costs agent: researcher
reply_task: description: > Write a reply to the customer's question from the researcher's findings expected_output: > A reply of at most five sentences agent: writerप्रोजेक्ट के रूट पर एक .aggrega-config.yaml फ़ोल्डर को वर्कस्पेस बनाती है:
# The workspace key marks this directory as the workspace root, so an import run# here writes its drafts beside src/.workspace: {}# The registry the importer is fetched from the first time an import needs it.default_registry: hub.aggrega.aiइम्पोर्ट कैटलॉग के एजेंट और मॉडल Components का संदर्भ देता है, और --target उसके Recipes से एक Manifest ड्राफ़्ट करता है। वर्कस्पेस किसी कैटलॉग फ़ोल्डर का नाम नहीं देता, इसलिए इम्पोर्ट स्टैंडर्ड लाइब्रेरी का कैटलॉग उसी रजिस्ट्री से पढ़ता है जिससे वह अपना इम्पोर्टर लाता है: प्रकाशित कैटलॉग का एक हस्ताक्षरित स्नैपशॉट, जिसे पहला इम्पोर्ट लाता है, सत्यापित करता है और वर्कस्पेस के कंटेंट कैश में रखता है, और जिसका नाम उसके डाइजेस्ट से उस रिकॉर्ड में दिया जाता है जिसे इम्पोर्ट अपने ड्राफ़्ट के बगल में लिखता है। जो वर्कस्पेस अपने स्वयं के कैटलॉग फ़ोल्डरों का नाम देता है — AGGREGA_CATALOG_DIRS में, या workspace.catalog_dirs के अंतर्गत — उन्हें पहले पढ़ता है, उनके पीछे प्रकाशित स्नैपशॉट के साथ।
इम्पोर्ट क्या पूछता है
घोषणाएँ हर एजेंट के मॉडल का नाम देती हैं, उस इमेज का कभी नहीं जिसमें crew का प्रोग्राम चलता है: वह इमेज आप अपने प्रोजेक्ट से बिल्ड करते हैं। इसलिए इम्पोर्ट उसके लिए पूछता है, हर एजेंट के लिए एक बार। किसी टर्मिनल पर यह हर एक के लिए एक प्रश्न पूछता है, और उत्तरों को ड्राफ़्ट में और उत्तर फ़ाइल, import-answers.yaml, में लिखता है, जो उस डायरेक्टरी के अंदर है जिसे यह इम्पोर्ट करता है, src/support_brief/, ताकि अगला इम्पोर्ट उन्हें वहीं से पढ़े और कुछ न पूछे। टर्मिनल के बिना — कंटीन्यूअस इंटीग्रेशन में, या किसी पाइप के माध्यम से — यह कुछ नहीं पूछता: यह फ़ाइल को खाली कुंजियों के साथ लिखता है, और फ़ाइल का नाम बताते हुए रुक जाता है। उदाहरण में यह फ़ाइल पहले से है, जिसमें दोनों एजेंट एक ही इमेज, ghcr.io/example/support-brief:1.0.0, पर हैं, जो उस इमेज के स्थान पर है जिसे आप बिल्ड करते हैं:
# 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: # Container image running the CrewAI application code. spec.components.researcher.infra.image: "ghcr.io/example/support-brief:1.0.0" # 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.researcher.uses.model.gpt-4o-mini.features.credential.infra.origin: "openai-api-key" # Container image running the CrewAI application code. spec.components.writer.infra.image: "ghcr.io/example/support-brief:1.0.0" # 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.writer.uses.model.gpt-4o-mini.features.credential.infra.origin: "openai-api-key"दो origin उत्तर Kubernetes के लिए बिल्ड के हैं, --target helm के साथ: वहाँ हर एजेंट OpenAI कुंजी किसी Kubernetes Secret से पढ़ता है, और उत्तर उस Secret का नाम है, openai-api-key, कभी कुंजी नहीं। Docker Compose के लिए बिल्ड इसके बजाय कुंजी आपके शेल से पढ़ता है, इसलिए यह इम्पोर्ट उन उत्तरों का उपयोग नहीं करता। इम्पोर्ट उत्तर फ़ाइल फ़ाइल, प्रश्नों और किसी सीक्रेट के उत्तर के नियमों का वर्णन करती है।
aggrega import उन सभी फ़्लैग की सूची देता है जिन्हें कमांड लेता है, और उनमें --answers भी है, जो कहीं और रखी गई उत्तर फ़ाइल का नाम देता है।
source में जाएँ:
cd sourceइम्पोर्ट चलाएं
crew की डायरेक्टरी का नाम दें। इम्पोर्ट उसमें मौजूद घोषणाएँ पढ़ता है और कुछ नहीं:
aggrega import src/support_brief --target composeस्टैंडर्ड आउटपुट पर यह सूची देता है कि इसने क्या लिखा:
wrote aggregate.yamlwrote release.yamlwrote manifest.yamlwrote .aggrega-import.jsonस्टैंडर्ड एरर पर, जहाँ <workspace> उस फ़ोल्डर के स्थान पर है जिसमें आपने इसे चलाया:
[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]read as the crewai format, with drafted paths relative to <workspace>info: the answers file <workspace>/src/support_brief/import-answers.yaml also answers spec.components.researcher.uses.model.gpt-4o-mini.features.credential.infra.origin in release.yaml, spec.components.writer.uses.model.gpt-4o-mini.features.credential.infra.origin in release.yaml, which these drafts do not leave empty; those answers are kept there and not appliedmapped researcher (agent) to core/ai-agent/crewai as a reference, NONEmapped openai/gpt-4o-mini (llm) to core/ai-model/openai as a reference, NONEmapped writer (agent) to core/ai-agent/crewai as a reference, NONEmade no choice for research_task (task)made no choice for reply_task (task)Pull complete: <workspace>/release.lock (entities=8, source_artifacts=0, external_inputs=0)
infoपंक्ति उन उत्तरों का नाम देती है जिनका Docker Compose ड्राफ़्ट उपयोग नहीं करते, और जो Kubernetes के लिए बिल्ड हेतु उत्तर फ़ाइल में रखे गए हैं।mappedपंक्तियाँ बताती हैं कि हर एजेंट स्टैंडर्ड लाइब्रेरी के CrewAI एजेंट,core/ai-agent/crewai, का एक इंस्टेंस है, और जिस मॉडल का नाम दोनों देते हैं,openai/gpt-4o-mini, वहcore/ai-model/openaiका एक इंस्टेंस है। उनका स्तरNONEपढ़ता है: CrewAI इम्पोर्ट इन Components का संदर्भ, हर एक को कैटलॉग के सामने तौलने के बजाय, उससे देता है जिसका नाम घोषणाएँ देती हैं, यानी एक एजेंट और एक मॉडल प्रोवाइडर।made no choiceपंक्तियाँ बताती हैं कि टास्क किसी भी रूप में ड्राफ़्ट नहीं किए जाते: टास्क वह लॉजिक है जिसे crew का प्रोग्राम चलाता है।Pull completeपंक्ति इम्पोर्ट द्वारा वह लाना है जिस पर ड्राफ़्ट किया गया Release निर्भर है, जैसेaggrega pullकरता है,release.lockमें, ताकि ड्राफ़्ट तुरंत वैलिडेट और बिल्ड हों।--offlineके अंतर्गत इम्पोर्ट कुछ भी पुल नहीं करता और चलाने के लिएaggrega pullका नाम देता है।
यह क्या लिखता है
Aggregate, Release और Manifest का नाम imported/support-brief रखा जाता है: किसी प्रोजेक्ट की config/agents.yaml और config/tasks.yaml किसी crew का नाम नहीं देतीं — उसका नाम प्रोग्राम में रहता है, जिसे इम्पोर्ट नहीं पढ़ता — इसलिए उनके डायरेक्टरी इम्पोर्ट का नाम डायरेक्टरी के अनुसार, support_brief, नाम खंड के रूप में लिखकर, रखा जाता है, उस नेमस्पेस के अंतर्गत जिसे इम्पोर्टर की target_namespace सेटिंग निर्धारित करती है, जो imported है जब तक आप कोई दूसरा निर्धारित न करें (सेटिंग्स)।
aggregate.yaml — हर एजेंट के लिए एक इंस्टेंस, हर एक उस मॉडल से वायर किया गया जिसका वह नाम देता है और जिस कुंजी को वह प्रस्तुत करता है वह कनेक्शन पर घोषित है, और मॉडल, शुरुआत में ऐसी टिप्पणियों के साथ जो बताती हैं कि क्या पढ़ा गया और क्या नहीं:
# CrewAI declarations read:# - config/agents.yaml# - config/tasks.yaml# Not read: the crew's program, which runs its agents and its tasks and defines its tools; it runs in the image the Release names for each agent.# Tasks the crew's program runs, drafted as no Component:# - research_task, assigned to researcher# - reply_task, assigned to writerapiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: imported/support-brief version: 0.1.0 description: Draft Aggregate imported from a source in the crewai format.spec: components: researcher: type: core/ai-agent/crewai values: role: "Support plan researcher\u000A" goal: "Find what each support plan of the company covers, and what it costs\u000A" backstory: "You keep the company's support plans at your fingertips and answer from them alone.\u000A" allow_delegation: false log_level: DEBUG uses: model: gpt-4o-mini: target: gpt-4o-mini # For the compose target, the lines below declare credential on gpt-4o-mini: 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 writer: type: core/ai-agent/crewai values: role: "Support reply writer\u000A" goal: "Turn the researcher's findings into a short, friendly reply to the customer\u000A" backstory: "You write replies customers can act on, in plain words.\u000A" allow_delegation: false log_level: INFO uses: model: gpt-4o-mini: target: gpt-4o-mini # For the compose target, the lines below declare credential on gpt-4o-mini: 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 # The model openai/gpt-4o-mini. gpt-4o-mini: type: core/ai-model/openai values: model: "gpt-4o-mini"role, goal और backstory जैसे घोषित हैं वैसे ही आगे ले जाए जाते हैं, उस लाइन ब्रेक सहित जिससे हर फ़ोल्डेड ब्लॉक समाप्त होता है। log_level researcher के लिए DEBUG है, जो verbose घोषित है, और writer के लिए INFO, जो नहीं है। जो एजेंट कोई allow_delegation घोषित नहीं करता, उसे false के साथ ड्राफ़्ट किया जाता है। मॉडल एक होस्टेड सेवा है, इसलिए एजेंट का Component उससे ऐसे कनेक्शन को अस्वीकार करता है जो कोई क्रेडेंशियल नहीं रखता; हर कनेक्शन एक क्रेडेंशियल घोषित करता है, कुंजी OPENAI_API_KEY के अंतर्गत।
release.yaml — एनवायरनमेंट, हर एजेंट की इमेज और प्रकाशित पोर्ट, और हर कुंजी कहाँ से आती है:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: imported/support-brief # 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 crewai format.spec: aggregate: imported/support-brief manifest: imported/support-brief components: researcher: infra: # Left for the Release, since the source cannot supply it: infra.image, the container image running the crew's program image: "ghcr.io/example/support-brief:1.0.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: 8000 uses: model: gpt-4o-mini: features: credential: type: core/secret-value infra: # Attached by reference, never as a value: the credential researcher presents to gpt-4o-mini on its model connection (the source names no variable for it, so it is read from the one OpenAI's client libraries read the API key from), 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}" writer: infra: # Left for the Release, since the source cannot supply it: infra.image, the container image running the crew's program image: "ghcr.io/example/support-brief:1.0.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: 8001 uses: model: gpt-4o-mini: features: credential: type: core/secret-value infra: # Attached by reference, never as a value: the credential writer presents to gpt-4o-mini on its model connection (the source names no variable for it, so it is read from the one OpenAI's client libraries read the API key from), 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}" gpt-4o-mini: {}एनवायरनमेंट, development, एक डिफ़ॉल्ट है जिसे इम्पोर्ट लिखता है क्योंकि कोई घोषणा उसका नाम नहीं देती; जहाँ Release कहीं और डिप्लॉय होता है, वहाँ इसे बदलें। हर इमेज वह उत्तर है जिसे इम्पोर्ट ने import-answers.yaml से पढ़ा। हर एजेंट आपकी मशीन के लूपबैक पते पर प्रकाशित होता है, और उस पोर्ट पर फ़ॉरवर्ड करता है जिस पर उसका प्रोग्राम सुनता है, infra.port, जो 8000 है जब तक आप इसे निर्धारित न करें: researcher 8000 पर और writer 8001 पर, क्योंकि एक Release की दो सेवाएँ एक ही पोर्ट प्रकाशित नहीं कर सकतीं। घोषणाएँ कुंजी के लिए किसी वेरिएबल का नाम नहीं देतीं, इसलिए हर कनेक्शन उसे ${OPENAI_API_KEY} से पढ़ता है, वह वेरिएबल जिसे OpenAI की क्लाइंट लाइब्रेरी पढ़ती हैं, एक वेरिएबल संदर्भ के रूप में और कभी किसी मान के रूप में नहीं।
manifest.yaml — हर प्रकार का Compose Recipe, और वह रियलाइज़ेशन जो किसी कुंजी के वेरिएबल संदर्भ को Compose फ़ाइल में जैसा लिखा है वैसा ही लिखता है:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: imported/support-brief version: 0.1.0spec: mappings: components: type: core/ai-agent/crewai: compose/crewai core/ai-model/openai: compose/openai features: type: core/secret-value: compose/dotenv-secretrelease.lock उन कैटलॉग एंटिटी को, डाइजेस्ट के साथ, रिकॉर्ड करता है जिन पर Release रिज़ॉल्व हुआ, और .aggrega-import.json इस बात का रिकॉर्ड है कि इम्पोर्ट ने क्या लिखा, जिसे बाद में कोई aggrega import --sync पढ़ता है।
वैलिडेट और बिल्ड करें
aggrega validate --release release.yamlaggrega build --release release.yaml

वैलिडेशन प्रिंट करता है:
notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)release dependency validation passed: release.yaml (schema-pillar + dependency pillars)और बिल्ड, जहाँ <workspace> उस फ़ोल्डर के स्थान पर है जिसमें आपने इसे चलाया:
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>/distnotice पंक्ति सलाहकारी है: सीक्रेट Feature अपना origin Aggregate के values से या Release के infra से स्वीकार करता है, और नोटिस बताता है कि एक लीफ़ दोनों में घोषित है। यह कोई निर्णय नहीं बदलती।
dist/compose/docker-compose.yaml में researcher की सेवा; writer की सेवा केवल अपने नाम में, अपने स्वयं के वेरिएबल जिन मानों को रखते हैं उनमें, और जिस पोर्ट को वह प्रकाशित करती है उसमें भिन्न है:
services: researcher: image: ghcr.io/example/support-brief:1.0.0 environment: OPENAI_BASE_URL: https://api.openai.com/v1 MODEL: gpt-4o-mini CREWAI_ALLOW_DELEGATION: "false" CREWAI_BACKSTORY: | You keep the company's support plans at your fingertips and answer from them alone. CREWAI_GOAL: | Find what each support plan of the company covers, and what it costs CREWAI_LOG_LEVEL: DEBUG CREWAI_ROLE: | Support plan researcher OPENAI_API_KEY: ${OPENAI_API_KEY} ports: - 127.0.0.1:8000:8000 [… omitted: the labels the build writes on every service, naming the Aggregate, the component, the environment and the compiler's version] networks: - composeएजेंट मॉडल का पता और उसका नाम OPENAI_BASE_URL और MODEL के रूप में प्राप्त करता है, वे वेरिएबल जिनसे CrewAI उन्हें पढ़ता है, और कुंजी OPENAI_API_KEY के रूप में। उसकी भूमिका, लक्ष्य, बैकस्टोरी, डेलिगेशन स्विच और लॉग स्तर उन नामों के अंतर्गत पहुँचते हैं जो CrewAI Component उन्हें डिफ़ॉल्ट रूप से देता है, ताकि crew का प्रोग्राम उन्हें पढ़े; घटक पर ही एक inject: ब्लॉक उनमें से किसी को भी इसके बजाय उस नाम के अंतर्गत पहुँचाता है जिसे प्रोग्राम पढ़ता है। इम्पोर्ट द्वारा ड्राफ़्ट किया गया हर मान वह लाइन ब्रेक बनाए रखता है जिससे उसकी घोषणा समाप्त हुई थी, इसलिए फ़ाइल उसे एक ब्लॉक के रूप में लिखती है। मॉडल को अपनी कोई सेवा नहीं मिलती: एजेंट OpenAI API तक उसके अपने पते पर पहुँचते हैं। कुंजी एक वेरिएबल संदर्भ है, जो स्टैक शुरू होने पर आपके शेल से भरा जाता है। हर सेवा अपना पोर्ट केवल 127.0.0.1 पर प्रकाशित करती है: researcher का 8000 और writer का 8001, हर एक अपने कंटेनर के अंदर प्रोग्राम के पोर्ट 8000 पर फ़ॉरवर्ड करता है।
AI असिस्टेंट के साथ
Aggrega के टूल के साथ सेट अप किया गया AI असिस्टेंट भी यही कर सकता है: यह प्रॉम्प्ट उसमें पेस्ट करें।
केवल Aggrega टूल का उपयोग करें, और स्वयं कोई फ़ोल्डर न बनाएं। यदि Workspace फ़ोल्डर में अभी कोई `import-crewai` फ़ोल्डर नहीं है, तो `draft` टूल को एक बार कॉल करें, `example` को `import-crewai` पर सेट करके और बिना `dir` के: यह उदाहरण को एक नए `import-crewai` फ़ोल्डर में लिखता है, जिसके `source` फ़ोल्डर में वह है जिसे यह पेज इम्पोर्ट करता है। फिर `import` टूल को कॉल करें, `workspace_root` को `import-crewai/source` पर, `source` को `src/support_brief` पर और `target` को `compose` पर सेट करके: यह जिन उत्तरों की आवश्यकता है उन्हें `src/support_brief` फ़ोल्डर के अंदर `import-answers.yaml` से पढ़ता है, अपने ड्राफ़्ट `import-crewai/source` में लिखता है और जो उन्हें चाहिए उसे पुल करता है। फिर `validate` टूल को कॉल करें, `workspace_root` को `import-crewai/source` पर और `release` को `release.yaml` पर सेट करके, और `build` टूल को, `workspace_root` को `import-crewai/source` पर, `release` को `release.yaml` पर और `write` को true पर सेट करके। मुझे बताएं कि बिल्ड ने कौन-सी फ़ाइलें लिखीं; वे `import-crewai/source/dist/` के अंतर्गत हैं।इसे VS Code में खोलें
Visual Studio Code के लिए Aggrega एक्सटेंशन इंस्टॉल होने पर, VS Code में फ़ोल्डर import-crewai/source खोलें, जहाँ इम्पोर्ट ने अपने ड्राफ़्ट लिखे। फ़ोल्डर में एक Release है, ड्राफ़्ट किया गया release.yaml, इसलिए एडिटर उसे आपके लिए चुन लेता है, और जब आप ड्राफ़्ट संपादित करते हैं तो वह उन्हें उस Release के विरुद्ध जाँचता है, और जो कुछ उसे मिलता है उसे फ़ाइल में और Problems पैनल में चिह्नित करता है। कमांड पैलेट में Aggrega: Show topology graph Release के घटकों और उनके बीच के कनेक्शनों को बनाता है। Aggrega: Build, Aggrega: Preview build और Aggrega: Pull उसी Release पर काम करते हैं, और हर एक एक्टिविटी बार में Aggrega व्यू के Commands पैनल पर एक बटन भी है; Build अपनी फ़ाइलें फ़ोल्डर के dist/ में लिखता है। बाकी सब Visual Studio Code में Aggrega का उपयोग करें में है।
इसे चलाएं
आप इमेज प्रोजेक्ट से, अपने स्वयं के Dockerfile के साथ, बिल्ड करते हैं। Docker Compose इमेज के अपने कमांड को हर एजेंट की सेवा के रूप में चलाता है, क्योंकि Recipe कोई कमांड निर्धारित नहीं करता, इसलिए वह कमांड चलता रहना चाहिए, और यदि आप crew तक पहुँचना चाहते हैं तो उसे अनुरोधों का उत्तर देना चाहिए। पता, रूट और जवाब आपका प्रोग्राम तय करता है।
नीचे का रन ऐसी ही एक इमेज के साथ हुआ: CrewAI के क्लासिक लेआउट में crew का प्रोग्राम — एक crew.py जो दोनों घोषणा फ़ाइलों से crew बनाती है, वैसे ही जैसे इम्पोर्ट ने उन्हें पढ़ा — और, इमेज के कमांड के रूप में, पोर्ट 8000 पर प्रोग्राम का अपना एक छोटा HTTP सर्वर, जो हर POST /kickoff के लिए crew को एक बार चलाता है। अपनी इमेज प्रोजेक्ट के रूट पर बिल्ड करें, src/support_brief/import-answers.yaml में दोनों एजेंटों के लिए ghcr.io/example/support-brief:1.0.0 के स्थान पर उसका नाम लिखें, और --sync के साथ फिर से इम्पोर्ट करें, जो नए उत्तर ड्राफ़्ट में लिखता है और फिर से पुल करता है; फिर बिल्ड करें:
docker build -t support-brief:local .aggrega import src/support_brief --syncaggrega build --release release.yamlदोनों उत्तरों के रूप में support-brief:local होने पर, सिंक अपने द्वारा प्रिंट की गई पंक्तियों में उन दो मानों का नाम देता है जिन्हें उसने बदला:
changed spec.components.researcher.infra.image in release.yamlchanged spec.components.writer.infra.image in release.yamlफिर अपने शेल में कुंजी सेट करें और स्टैक शुरू करें:
export OPENAI_API_KEY='your OpenAI key'docker compose -p support-brief -f dist/compose/docker-compose.yaml up -d --wait-p प्रोजेक्ट का नाम देता है, जैसा इम्पोर्ट कैसे चलता है का रन चरण बताता है।
इसे जाँचें
नीचे का अनुरोध उस प्रोग्राम तक पहुँचता है जिसे इस वॉकथ्रू की इमेज चलाती है: पोर्ट 8000 पर एक छोटे HTTP सर्वर के पीछे crew, जो POST /kickoff का उत्तर देता है। आपका अपना प्रोग्राम अपना रूट और जवाब स्वयं तय करता है। इसे researcher को http://127.0.0.1:8000 पर भेजें, वह पता जिसे published_port प्रकाशित करता है, जब प्रोग्राम सुनने लगे, यानी स्टैक शुरू होने के कुछ सेकंड बाद:
curl -sS -X POST http://127.0.0.1:8000/kickoff -H 'Content-Type: application/json' \ -d '{"question": "Which support plan covers a weekend outage, and what does it cost?"}'{ "error": "the crew failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-place************-key. [… omitted: where to find an API key, and the error's type and code]"}रन ने OPENAI_API_KEY को एक प्लेसहोल्डर पर सेट किया, इसलिए जवाब OpenAI द्वारा उसका अस्वीकार है, जिसे प्रोग्राम आगे भेजता है। crew का अनुरोध OpenAI API तक उस कुंजी के साथ पहुँचा जिसे बिल्ड ने पहुँचाया। दोनों एजेंट एक ही इमेज चलाते हैं, इसलिए अनुरोध किसी को भी जा सकता था: writer http://127.0.0.1:8001 पर वैसा ही उत्तर देता है।
स्टैक को इससे रोकें:
docker compose -p support-brief -f dist/compose/docker-compose.yaml downKubernetes पर, --target helm के साथ इम्पोर्ट करें और इमेज को ऐसी रजिस्ट्री पर पुश करें जिससे आपका क्लस्टर पुल करता है, और src/support_brief/import-answers.yaml में उसका नाम दें। फिर Secret openai-api-key बनाएं और बिल्ड लागू करें, जैसा इम्पोर्ट कैसे चलता है का रन चरण बताता है। किसी भी एजेंट के Deployment का कोई Service नहीं है, इसलिए एक लोकल पोर्ट को researcher के Deployment पर फ़ॉरवर्ड करें। कमांड तब तक चलता है जब तक आप उसे रोक न दें:
kubectl port-forward deploy/researcher 8000:8000Forwarding from 127.0.0.1:8000 -> 8000Forwarding from [::1]:8000 -> 8000किसी दूसरे टर्मिनल से, वही अनुरोध फ़ॉरवर्ड किए गए पोर्ट पर भेजें:
curl -sS -X POST http://127.0.0.1:8000/kickoff -H 'Content-Type: application/json' \ -d '{"question": "Which support plan covers a weekend outage, and what does it cost?"}'{ "error": "the crew failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-place************-key. [… omitted: where to find an API key, and the error's type and code]"}