התאמה אישית ופריסה של תבנית של Google

התבניות ש-Google מספקת ב-Application Design Center מאפשרות לכם להתחיל מארכיטקטורות שהוגדרו מראש בהתאם Google Cloud לשיטות המומלצות. במדריך למתחילים הזה תעתיקו את התבנית Generative AI RAG with Cloud SQL, תתאימו אישית את הרכיבים שלה ותפרסו אפליקציית בדיקה, באמצעות שלבים שרלוונטיים לכל תבנית.

בתמונה הבאה מוצגים הרכיבים והחיבורים של התבנית "AI גנרטיבי RAG with Cloud SQL" בקנבס העיצוב:

אפליקציית RAG של AI גנרטיבי בכלי העריכה.

לפני שמתחילים

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that billing is enabled for your Google Cloud project.

  3. מגדירים את App Design Center בפרויקט.

התפקידים הנדרשים

מבקשים מהאדמין להקצות לכם את התפקידים שמפורטים בטבלה הבאה:

משימה התפקידים הנדרשים
העתקה, עיצוב ועריכה של תבניות אדמין ב-Application Design Center‏ (roles/designcenter.admin) או משתמש ב-Application Design Center‏ (roles/designcenter.user)
פריסת אפליקציות והגדרות אישיות אדמין של אפליקציה (roles/designcenter.applicationAdmin) או עריכת אפליקציה (roles/designcenter.applicationEditor)
יצירת חשבונות שירות במהלך הפריסה יצירת חשבונות שירות (roles/iam.serviceAccountCreator) בפרויקט
מתן גישה לחשבון השירות בפרויקט אדמין IAM של פרויקט (roles/resourcemanager.projectIamAdmin) בפרויקט

מידע נוסף על תפקידים זמין במאמר בקרת גישה באמצעות IAM.

הכנת הסביבה

כדי להשלים את המדריך למתחילים הזה, אתם יכולים להשתמש באחת מהאפשרויות הבאות:

  • משתמשים בלוח הציור במסוף Google Cloud .

העתקת התבנית ויצירת טיוטה של הבקשה

מעתיקים את התבנית של Google ומגדירים טיוטת אפליקציה.

קנבס לעיצוב

  1. נכנסים לדף Google templates במסוף Google Cloud .

    מעבר לתבניות של Google

  2. לוחצים על Preview and customize בכרטיס התבנית Generative AI RAG with Cloud SQL.

    התבנית נפתחת באזור העיצוב.

  3. לוחצים על שכפול והתאמה אישית.

  4. בתיבת הדו-שיח Create a new template, מזינים את הפרטים הבאים:

    1. בשדה Template ID, מזינים את הערך quickstart-custom-gen-ai-rag.

    2. בשדה Template Name, מזינים את הערך Quickstart custom Generative AI RAG.

    3. בשדה Description, מזינים A custom template copied from the Generative AI RAG with Cloud SQL template..

    4. לוחצים על יצירת תבנית.

    התבנית מועתקת למרחב שלכם ומוצגת באזור העריכה.

  5. ב-design canvas, לוחצים על Configure an app.

  6. לוחצים על יצירת אפליקציה חדשה ומזינים את הפרטים הבאים:

    1. בשדה Name, מזינים quickstart-custom-gen-ai-rag-test.

    2. בשדה השם המוצג, מזינים Quickstart custom Generative AI RAG test.

    3. ברשימה Region, בוחרים באפשרות us-central1 (Iowa).

    4. ברשימה Environment, בוחרים באפשרות Test.

    5. ברשימה Criticality, בוחרים באפשרות Low.

  7. לוחצים על Create Application.

    המערכת יוצרת טיוטה של הבקשה.

‫CLI של gcloud

  1. מסננים את התבניות המשותפות בקטלוג של Google כדי למצוא את ה-URI של הגרסה של התבנית gen-ai-rag-with-sql.

    gcloud design-center spaces shared-templates list \
      --google-catalog \
      --location=LOCATION \
      --filter="displayName:gen-ai-rag-cloud-sql"
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫LOCATION: המיקום של המרחב המשותף. לדוגמה, us-central1.

    מזהים את ה-URI של הגרסה מהפלט.

  2. יוצרים טיוטת אפליקציה מגרסת התבנית הזו.

    gcloud design-center spaces applications create quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --source-shared-template-revision-uri=SHARED_TEMPLATE_REVISION_URI \
      --display-name="Quickstart custom Generative AI RAG test" \
      --environment-type=test \
      --criticality-type=low \
      --scope-type=regional \
      --deployment-region=LOCATION
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫SPACE: מזהה המרחב המשותף. לדוגמה, default-space.
    • ‫LOCATION: המיקום של המרחב המשותף. לדוגמה, us-central1.
    • ‫PROJECT: מזהה הפרויקט.
    • ‫SHARED_TEMPLATE_REVISION_URI: ה-URI של הגרסה של התבנית. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/sharedTemplates/f8ddfbd3-6393-4a1e-942c-aaa7292fa30c/revisions/r-28.

