| 30 | |
| 31 | |
| 32 | class AgentEngineApp(AdkApp): |
| 33 | def set_up(self) -> None: |
| 34 | """Initialize the agent engine app with logging and telemetry.""" |
| 35 | vertexai.init() |
| 36 | setup_telemetry() |
| 37 | super().set_up() |
| 38 | logging.basicConfig(level=logging.INFO) |
| 39 | logging_client = google_cloud_logging.Client() |
| 40 | self.logger = logging_client.logger(__name__) |
| 41 | if gemini_location: |
| 42 | os.environ["GOOGLE_CLOUD_LOCATION"] = gemini_location |
| 43 | |
| 44 | def register_feedback(self, feedback: dict[str, Any]) -> None: |
| 45 | """Collect and log feedback.""" |
| 46 | feedback_obj = Feedback.model_validate(feedback) |
| 47 | self.logger.log_struct(feedback_obj.model_dump(), severity="INFO") |
| 48 | |
| 49 | def register_operations(self) -> dict[str, list[str]]: |
| 50 | """Registers the operations of the Agent.""" |
| 51 | operations = super().register_operations() |
| 52 | operations[""] = [*operations.get("", []), "register_feedback"] |
| 53 | return operations |
| 54 | |
| 55 | |
| 56 | gemini_location = os.environ.get("GOOGLE_CLOUD_LOCATION") |