Skip to content

Instantly share code, notes, and snippets.

View madhurprash's full-sized avatar

Madhur Prashant madhurprash

View GitHub Profile
@madhurprash
madhurprash / generate_meeting_minutes_synthetic.ipynb
Created April 9, 2025 16:30
This gist generates synthetic meeting minutes, summary and counts the tokens for each. This generates a JSONL file with the meeting minutes, summaries, and token metrics.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@madhurprash
madhurprash / list_s3_uris_in_kb
Created April 2, 2025 17:15
This gist helps get insights into s3 uri's that the knowledge base has ingested as a part of its data s
import boto3
import json
from typing import Dict, List, Optional
import re
def get_detailed_s3_uris(
knowledge_base_id: str,
data_source_id: str
) -> Dict:
"""
@madhurprash
madhurprash / move_folders_within_s3
Created April 2, 2025 16:15
This gist moves folders from within the same s3 bucket to another using pythons asyncio functionality
import os
import shutil
import concurrent.futures
import boto3
from pathlib import Path
import logging
import time
def move_folders_to_combined(bucket_name, folders_to_move=["SSE", "FPA", "Hypershield"], log_level=logging.INFO):
"""
@madhurprash
madhurprash / qrcode_generator.py
Created December 11, 2024 15:33
This gist takes in a list of links and generates QRCodes for those links.
import qrcode
import logging
import re
import os
# Install the following package before running the script: pip install qrcode
# set a logger
logging.basicConfig(
format='[%(asctime)s] p%(process)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',
@madhurprash
madhurprash / sagemaker_mlflow_simple_example.ipynb
Created November 13, 2024 17:37
In this gist, we do the following: Set up `mlflow` tracking with the SageMaker tracking server, create a simple classification experiment and use MLFlow to input logs, metrics, parameters and model with simple API calls.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@madhurprash
madhurprash / github_issues_in_csv.py
Created September 17, 2024 18:41
This gist converts github issues into csv that can be imported into Asana for sprint planning
import os
import csv
import logging
import requests
from datetime import datetime
from typing import Optional, List
logging.basicConfig(format='[%(asctime)s] p%(process)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
@madhurprash
madhurprash / deploy_and_predict_hf_model_djl.ipynb
Last active August 8, 2024 01:58
Deploys a model from HuggingFace on Amazon SageMaker using the DJL DeepSpeed LMI (https://github.com/deepjavalibrary/djl-serving).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@madhurprash
madhurprash / claude_3_metadata_tagger.txt
Last active June 7, 2024 19:59
Claude 3 metadata tagger
Human: you are a metadata tagger, see the following schema and tag the data that follows to extract the metadata fields listed in the schema:
<schema>
schema = {
"properties": {
"movie_title": { "type": "string" },
"critic": { "type": "string" },
"tone": {
"type": "string",
"enum": ["positive", "negative"]
@madhurprash
madhurprash / retrieve_modelconfig_jumpstart.py
Last active February 16, 2024 17:11
Retrieve SageMaker JumpStart Models' Configurations
"""
Get information about models in Amazon SageMaker JumpStart.
Tested with sagemaker SDK version 2.203.0.
"""
## View the full list of models available through JumpStart here: https://sagemaker.readthedocs.io/en/stable/doc_utils/pretrainedmodels.html
import pandas as pd
from typing import Dict, List
from sagemaker import get_execution_role
@madhurprash
madhurprash / gist:19558e9a947e15584a63e49b206bc0fd
Created January 12, 2024 13:59
Call Bedrock Models via REST API
import json
import botocore.session
import requests as req
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
# Configuration and payload
region = "us-east-1"
model_id = 'cohere.command-text-v14'
endpoint = f"https://bedrock-runtime.{region}.amazonaws.com/model/{model_id}/invoke"