הגדרת רכיבים

מגדירים את הפרמטרים הנדרשים של הרכיבים בטיוטת האפליקציה. מידע נוסף על פרמטרים של רכיבים זמין במאמר משאבים נתמכים.

קנבס לעיצוב

  1. ב-design canvas, לוחצים על frontend-service ומבצעים את הפעולות הבאות באזור Configuration:

    1. בשדה Service Name, מזינים את הערך custom-rag-frontend.

    2. לוחצים על Save.

  2. ב-design canvas, לוחצים על retrieval-service ומבצעים את הפעולות הבאות באזור Configuration:

    1. בשדה Service Name, מזינים את הערך custom-retrieval-service.

    2. לוחצים על Save.

  3. ב-design canvas, לוחצים על database-postgresql ומבצעים את הפעולות הבאות באזור Configuration:

    1. בשדה Name, מזינים custom-rag-database.

    2. לוחצים על Save.

  4. ב-design canvas, לוחצים על vertex-ai ומבצעים את הפעולות הבאות באזור Configuration:

    1. ברשימה מזהה פרויקט, מוודאים שהפרויקט שלכם נבחר.

    2. לוחצים על Save.

  5. ב-design canvas, לוחצים על secret-manager ומבצעים את הפעולות הבאות באזור Configuration:

    1. בשדה Name, מזינים db-ai-secret.

    2. לוחצים על Save.

בכל רכיב בקנבס מופיע סימן וי ירוק, שמציין שכל הפרמטרים הנדרשים הוגדרו.

‫CLI של gcloud

  1. תארו את האפליקציה כדי לזהות פרמטרים של רכיבים.

    gcloud design-center spaces applications describe quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --format='yaml(name,componentParameters)'
    

    בפלט מוצגים פרמטרים לכל רכיב.

  2. קבלת רשימה של מזהי URI של רכיבים.

    gcloud design-center spaces applications describe quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --format='value(serializedApplicationTemplate.components.uri)'
    
  3. יוצרים קובצי JSON של הגדרות בספריית העבודה.

    1. יוצרים custom-frontend.json.

      {
         "component": "FRONTEND_COMPONENT_URI",
         "parameters": [
            {
               "key": "service_name",
               "value": "custom-rag-frontend"
            },
            {
               "key": "project_id",
               "value": "PROJECT"
            },
            {
               "key": "location",
               "value": "LOCATION"
            }
         ]
      }
      
    2. יוצרים custom-retrieval.json.

      {
         "component": "RETRIEVAL_COMPONENT_URI",
         "parameters": [
            {
               "key": "service_name",
               "value": "custom-retrieval-service"
            },
            {
               "key": "project_id",
               "value": "PROJECT"
            },
            {
               "key": "location",
               "value": "LOCATION"
            }
         ]
      }
      
    3. יוצרים custom-database.json.

      {
         "component": "DATABASE_COMPONENT_URI",
         "parameters": [
            {
               "key": "name",
               "value": "custom-rag-database"
            },
            {
               "key": "project_id",
               "value": "PROJECT"
            },
            {
               "key": "database_version",
               "value": "POSTGRES_15"
            },
            {
               "key": "region",
               "value": "us-central1"
            },
            {
               "key": "zone",
               "value": "us-central1-a"
            }
         ]
      }
      
    4. יוצרים custom-secmanager.json.

      {
      "component": "SECRET_MANAGER_COMPONENT_URI",
      "parameters": [
         {
            "key": "name",
            "value": "db-ai-secret"
         },
         {
            "key": "project_id",
            "value": "PROJECT"
         }
      ]
      }
      
    5. יוצרים custom-vertex.json.

      {
      "component": "VERTEX_AI_COMPONENT_URI",
      "parameters": [
         {
            "key": "project_id",
            "value": "PROJECT"
         }
      ]
      }
      

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫FRONTEND_COMPONENT_URI: ה-URI של רכיב החזית. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/frontend-service.
    • ‫RETRIEVAL_COMPONENT_URI: ה-URI של רכיב השליפה. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/retrieval-service.
    • ‫DATABASE_COMPONENT_URI: ה-URI של רכיב מסד הנתונים. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/database-postgresql.
    • ‫SECRET_MANAGER_COMPONENT_URI: ה-URI של רכיב Secret Manager. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/secret-manager.
    • ‫VERTEX_AI_COMPONENT_URI: ה-URI של רכיב Vertex AI. לדוגמה, projects/gcpdesigncenter/locations/us-central1/spaces/googlespace/applicationTemplates/gen-ai-rag-cloud-sql/components/vertex-ai.
    • ‫PROJECT: מזהה הפרויקט.
    • ‫LOCATION: המיקום של המרחב המשותף. לדוגמה, us-central1.
  4. מעדכנים את הגדרות האפליקציה באמצעות קובצי הפרמטרים בפורמט JSON.

    gcloud design-center spaces applications update quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --component-parameters=./custom-frontend.json \
      --component-parameters=./custom-retrieval.json \
      --component-parameters=./custom-database.json \
      --component-parameters=./custom-secmanager.json \
      --component-parameters=./custom-vertex.json
    

