-
Notifications
You must be signed in to change notification settings - Fork 531
fix: airbnb_planner_multiagent sample #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- lack of params for ChatVertexAI - task id error in send_message function(referred to a2aproject#304)
Summary of ChangesHello @johnnylin9708, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical issues within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces fixes for initializing ChatVertexAI and handling task_id in send_message. The changes are correct and address the described issues. I've included a couple of suggestions to enhance robustness by adding environment variable validation and to improve code conciseness by simplifying dictionary access.
| if os.getenv('GOOGLE_GENAI_USE_VERTEXAI') == 'TRUE': | ||
| # If not using Vertex AI, initialize with Google Generative AI | ||
| logger.info('ChatVertexAI model initialized successfully.') | ||
| self.model = ChatVertexAI(model=model) | ||
| self.model = ChatVertexAI( | ||
| model=model, | ||
| project=os.getenv('GOOGLE_CLOUD_PROJECT'), | ||
| location=os.getenv('GOOGLE_CLOUD_LOCATION'), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved robustness, it's a good practice to explicitly check for the existence of GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables when GOOGLE_GENAI_USE_VERTEXAI is enabled. This ensures the application fails fast with a clear error message if the required configuration is missing, similar to the existing check for GOOGLE_GENAI_MODEL.
if os.getenv('GOOGLE_GENAI_USE_VERTEXAI') == 'TRUE':
# If not using Vertex AI, initialize with Google Generative AI
logger.info('ChatVertexAI model initialized successfully.')
project = os.getenv('GOOGLE_CLOUD_PROJECT')
if not project:
raise ValueError(
'GOOGLE_CLOUD_PROJECT environment variable must be set when using Vertex AI'
)
location = os.getenv('GOOGLE_CLOUD_LOCATION')
if not location:
raise ValueError(
'GOOGLE_CLOUD_LOCATION environment variable must be set when using Vertex AI'
)
self.model = ChatVertexAI(
model=model,
project=project,
location=location,
)| # task_id = state['task_id'] if 'task_id' in state else str(uuid.uuid4()) | ||
| if 'task_id' in state and state['task_id'] is not None: | ||
| task_id = state['task_id'] | ||
| else: | ||
| task_id = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for retrieving task_id can be simplified. Using the .get() dictionary method is a more concise and Pythonic way to fetch the value, as it returns None by default if the key is not found. This single line can replace the if/else block and the commented-out code.
| # task_id = state['task_id'] if 'task_id' in state else str(uuid.uuid4()) | |
| if 'task_id' in state and state['task_id'] is not None: | |
| task_id = state['task_id'] | |
| else: | |
| task_id = None | |
| task_id = state.get('task_id') |
…sues - Initialize `ChatVertexAI` with explicit `project` and `location` parameters to ensure correct GCP context. - Update `routing_agent.py` to omit `taskId` on initial requests, allowing sub-agents to generate it. This resolves the "Task does not exist" error (Issue a2aproject#304). - Format code with Ruff and sort imports to comply with linting standards.
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.Fixes #304 🦕