Posts

ADK input and output for llm function call using Gemini model

When it comes to tool calling, it can quickly get complicated - as tool calling can behave quite differently for different models, how do you pass those response back to the LLM model so that it can be used.  If we were to use a 2 billion paramater smaller model, those tool calling cane challenging. Having said that, it is worth look behind the scene how tool happens - what is the input and output when using it with Google ADK  This is what an input to the model using Google ADK looks like using Gemini-2.5-flash model='gemini -2.5 -flash' contents=[ Content(   parts= [     Part(       text='What is my account balance including pending charges for user_ 123 ?'     ) ,   ],   role='user' ) ] config=GenerateContentConfig(   system_instruction= """You are a helpful customer support agent. Answer questions concisely. You are an agent. Your internal name is " account_assistant ".""" ,   tools=[     Tool( ...

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...