Skip to content

Instantly share code, notes, and snippets.

View capableguptadotcom's full-sized avatar
🏠
Working from home

Saksham Gupta capableguptadotcom

🏠
Working from home
View GitHub Profile
import json
import subprocess
from openai import OpenAI
# Initialize OpenAI client
client = OpenAI()
# Custom tool: Format Python code using Black
def format_code(code: str) -> dict:
try:
@capableguptadotcom
capableguptadotcom / column_descriptions.py
Last active February 25, 2025 16:41
Column & Table Description
1. Core Components to Include
Incorporate these elements for each column (prioritize clarity and conciseness):
A. Purpose (1–2 Sentences)
What does the column represent? Use plain language, not technical jargon.
Contextualize its role in the table.
Example:
"The order_status column indicates the current state of an order in the fulfillment process (e.g., pending, shipped, canceled). It is updated in real-time as the order progresses."
@capableguptadotcom
capableguptadotcom / profiling.py
Last active February 17, 2025 19:03
profiles data of sql tables
from pyspark.sql import SparkSession
from pyspark.sql.functions import col, count, countDistinct, regexp_extract
from pyspark.sql.types import (
StructType, StructField, StringType, BooleanType, ArrayType, LongType, DoubleType
)
# Initialize Spark session
spark = SparkSession.builder.appName("MetadataExtractor").getOrCreate()
# JDBC configuration for MS SQL Server (update with your connection details)
@capableguptadotcom
capableguptadotcom / summarize_and_split.py
Created January 27, 2025 07:05
Generate Summaries and Splitting File
Step-by-Step Instructions for Summarizing PDF Chunks for Improved Citation Retrieval and Query Similarity
Objective:
Create concise summaries of large PDF text chunks that retain critical information for both human readability and effective similarity matching during query retrieval.
Optimize Summaries for Query Similarity
Why: Ensure summaries retain terms/queries users might search for.
Steps:
Keyword Extraction:
@capableguptadotcom
capableguptadotcom / sql.py
Created November 13, 2024 13:56
highlight sql code in databricks
# Define your SQL query
sql_query = """
SELECT name, age, salary
FROM employees
WHERE department = 'Sales'
ORDER BY salary DESC;
"""
# Define the explanation for the SQL query
explanation = "This query selects the names, ages, and salaries of all employees in the Sales department and orders them by their salaries in descending order."
@capableguptadotcom
capableguptadotcom / test_multi_function_yield.py
Created November 11, 2024 04:29
yield the output as function is completed (asyncio) & stream it to ui
"""working code
- have to check the code on the ui side , what format are we getting
"""
import asyncio
from fastapi import FastAPI, Response
from fastapi.responses import StreamingResponse
import json
app = FastAPI()
@capableguptadotcom
capableguptadotcom / binary tree.py
Last active May 23, 2024 07:46
Audio File Processing
# Define Node Class
class Node:
def __init__(self, key, value):
self.key = key
self.value = value
self.left = None
self.right = None
# Define Binary Index Tree Class
class BinaryTree: