This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from typing import Type, TypeVar, Callable, Any | |
from pydantic import BaseModel | |
from openai import OpenAI | |
T = TypeVar('T', bound=BaseModel) | |
def openai_call(_model: str, response_model: Type[T]) -> Callable: | |
""" | |
Decorator that handles OpenAI API calls using structured output parsing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pathlib import Path | |
from datetime import datetime | |
import logging | |
from typing import Optional | |
from dotenv import load_dotenv | |
from moviepy.editor import VideoFileClip | |
import httpx | |
from deepgram import ( | |
DeepgramClient, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer-extra'); | |
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); | |
const fs = require('fs').promises; | |
const path = require('path'); | |
const { URL } = require('url'); | |
const crypto = require('crypto'); | |
const argparse = require('argparse'); | |
puppeteer.use(StealthPlugin()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Interface Definition | |
interface RateLimitOptions { | |
identifier: string; // e.g., IP address or user ID | |
points: number; // max number of requests | |
duration: number; // time window in seconds | |
} | |
// 2. Core Rate Limit Check Function | |
export const checkRateLimit = async ({ | |
identifier, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>AI Chatbot Cost Calculator</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
line-height: 1.6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
from sqlalchemy import create_engine, inspect | |
from sqlalchemy.exc import SQLAlchemyError | |
from sqlalchemy import text | |
import re | |
import json | |
class LLMSQLQueryEngine: | |
def __init__(self, db_path): | |
self.engine = create_engine(f'sqlite:///{db_path}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check for required arguments | |
if [ $# -lt 2 ]; then | |
echo "Usage: $0 <directory> <delimiter> [--include=<pattern>] [--exclude=<pattern>]" | |
exit 1 | |
fi | |
# Assign the first argument as the directory | |
DIRECTORY=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI, HTTPException | |
from pydantic import BaseModel | |
from typing import List, Optional, Dict | |
import faiss | |
import numpy as np | |
import os | |
app = FastAPI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
import os | |
from dotenv import load_dotenv | |
# Load environment variables | |
load_dotenv() | |
API_KEY = os.getenv("ANTHROPIC_API_KEY") | |
API_URL = "https://api.anthropic.com/v1/messages" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
from pydub import AudioSegment | |
from groq import Groq | |
import argparse | |
# Initialize the Groq client | |
client = Groq() | |
def convert_video_to_audio(video_path, audio_path): |
NewerOlder