googleapis / googleapis/python-aiplatform

Invalid argument error

Aperta
#6,014 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
api: vertex-ai
Lingua principale
Python
Stelle
905
Fork
465
Merge medio
1g 13h
PR unite (30g)
44

Descrizione

Thanks for stopping by to let us know something could be better!

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

- Search the issues already opened: https://github.com/googleapis/python-aiplatform/issues
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python

If you are still having issues, please be sure to include as much information as possible:

#### Environment details

- OS type and version: windows 11
- Python version: 3.12.10
- pip version: 25.0.1
- `google-cloud-aiplatform` version: 1.121.0

#### Steps to reproduce

1. create an adk agent and then created a deployement folder that consists of the deployement.py
2. run the deployement.py --create

#### Code example

import os
import sys

import vertexai
from absl import app, flags
from dotenv import load_dotenv
from vertexai import agent_engines
from vertexai.preview import reasoning_engines

from bq_agent_app.agent import root_agent

FLAGS = flags.FLAGS
flags.DEFINE_string("project_id", None, "GCP project ID.")
flags.DEFINE_string("location", None, "GCP location.")
flags.DEFINE_string("bucket", None, "GCP bucket.")
flags.DEFINE_string("resource_id", None, "ReasoningEngine resource ID.")
flags.DEFINE_string("user_id", "test_user", "User ID for session operations.")
flags.DEFINE_string("session_id", None, "Session ID for operations.")
flags.DEFINE_bool("create", False, "Creates a new deployment.")
flags.DEFINE_bool("delete", False, "Deletes an existing deployment.")
flags.DEFINE_bool("list", False, "Lists all deployments.")
flags.DEFINE_bool("create_session", False, "Creates a new session.")
flags.DEFINE_bool("list_sessions", False, "Lists all sessions for a user.")
flags.DEFINE_bool("get_session", False, "Gets a specific session.")
flags.DEFINE_bool("send", False, "Sends a message to the deployed agent.")
flags.DEFINE_string(
"message",
"Shorten this message: Hello, how are you doing today?",
"Message to send to the agent.",
)
flags.mark_bool_flags_as_mutual_exclusive(
[
"create",
"delete",
"list",
"create_session",
"list_sessions",
"get_session",
"send",
]
)

def create() -> None:
"""Creates a new deployment."""
# First wrap the agent in AdkApp
app = reasoning_engines.AdkApp(
agent=root_agent,
enable_tracing=True,
)

# Now deploy to Agent Engine
remote_app = agent_engines.create(
agent_engine=app,
requirements=[
"google-cloud-aiplatform[adk,agent_engines]"
],
extra_packages=["bq_agent_app"],
)
print(f"Created remote app: {remote_app.resource_name}")

def delete(resource_id: str) -> None:
"""Deletes an existing deployment."""
remote_app = agent_engines.get(resource_id)
remote_app.delete(force=True)
print(f"Deleted remote app: {resource_id}")

def list_deployments() -> None:
"""Lists all deployments."""
deployments = agent_engines.list()
if not deployments:
print("No deployments found.")
return
print("Deployments:")
for deployment in deployments:
print(f"- {deployment.resource_name}")

def create_session(resource_id: str, user_id: str) -> None:
"""Creates a new session for the specified user."""
remote_app = agent_engines.get(resource_id)
remote_session = remote_app.create_session(user_id=user_id)
print("Created session:")
print(f" Session ID: {remote_session['id']}")
print(f" User ID: {remote_session['user_id']}")
print(f" App name: {remote_session['app_name']}")
print(f" Last update time: {remote_session['last_update_time']}")
print("\nUse this session ID with --session_id when sending messages.")

def list_sessions(resource_id: str, user_id: str) -> None:
"""Lists all sessions for the specified user."""
remote_app = agent_engines.get(resource_id)
sessions = remote_app.list_sessions(user_id=user_id)
print(f"Sessions for user '{user_id}':")
for session in sessions:
print(f"- Session ID: {session['id']}")

def get_session(resource_id: str, user_id: str, session_id: str) -> None:
"""Gets a specific session."""
remote_app = agent_engines.get(resource_id)
session = remote_app.get_session(user_id=user_id, session_id=session_id)
print("Session details:")
print(f" ID: {session['id']}")
print(f" User ID: {session['user_id']}")
print(f" App name: {session['app_name']}")
print(f" Last update time: {session['last_update_time']}")

def send_message(resource_id: str, user_id: str, session_id: str, message: str) -> None:
"""Sends a message to the deployed agent."""
remote_app = agent_engines.get(resource_id)

print(f"Sending message to session {session_id}:")
print(f"Message: {message}")
print("\nResponse:")
for event in remote_app.stream_query(
user_id=user_id,
session_id=session_id,
message=message,
):
print(event)

def main(argv=None):
"""Main function that can be called directly or through app.run()."""
# Parse flags first
if argv is None:
argv = flags.FLAGS(sys.argv)
else:
argv = flags.FLAGS(argv)

load_dotenv()

# Now we can safely access the flags
project_id = (
FLAGS.project_id if FLAGS.project_id else os.getenv("GOOGLE_CLOUD_PROJECT")
)
location = FLAGS.location if FLAGS.location else os.getenv("GOOGLE_CLOUD_LOCATION")
bucket = FLAGS.bucket if FLAGS.bucket else os.getenv("GOOGLE_CLOUD_STAGING_BUCKET")
user_id = FLAGS.user_id

if not project_id:
print("Missing required environment variable: GOOGLE_CLOUD_PROJECT")
return
elif not location:
print("Missing required environment variable: GOOGLE_CLOUD_LOCATION")
return
elif not bucket:
print("Missing required environment variable: GOOGLE_CLOUD_STAGING_BUCKET")
return

vertexai.init(
project=project_id,
location=location,
staging_bucket=bucket,
)

if FLAGS.create:
create()
elif FLAGS.delete:
if not FLAGS.resource_id:
print("resource_id is required for delete")
return
delete(FLAGS.resource_id)
elif FLAGS.list:
list_deployments()
elif FLAGS.create_session:
if not FLAGS.resource_id:
print("resource_id is required for create_session")
return
create_session(FLAGS.resource_id, user_id)
elif FLAGS.list_sessions:
if not FLAGS.resource_id:
print("resource_id is required for list_sessions")
return
list_sessions(FLAGS.resource_id, user_id)
elif FLAGS.get_session:
if not FLAGS.resource_id:
print("resource_id is required for get_session")
return
if not FLAGS.session_id:
print("session_id is required for get_session")
return
get_session(FLAGS.resource_id, user_id, FLAGS.session_id)
elif FLAGS.send:
if not FLAGS.resource_id:
print("resource_id is required for send")
return
if not FLAGS.session_id:
print("session_id is required for send")
return
send_message(FLAGS.resource_id, user_id, FLAGS.session_id, FLAGS.message)
else:
print(
"Please specify one of: --create, --delete, --list, --create_session, --list_sessions, --get_session, or --send"
)

if __name__ == "__main__":
app.run(main)

#### Stack trace
```
Creating AgentEngine
I1024 11:51:15.500392 19340 base.py:85] Creating AgentEngine
Create AgentEngine backing LRO: projects/483836109247/locations/us-central1/reasoningEngines/851659716642734080/operations/1097970335812157440
I1024 11:51:15.500392 19340 base.py:88] Create AgentEngine backing LRO: projects/483836109247/locations/us-central1/reasoningEngines/851659716642734080/operations/1097970335812157440
View progress and logs at https://console.cloud.google.com/logs/query?project=smrtfact-mfg-adv-analytic-650e
I1024 11:51:15.508526 19340 _agent_engines.py:611] View progress and logs at https://console.cloud.google.com/logs/query?project=smrtfact-mfg-adv-analytic-650e
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\ADK_AGENTS\deployement\deploy.py", line 205, in
app.run(main)
File "C:\Users\240155618\OneDrive - GE Appliances\ADK_agents\venv\Lib\site-packages\absl\app.py", line 316, in run
_run_main(main, args)
File "C:\Users\240155618\OneDrive - GE Appliances\ADK_agents\venv\Lib\site-packages\absl\app.py", line 261, in _run_main
sys.exit(main(argv))
^^^^^^^^^^
File "C:\ADK_AGENTS\deployement\deploy.py", line 164, in main
create()
File "C:\ADK_AGENTS\deployement\deploy.py", line 54, in create
remote_app = agent_engines.create(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\240155618\OneDrive - GE Appliances\ADK_agents\venv\Lib\site-packages\vertexai\agent_engines\__init__.py", line 194, in create
return AgentEngine.create(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\240155618\OneDrive - GE Appliances\ADK_agents\venv\Lib\site-packages\vertexai\agent_engines\_agent_engines.py", line 614, in create
created_resource = operation_future.result()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\240155618\OneDrive - GE Appliances\ADK_agents\venv\Lib\site-packages\google\api_core\future\polling.py", line 261, in result
raise self._exception
google.api_core.exceptions.InvalidArgument: 400 Reasoning Engine resource [projects/483836109247/locations/us-central1/reasoningEngines/851659716642734080] failed to start and cannot serve traffic. Please refer to our documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/troubleshooting/deploy) for checking logs and other troubleshooting tips. 3: Reasoning Engine resource [projects/483836109247/locations/us-central1/reasoningEngines/851659716642734080] failed to start and cannot serve traffic. Please refer to our documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/troubleshooting/deploy) for checking logs and other troubleshooting tips.

```

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.