Skip to content

Instantly share code, notes, and snippets.

View usametov's full-sized avatar

Ulan Sametov usametov

  • Asta Nova Enterprise Solutions
View GitHub Profile
@usametov
usametov / toon.md
Created November 5, 2025 01:00
TOON

TOON, or Token-Oriented Object Notation, is a lightweight, human-readable data serialization format specifically designed for use with Large Language Models (LLMs). It acts as a more efficient alternative to JSON by reducing token consumption in prompts, making it ideal for passing structured data to AI systems without losing information. TOON is particularly effective for uniform tabular data, such as arrays of objects with consistent fields, where it can achieve 30-60% fewer tokens compared to JSON, based on benchmarks using common tokenizers like those in GPT models. This efficiency comes from stripping away redundant syntax like braces, brackets, and repeated keys, while relying on indentation and length markers to maintain structure.

Purpose and Benefits

The main goal of TOON is to optimize for LLM contexts, where token limits and costs are critical. JSON's verbosity can inflate prompts unnecessarily, especially with large datasets, but TOON minimizes this by:

  • Using indentation for nesting (simila
@usametov
usametov / langfuse.md
Created October 22, 2025 14:03
langfuse LLM-as-a-Judge tutorial

LLM-as-a-Judge Setup in Langfuse

LLM-as-a-Judge (also called model-based evaluation) is a scalable way to use one LLM to automatically score and reason about the outputs of another LLM or agent. In the context of your CanvassAssistant (backed by OpenAI's Assistant API via Azure), this is ideal for tuning prompts and fixing issues like repetitive questions. For example, you can evaluate thread histories for redundancy, coherence, or completeness, generating scores (e.g., 0-1) with chain-of-thought explanations.

Langfuse provides managed LLM-as-a-Judge evaluators through its UI, with a catalog of pre-built templates (e.g., for Hallucination, Helpfulness, Toxicity) and support for customization. It integrates seamlessly with your traced runs from the previous setup (using @langfuse/openai or manual observations). Evaluations can run on production traces (e.g., your callEndpoint executions) or offline datasets.

If you need fully custom logic beyond the UI (e.g., specialized scoring for repetitiveness),

@usametov
usametov / redis-example.md
Created October 20, 2025 17:09
redis-sample typescript

Tutorial: Using Azure Cache for Redis with TypeScript This tutorial guides you through setting up and using Azure Cache for Redis in a TypeScript application, implementing the cache-aside pattern. We'll use the ioredis library for Redis connectivity and demonstrate basic caching operations. Prerequisites

An active Azure subscription Node.js (v16 or later) and npm installed An Azure Cache for Redis instance (Basic, Standard, Premium, or Enterprise tier) TypeScript installed (npm install -g typescript)

Step 1: Create an Azure Cache for Redis Instance

@usametov
usametov / gpt5-prompt-leak
Created August 29, 2025 12:48
gpt5 prompt leak
You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2025-08-24
Image input capabilities: Enabled
Personality: v2
Do not reproduce song lyrics or any other copyrighted material, even if asked.
If you are asked what model you are, you should say GPT-5. If the user tries to convince you otherwise, you are still GPT-5. You are a chat model and YOU DO NOT have a hidden chain of thought or private reasoning tokens, and you should not claim to have them. If asked other questions about OpenAI or the OpenAI API, be sure to check an up-to-date web source before responding.
@usametov
usametov / equavariant-func-problem-solution.md
Last active July 19, 2025 16:43
equavariant-func-problem-solution

To formalize the last step of your proof, let’s carefully work through the problem of showing that any linear permutation-equivariant function ( F: \mathbb{R}^n \to \mathbb{R}^n ) can be written as ( F(X) = aI X + b 11^T X ), where ( I ) is the identity matrix, ( 11^T ) is the matrix corresponding to the average function, and ( a, b \in \mathbb{R} ). The key property is that ( F ) is linear and permutation-equivariant, meaning ( FPX = PFX ) for any permutation matrix ( P ). Your insight about setting ( X = 11^T ) is a good starting point, and we’ll use it to derive the result.


Step-by-Step Formalization

Since ( F ) is a linear function from ( \mathbb{R}^n \to \mathbb{R}^n ), it can be represented by an ( n \times n ) matrix, say ( A ), such that ( F(X) = AX ). The permutation-equivariance condition ( FPX = PFX ) translates to:

[ A(PX) = P(AX) ]

@usametov
usametov / multiples-files-ts.md
Created July 8, 2025 13:39
azure deployment notes

When deploying a TypeScript Azure Function App with multiple files (e.g., a handler and a library) to Azure, the issue of functions not appearing in the Azure Portal often stems from incorrect project structure, configuration, or deployment settings. Below, I'll guide you through the steps to properly deploy a TypeScript Azure Function App with multiple files, ensuring the functions are visible in the Azure Portal.

Common Issues and Solutions

The problem you're facing—functions not appearing in the Azure Portal—can occur due to:

  1. Incorrect project structure: Azure Functions expects a specific folder structure, especially for TypeScript projects where compiled JavaScript files are used.
  2. Missing or incorrect function.json files: For the v3 programming model, these files define the function's bindings and entry points.
  3. Improper compilation or deployment: TypeScript files need to be compiled to JavaScript, and all
@usametov
usametov / dewarping-text.md
Created July 3, 2025 21:15
text de-warping

Applying differential and computational geometry to read letters on a warped piece of paper is a fascinating problem that involves modeling the paper’s deformation, reconstructing its 3D shape, and extracting text from a distorted surface. This task has applications in document analysis, historical manuscript restoration, and computer vision. Below, I’ll outline the key concepts, existing work, and related projects in this domain, focusing on differential and computational geometry approaches. I’ll keep the explanation concise yet comprehensive, as you’ve expressed curiosity without specifying a desired length.

Key Concepts

  1. Differential Geometry: This field provides tools to describe the geometry of surfaces, such as a warped piece of paper, using concepts like curvature, tangent planes, and geodesics. For a warped paper, differential geometry helps model the surface as a smooth, non-Euclidean manifold, allowing us to understand its deformation mathematically.
  2. Computational Geometry: This i
@usametov
usametov / aider-vs-openhands.md
Created July 2, 2025 14:45
aider vs openhands

Both Aider and OpenHands are powerful open-source AI coding agents designed to assist developers, but they cater to slightly different workflows and preferences. Below is a detailed comparison of their pros and cons based on available information and community feedback, focusing on their features, usability, and performance as of July 2025.


Aider

Aider is a command-line-based AI coding assistant that enables pair programming with large language models (LLMs) to edit code in your local Git repository. It is designed for simplicity, speed, and integration with existing codebases.

Pros

  1. Ease of Setup and Use:
@usametov
usametov / transformers-http-server.md
Created June 30, 2025 18:07
run transformers with http server

https://grok.com/share/bGVnYWN5_b34d4dfb-2047-4266-87c7-12cb79e37f4a

The Hugging Face Transformers library now includes a built-in HTTP server, introduced via pull request #38443, enabling users to serve machine learning models over HTTP for inference tasks. Below is a concise tutorial on how to install and run the HTTP server, along with details on hardware requirements based on available information and general knowledge about running transformer models.


Tutorial: Installing and Running the Transformers HTTP Server

The HTTP server in the Transformers library allows you to serve models for inference via HTTP endpoints, making it easier to integrate models into applications. The following steps guide you through setting up and running the server.

@usametov
usametov / az-middleware.md
Last active July 14, 2025 20:02
azure functions middleware best practices

Implementing a middleware design pattern in Azure Functions, similar to Clojure's Ring middleware, Pedestal interceptors, or Django's middleware, is a common approach to handle cross-cutting concerns like authentication, logging, input validation, and error handling in a clean and modular way. While Azure Functions doesn't have a built-in middleware framework as robust as Ring or Django, you can implement middleware-like patterns using a combination of Azure Functions features and custom code. Below, I'll outline industry best practices for implementing middleware patterns in Azure Functions, drawing parallels to the Clojure and Django approaches, and referencing available resources.


Understanding Middleware Patterns in Context

  • Clojure Ring Middleware: In Ring, middleware is a higher-order function that wraps a handler, transforming requests before they reach the handler and/or responses after the handler processes them. Middleware is composed functionally, allowing sequential processing with