Posts

Quickstart with laya

Image
To get started with laya.  Laya is a free, open-source AI model designed for fast, focused text classification. It makes simple decisions—such as routing emails, prioritising tickets, or identifying refund requests—by choosing from predefined options and providing a confidence score. In short: Laya is built for fast, low-cost AI decisions rather than generating text. To get started, we have to install laya and creating your python environment. Next we going to use it to decide if the ticket belongs to which department. This is an approach where it uses the model with your local computing resources. import laya from laya import Router # Initialize router with preloading (avoids swap delay) router = Router ( preload = True ) # Define complex state ticket = {     "ticket_id" : "TCK-8821" ,     "customer" : "enterprise_user" ,     "subject" : "System downtime and billing dispute" ,     "body" : "Our product...

keycloak setting up mcp cimd profile

Image
In this example, we will be setting up our mcp authentication using Keycloak CIMD using vscode desktop.  Let's get our keycloak instance up and running.  docker run -p 8080:8080 -e KC_FEATURES=cimd -e KC_BOOTSTRAP_ADMIN_USERNAME=admin -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:latest start-dev Then setup follow these steps here to configure vscode desktop Setting up the client profile for VS Code desktop Navigate to Realm Settings → Client Policies → Profiles tab. Click Create client profile . Give the profile a name such as vscode-cimd-profile and click Save . Click Add executor and select client-id-metadata-document from the list. Configure the executor with the following options: Allow http scheme : OFF Trusted domains : vscode.dev , 127.0.0.1 , code.visualstudio.com (This option is applied not only to the client_id URL but also to the URL-valued properties of the Client ID Metadata Document, such as client_uri , logo_uri , tos_uri , policy_...

Google ADK creating custom tool

  Creating a custom tool with Google ADK is pretty much the same defining a normal python function.  Here is an example code:- As you can see from the code here get_weather_report() is a custom tool that we can define and wrap it around with FunctionTool.   import asyncio from google . adk . agents import Agent from google . adk . tools import FunctionTool from google . adk . runners import Runner from google . adk . sessions import InMemorySessionService from google . genai import types APP_NAME = "weather_sentiment_agent" USER_ID = "user1234" SESSION_ID = "1234" MODEL_ID = "gemini-2.0-flash" # Tool 1 def get_weather_report ( city : str ) -> dict :     """Retrieves the current weather report for a specified city.     Returns:         dict: A dictionary containing the weather information with a 'status' key ('success' or 'error') and a 'report' key with the weather details if succ...

AggregatedValue is a reserved word in Application Insights

Apparently claude model like to use aggregatedValue as a variable name when creating an alert in Application Insights. After reviewing the code, found out that it is not a good idea  at all.  https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-create-log-alert-rule#configure-alert-rule-conditions

google adk with local llm agent

Image
 We all wanted our agent to be running 24 hours a day to boost productivity and that normally requires a local LLM. agent. Today we are going to look into setting Qwen3.8 local model using unsloth studio.  First we get unsloth (under the hood it is using llama.cpp) and generate an API token. Then we will proceed to create python env and setup our packages.  uv venv uv init uv add google-adk litellm litert-llm ollama openai Lets' go and create your app name by running the command below :- adk create app  This will create a directory and some basic scaffolding files   Next we will update agent.py with the following code :- from google . adk . agents . llm_agent import LlmAgent from google . adk . models . lite_llm import LiteLlm # Create a LiteLLM model pointing to your local server model = LiteLlm (     model = "openai/empero-ai/Qwen3.8-2B-Distill-GGUF" ,     api_base = "http://localhost:8888/v1" ,   # Your local server   ...

AWS Bedrock agentcore vs harness coding perspective

In bedrock agentcore, we have harness and runtime. We going to look at the code differences trying to invoke them. Whenever possible, ry to use 'bedrock-agentcore' as it is the newer package  atleast for now. Older library typically uses bedrock-agent-runtime . https://docs.aws.amazon.com/boto3/latest/reference/services/bedrock-agent-runtime.html Harness Notice that everything is the same except we need to update harnessArn and we invoke the method invoke_harness(). Notice we are instantiating 'bedrick-agentcore'. There's also a client called 'bedrock-agent-runtime. And when you see the word harness - you know you're in a good seat. :) import boto3 import json import uuid client = boto3.client( 'bedrock-agentcore' , region_name = 'ap-southeast-2' ) session_id = str (uuid.uuid4()) response = client.invoke_harness(     harnessArn = 'your-harness-arn' ,     runtimeSessionId = session_id,     messages = [         {     ...

aws bedrock runtime that integrates with your knowledge based

Image
 First of all we need to setup our knowledge base as shown here where we can specify the source of our knowledge.  Once we created it, we can referenced it in our code, next.  And these are the code that we can use to harness our knowledge base.  import boto3 client = boto3 . client ( "bedrock-agent-runtime" , region_name = "ap-southeast-2" ) # AgenticRetrieveStream - streaming, agent-driven multi-step retrieval response = client .agentic_retrieve_stream(     messages = [{ "role" : "user" , "content" : { "text" : "your query here" }}],     retrievers = [{ "configuration" : { "knowledgeBase" : { "knowledgeBaseId" : "YOUR-KNOWLEDGE-BASE-ID" }}}],     agenticRetrieveConfiguration = { "foundationModelType" : "MANAGED" , "maxAgentIteration" : 5 },     generateResponse = True , ) for event in response [ "stream" ]:     if "respons...

bedrock agentcore runtime getting started

Image
 Amazon Bedrock AgentCore Runtime is the serverless infrastructure layer that hosts custom agent code, pay for what you use while AgentCore Harness is a fully managed orchestration layer running on top of that runtime that builds the agent loop for you through simple configuration. Harness created runs and you will be billed for how long it is running. To get started with AgentCore runtime, we need to install it npm install -g @aws/agentcore agentcore --version Next, we will run the following in the root directory of the project (it must be in the root directory) :-  agentcore create --project-name MyTsAgent --no-agent cd MyTsAgent agentcore add agent --name TsAgent --type create --build CodeZip --language Python --framework Strands --model-provider Bedrock --memory none And to deploy it  agentcore deploy And we can see it in the console too To test it out  agentcore invoke "Tell me a joke" Or you can invoke it wth code :- import boto3 import json client = boto3.c...

azure application insights static metrics does not exsit trick

Remember when you're trying to create a static mertric ( azurerm_monitor_metric_aler t ), get it into terraform and when you deploy it, it failed because it does not exist in production. These metrics are not being sent into application insights via otel collector.  How do you get the metric setup in terraform? Instead of using the one above, we can use azurerm_monitor_scheduled_query_rules_alert to sett up the query instead.  Craft that in a way that even if the metric does not exist, we are still good. Then we can avoid this error when deployment to PROD.  

AWS Gateway API with REST API And Lambda setup

Image
To setup gateway API for your REST API, click on "Create API". Then click on "Build" Next, you will be prompted for these. Select "New API" and then TLS 1.3.  And then use default settings and click on "Create API". Then you click on "Create Method". Amd we will configure to point this service to our lamda function. Please ensure you have a lambda ready to go and then click " Create ".  You can easily test it out by clicking on "Test"  AWS gateway has this concept called Stage that basic define a REST API path, for example my server  https//myhost/dev and https//myhost/test   And let's say you created your REST API which has a path /hello then you references it via  https//myhost/dev/hello  and https//myhost/test/hello Here dev and test are called stage and that's where you need to deploy your application. API Key You can configure your REST API to ask for an API key  You can also add extra RESPONSE HEADER....

AWS Bedrock configuring intelligent prompt router

Image
We want to use bedrock intelligent prompt routing because we can send prompts to different foundational models within a model family, helping you optimize for quality of responses and cost. To do that,  goto "Prompt routing model".  Depending on the region, we are limited to AWS Nova and Llama.  Provide a name for your prompt router and then select relevant models. These are the list of models that your requested gets routed to. In this scenario, we are routing to Llama.   We also need to select a default route model, that will handle all responses if it is unable to determine where to route prompts to.  Click "Submt" when ready You can test it out by, click on "Action" ->  Open in playground If you want to access from "playground", you can do the following. Goto Playground -> Select Router under Categories. Then select your newly created routers.