agent_engines בתוך ה-SDK עבר שינוי מבנה ושמו שונה ל-runtimes בחבילה העצמאית agentplatform.
בדף הזה מתוארים השינויים העיקריים במודול ומוסבר איך להעביר את הקוד הקיים למבנה החדש של ה-SDK.
מידע כללי על Agent Runtime זמין במאמר סקירה כללית.
השינויים העיקריים
ברמה גבוהה, פרמטרים של לקוח שירות מאותחלים על בסיס כל לקוח, והלקוח מכיל את המודולים הרלוונטיים לאינטראקציות עם השירות. למשל:
import vertexai
from vertexai import agent_engines
vertexai.init(project=GCP_PROJECT, location=GCP_REGION)
agent_engines.create(...)
מוחלף על ידי
import agentplatform
# Mandatory for cross-project deployment and for use of the framework-specific templates.
client = agentplatform.Client(project=GCP_PROJECT, location=GCP_REGION)
client.runtimes.create(...)
מרחבי השמות הבאים ב-SDK נמצאים בשלב ההוצאה משימוש. משתמשים במרחבי השמות המקבילים מ-SDK של Agent Platform שמבוסס על לקוח, שיש לו שוויון מלא בתכונות עם המודולים והחבילות שהוצאו משימוש.
| מרחב שמות מדור קודם | קוד מושפע | החלפה (agentplatform) |
|---|---|---|
vertexai.agent_engines |
השיטות שהושפעו:
|
החלפה:
|
client.agent_engines |
השיטות שהושפעו:
|
החלפה:
|
מעבר לעיצוב מבוסס-לקוח
בקטע הזה יש קטעי קוד שמדגימים איך להעביר את הקוד הקיים של Agent Runtime לעיצוב של agentplatform SDK.
הערה: יכול להיות שהדוגמאות לא יכללו ייבוא, תלות וקוד 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 agentplatform
client = agentplatform.Client(
project=PROJECT,
location=LOCATION,
)
client.runtimes.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 agentplatform
client = agentplatform.Client(
project=PROJECT,
location=LOCATION,
)
client.runtimes.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 agentplatform
client = agentplatform.Client(
project=PROJECT,
location=LOCATION,
)
remote_agent = client.runtimes.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 agentplatform
client = agentplatform.Client(
project=PROJECT,
location=LOCATION,
)
runtimes = client.runtimes.list()
מחיקה של מופע Agent Runtime
לפני
agent_engine.delete(
force=True, # Optional
)
לחלופין,
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.delete(
resource_name, # Required.
force=True, # Optional
)
אחרי
remote_agent.delete(
force=True, # Optional.
)
לחלופין,
import agentplatform
client = agentplatform.Client(
project=PROJECT,
location=LOCATION,
)
remote_agent = client.runtimes.delete(
name=resource_name, # Required.
force=True, # Optional.
)