agent_engines ב-Vertex AI SDK ל-Python, והוא עוצב מחדש כעיצוב מבוסס-לקוח.
בדף הזה מתוארים השינויים העיקריים במודול ומוסבר איך מעבירים את הקוד הקיים לעיצוב מבוסס-לקוח.
מידע כללי על Agent Runtime זמין במאמר סקירה כללית.
השינויים העיקריים
ברמה גבוהה, פרמטרים של לקוח שירות מאותחלים על בסיס כל לקוח, והלקוח מכיל את המודולים הרלוונטיים לאינטראקציות עם השירות. למשל:
import vertexai
from vertexai import agent_engines
vertexai.init(project=GCP_PROJECT, location=GCP_REGION)
agent_engines.create(...)
מוחלף על ידי
import vertexai
# Mandatory for cross-project deployment and for use of the framework-specific templates.
vertexai.init(project=GCP_PROJECT, location=GCP_REGION)
client = vertexai.Client(project=GCP_PROJECT, location=GCP_REGION)
client.agent_engines.create(...)
מרחבי השמות הבאים של Agent Runtime ב-Vertex AI SDK נמצאים בשלב ההוצאה משימוש. משתמשים במרחבי השמות המקבילים מ-Vertex AI SDK שמבוסס על לקוח, שיש לו שוויון מלא בתכונות עם המודולים והחבילות שהוצאו משימוש.
| מרחב השמות של Vertex AI SDK | קוד מושפע | החלפה של Vertex AI SDK בגרסת לקוח |
|---|---|---|
vertexai.agent_engines |
השיטות שהושפעו:
|
החלפה:
|
client.agent_engines |
השיטות שהושפעו:
|
החלפה:
|
מעבר לעיצוב מבוסס-לקוח
בקטע הזה יש קטעי קוד שמדגימים איך להעביר את הקוד הקיים של Agent Runtime לעיצוב מבוסס-לקוח. הערה: יכול להיות שהדוגמאות לא יכללו ייבוא, תלות וקוד boilerplate אחר כדי לשפר את הקריאוּת.
יצירת מופע של Agent Runtime
לפני
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
staging_bucket=STAGING_BUCKET,
)
agent_engines.create(
local_agent,
requirements=REQUIREMENTS,
extra_packages=EXTRA_PACKAGES,
# ...
)
אחרי
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
client.agent_engines.create(
agent=local_agent,
config={
"staging_bucket": STAGING_BUCKET,
"requirements": REQUIREMENTS,
"extra_packages": EXTRA_PACKAGES,
# ...
},
)
עדכון מופע של Agent Runtime
לפני
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
staging_bucket=STAGING_BUCKET,
)
agent_engines.update(
resource_name,
agent_engine=local_agent,
requirements=REQUIREMENTS,
extra_packages=EXTRA_PACKAGES,
# ...
)
אחרי
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
client.agent_engines.update(
name=resource_name,
agent=local_agent,
config={
"staging_bucket": STAGING_BUCKET,
"requirements": REQUIREMENTS,
"extra_packages": EXTRA_PACKAGES,
# ...
},
)
קבלת מופע של Agent Runtime
לפני
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.get(resource_name)
אחרי
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.get(name=resource_name)
הצגת מופעים של Agent Runtime
לפני
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.list()
אחרי
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.list()
מחיקה של מופע Agent Runtime
לפני
agent_engine.delete(
force=True, # Optional
)
אפשרות אחרת:
py
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.delete(
resource_name, # Required.
force=True, # Optional
)
אחרי
agent_engine.delete(
force=True, # Optional.
)
אפשרות אחרת:
py
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.delete(
name=resource_name, # Required.
force=True, # Optional.
)