Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: lint fixings in vertex_ai_memory_bank.py #2019

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

Merged
merged 1 commit into from
Jul 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/google/adk/memory/vertex_ai_memory_bank_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

import json
import logging
from typing import Any
from typing import Dict
from typing import Optional
from typing import TYPE_CHECKING

from google.genai import Client
from google.genai import types
from typing_extensions import override

from google import genai

from .base_memory_service import BaseMemoryService
from .base_memory_service import SearchMemoryResponse
from .memory_entry import MemoryEntry
Expand Down Expand Up @@ -84,7 +86,7 @@ async def add_session_to_memory(self, session: Session):
path=f'reasoningEngines/{self._agent_engine_id}/memories:generate',
request_dict=request_dict,
)
logger.info(f'Generate memory response: {api_response}')
logger.info('Generate memory response: %s', api_response)
else:
logger.info('No events to add to memory.')

Expand All @@ -106,7 +108,7 @@ async def search_memory(self, *, app_name: str, user_id: str, query: str):
},
)
api_response = _convert_api_response(api_response)
logger.info(f'Search memory response: {api_response}')
logger.info('Search memory response: %s', api_response)

if not api_response or not api_response.get('retrievedMemories', None):
return SearchMemoryResponse()
Expand All @@ -117,10 +119,8 @@ async def search_memory(self, *, app_name: str, user_id: str, query: str):
memory_events.append(
MemoryEntry(
author='user',
content=genai.types.Content(
parts=[
genai.types.Part(text=memory.get('memory').get('fact'))
],
content=types.Content(
parts=[types.Part(text=memory.get('memory').get('fact'))],
role='user',
),
timestamp=memory.get('updateTime'),
Expand All @@ -137,13 +137,13 @@ def _get_api_client(self):
Returns:
An API client for the given project and location.
"""
client = genai.Client(
client = Client(
vertexai=True, project=self._project, location=self._location
)
return client._api_client


def _convert_api_response(api_response):
def _convert_api_response(api_response) -> Dict[str, Any]:
"""Converts the API response to a JSON object based on the type."""
if hasattr(api_response, 'body'):
return json.loads(api_response.body)
Expand Down