פריסת האפליקציה

פורסים את האפליקציה שהוגדרה.

קנבס לעיצוב

  1. לוחצים על Deploy.

  2. באזור Select service account:

    1. לוחצים על Create a new service account.

    2. לוחצים על המשך.

  3. לוחצים על Deploy.

    אחרי כמה דקות, האפליקציה נפרסת והמשאבים נוצרים.

‫CLI של gcloud

  1. לצפות בתצוגה מקדימה של הפריסה וליצור באופן אוטומטי חשבון שירות לתצוגה מקדימה.

    gcloud design-center spaces applications preview quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --create-sa
    
  2. פורסים את האפליקציה ויוצרים באופן אוטומטי חשבון שירות לפריסה.

    gcloud design-center spaces applications deploy quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT \
      --create-sa \
      --async
    

    מעתיקים את מזהה הפעולה.

  3. עוקבים אחרי סטטוס הפריסה.

    gcloud design-center operations describe operation-OPERATION_ID \
        --location=LOCATION \
        --project=PROJECT
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫OPERATION_ID: מזהה הפעולה.
    • ‫LOCATION: המיקום של המרחב המשותף. לדוגמה, us-central1.
    • ‫PROJECT: מזהה הפרויקט.

אופציונלי: מעקב אחרי הפריסה

אחרי שפורסים את האפליקציה, אפשר לראות את הטלמטריה ולעקוב אחרי הביצועים:

  1. נכנסים לדף Application monitoring במסוף Google Cloud :

    כניסה אל Application monitoring

    אם אתם משתמשים בשורת החיפוש כדי למצוא את הדף הזה, בחרו בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. בעמודה Name, לוחצים על האפליקציה שפרסתם.

    בדף מוצג מידע על המעקב אחרי האפליקציה, השירותים ועומסי העבודה שלה.

  3. בודקים את מרכזי הבקרה המוגדרים מראש. למידע נוסף, קראו את הסקירה הכללית על מעקב אחרי אפליקציות.

הסרת המשאבים

כדי לא לצבור חיובים לחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, אתם צריכים למחוק את הפרויקט ב- Google Cloud יחד עם המשאבים.

מחיקת האפליקציה שנפרסה

קנבס לעיצוב

  1. בתפריט הניווט, לוחצים על אפליקציות.

    מעבר אל Applications

  2. לוחצים על Quickstart custom בינה מלאכותית גנרטיבית RAG test.

  3. לוחצים על Actions ובוחרים באפשרות Delete application.

  4. בשדה מחיקה, מזינים quickstart-custom-gen-ai-rag-test.

  5. לוחצים על Delete.

‫CLI של gcloud

  1. מוחקים את האפליקציה באמצעות ה-CLI.

    gcloud design-center spaces applications delete quickstart-custom-gen-ai-rag-test \
      --space=SPACE \
      --location=LOCATION \
      --project=PROJECT
    

אופציונלי: מחיקת הפרויקט

  1. במסוף Google Cloud , נכנסים לדף Manage resources.

    כניסה לדף Manage resources

  2. ברשימת הפרויקטים, בוחרים את הפרויקט שרוצים למחוק ולוחצים על Delete.
  3. בהודעה שמופיעה, מזינים את מזהה הפרויקט ולוחצים על Shut down.

המאמרים הבאים