Posts

application insights kusto working with dates

While working with dates are relatively easy until you be more specific. For example, what is the date and time range or between start and finish datetime range.  By default, application insights uses UTC time for its query. It is often a hassle when trying to convert between UTC to local time - and often introduces error in the query  How can we convert t local time? Save some time trying to figure out why there's no record coming back when we know there's some data in there. request | where timestamp between ( datetime_local_to_itc(datetime( 2026 - 10 - 0 7 11 : 00 : 00 , "Australia/Sydney" )) .. datetime_local_to_itc(datetime( 2026 - 10 - 0 7 11 : 15 : 00 , "Australia/Sydney" )) )

Using model armour with your google ADK agent

Image
Model armour provide guardrails for your model to ensure attacker do not perform mallicious prompt injection or perform jailbreak.  We can do that by creating our model armour in GCP and then test it out using our script. First we will start off by creating our template. Click on 'Create template'.  So here is how Model Armour works - you create the template in a region. Then when we deploy our agent - ADK to that region and ensure agent to use that configuration. All in the same region.  And then under "Detection" tab ensure that we have checked "Prompt injection and jailbreak detection".  As you can see, I have responsible AI configure too. And you can configure other details such as Responsible AI.  This is an example of our model armour Here is how we configure our model  from google . adk . agents . llm_agent import Agent from google . genai import types as genai_types TEMPLATE = "projects/project-your-id/locations/us-central1/templates/m...

Google agent platform creating corpus using console

Image
Creating corpus can be tricky in Google where we can get error messages about corpus type not being avaiable in certain regions.  Here is a quick example where we can create this corpus using console.  Click on "Create corpus" And then we need to provide some details :-  Please check to see corpus is supported in your region  Next, click on upload to upload your document. Supported documents are pdf, html, jsonl, json, markdwn, textfile, docs, pptx, google docs. No CSV :). Size are typically 10 to 50 MB.   This is different from vertex search which does support csv.  There are 3 embedding model here but we can only choose 2 ( text-embedding-005 and text-multilingual-embedding-002 ) that are recommended for use with RAG.  Something to note: As you can see we are running in "serverless mode" and that does not support Vector Search  (At least at the moment). Ensure you have selected "Managed Agent Retrieval".  And click " create corpus ". ...

python pydantic

Pydantic is a popular library which we can use for defining our custom objects and making it so much easy to use for day to day coding.  Here is one of the example that i link can really boost productivity - this is how we can assign data into our objects. from pydantic import BaseModel , EmailStr , Field class UserRegistration ( BaseModel ):     username : str = Field ( min_length = 3 , max_length = 20 )     age : int = Field ( ge = 18 )   # Must be 18 or older # Incoming untrusted JSON data raw_input = { "username" : "alice_dev" , "email" : "alice@example.com" , "age" : "25" } # Pydantic validates and coerces data types automatically user = UserRegistration ( ** raw_input ) print ( user . age )   # Output: 25 (converted from string to int) Application settings To work with an app config that automatically read from DATABASE_URL and REDIS_URL environment variables. Pre-req, you need to install  uv add pydantic_set...

python using orjson to work with json

orjson is a json library that is fast and getting popular.  Here are example code to work with same data  import orjson from dataclasses import dataclass from datetime import datetime @ dataclass class User :     id : int     name : str     created_at : datetime user = User ( id = 1 , name = "Alice" , created_at = datetime . now ()) # --- SERIALIZATION (Python Object -> JSON bytes) --- json_bytes = orjson . dumps ( user ) print ( json_bytes ) # Output: b'{"id":1,"name":"Alice","created_at":"2026-10-04T15:12:00+00:00"}' # --- DESERIALIZATION (JSON bytes/str -> Python Dict) --- data = orjson . loads ( json_bytes ) print ( data ) # Output: {'id': 1, 'name': 'Alice', 'created_at': '2026-10-04T15:12:00+00:00'} print(data['id']) # output 1

python async library - recommended way to wait for task completion

When using async library, it is always good to use TaskGroup to manage execution of different tasks where we use create_task to create async task.  import asyncio import time async def worker ( task_id : int , delay : int ):     print ( f "Task { task_id } started (sleeping { delay } s)..." )     await asyncio . sleep ( delay )     print ( f "Task { task_id } finished after { delay } s!" )     return f "Result { task_id } " async def main ():     start_time = time . time ()         # TaskGroup manages execution and waits until all tasks finish     async with asyncio . TaskGroup () as tg :         t1 = tg . create_task ( worker ( 1 , 1 ))         t2 = tg . create_task ( worker ( 2 , 2 ))         t3 = tg . create_task ( worker ( 3 , 10 ))         # All tasks are guaranteed complete after exiting the contex...

adk getting it to deploy to google agentic platform - errors

Image
I was trying to deploy using this command and pretty sure agentic platform is available here in Australia South East 2 (Melbourne) and I wasn't try to deploy to Sydney.  uv run adk deploy agent_engine agent_togo --project="project-015f2405-16e7-4b36-996" --region="australia-southeast2" Bump into this error when trying to deploy my adk sample app to google agentic platform.  To be fair, I didn't have my gcloud cli setup on my laptop. So I fixed that with  gcloud auth application-default login Deploy failed: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'}) Then bump into this error which is a generic error. And that drove me to check Log Explorer to find out more details Deploy failed: Failed to create Agent Engine: {'code': 10, 'message': 'Please refer to our troubleshooting pages (e.g., https://docs.cloud.google.com/gemini-enterprise-agent-platform/troub...

gcloud cli - getting, setting and working with projects

  You can get the info and listing of your proect using the following command  To show your local config gcloud config list To list project gcloud projects list To set project Id gcloud config set project PROJECT_ID  To set and configure billing quota gcloud config set billing/quota_project YOUR_REAL_PROJECT_ID  

commander using Qwen3.8-2B-Distill-GGUF model

Image
This is my main.py which uses the  Qwen3.8-2B-Distill-GGUF model. And the instruction is pretty much the same as previous model how ever, it does not seems to 'want' to read from start until end.  And because of that, the results is not so accurate.  """Have the model READ a README, detect its runtime, and extract the commands. Then start a matching container, run each command in it, and stop it. Usage:     python run_agent.py path/to/README.md """ import argparse import asyncio import inspect import json import re import shlex from pathlib import Path from dotenv import load_dotenv from google . adk . agents import LlmAgent from google . adk . runners import Runner from google . adk . sessions import InMemorySessionService from google . genai import types from pydantic import BaseModel , Field load_dotenv () # Reuse the same model your commander agent uses. from app . agent import root_agent   # ASSUMPTION: plain fu...