Dans la version 1.112.0 du SDK Vertex AI, le module agent_engines
du SDK Vertex AI pour Python a été refactorisé en conception basée sur le client.
Cette page décrit les principaux changements apportés au module et explique comment migrer votre code existant vers la conception basée sur le client.
Pour obtenir des informations générales sur Agent Engine, consultez la présentation.
Principales modifications
De manière générale, les paramètres du client de service sont initialisés pour chaque client, et le client contient les modules pertinents pour les interactions de service.
par exemple les éléments suivants :
import vertexai
from vertexai import agent_engines
vertexai.init(project=GCP_PROJECT, location=GCP_REGION)
agent_engines.create(...)
est remplacé par
import vertexai
client = vertexai.Client(project=GCP_PROJECT, location=GCP_REGION)
client.agent_engines.create(...)
Les espaces de noms suivants pour Vertex AI Agent Engine dans le SDK Vertex AI sont en phase d'abandon. Utilisez les espaces de noms équivalents du SDK Vertex AI basé sur le client, qui offre une parité de fonctionnalités complète avec les modules et packages obsolètes.
Espace de noms du SDK Vertex AI | Code concerné | Remplacement du SDK Vertex AI basé sur le client |
---|---|---|
vertexai.agent_engines |
Méthodes concernées :
|
Remplacement :
|
client.agent_engines |
Méthodes concernées :
|
Remplacement :
|
Migrer vers la conception basée sur le client
Cette section contient des extraits de code qui montrent comment migrer votre code Agent Engine existant vers la conception basée sur le client.
Créer une instance Agent Engine
Avant
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,
# ...
)
Après
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,
# ...
},
)
Mettre à jour une instance Agent Engine
Avant
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,
# ...
)
Après
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,
# ...
},
)
Obtenir une instance Agent Engine
Avant
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.get(resource_name)
Après
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.get(name=resource_name)
Lister les instances Agent Engine
Avant
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.list()
Après
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.list()
Supprimer une instance Agent Engine
Avant
import vertexai
from vertexai import agent_engines
vertexai.init(
project=PROJECT,
location=LOCATION,
)
agent_engine = agent_engines.list()
Après
import vertexai
client = vertexai.Client(
project=PROJECT,
location=LOCATION,
)
agent_engine = client.agent_engines.list()