This file contains hidden or 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
| def diciter(d, pad="", list_idx=0): | |
| for k, v in d.items(): | |
| if isinstance(v, str): | |
| print(f"{pad}KEY: {k} -> {v[:100]}") | |
| elif isinstance(v, int) or isinstance(v, float) or isinstance(v, bool): | |
| print(f"{pad}KEY: {k} -> {v}") | |
| elif isinstance(v, dict): | |
| print(f"{pad}KEY: {k} ") | |
| diciter(v, pad + " ") | |
| elif isinstance(v, list): |
This file contains hidden or 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
| #%pip install sentence_transformers | |
| #%pip install torch | |
| ########################### | |
| import os | |
| os.environ["TOKENIZERS_PARALLELISM"] = "true" | |
| import torch | |
| from sentence_transformers import SentenceTransformer |
This file contains hidden or 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 requests | |
| import os | |
| import time | |
| from urllib.parse import urlparse | |
| from cvs import cvs | |
| # Fake user agent to mimic a real browser | |
| headers = { |
This file contains hidden or 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
| #%pip install openai | |
| from openai import OpenAI | |
| import os | |
| import subprocess | |
| from pydub import AudioSegment | |
| import math | |
| client = OpenAI(api_key="sk-proj-XXX") |
This file contains hidden or 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 bcrypt = require('bcryptjs'); | |
| const CryptoJS = require('crypto-js'); | |
| // Generate a strong random password (16 characters, mix of letters, numbers, symbols) | |
| const strongPassword = 'my!!!strong!!password!'; | |
| console.log('Strong password:', strongPassword); | |
| // Generate bcrypt hash | |
| const passwordHash = bcrypt.hashSync(strongPassword, 12); | |
| console.log('Password hash:', passwordHash); |
This file contains hidden or 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 mapStyle = `https://api.maptiler.com/maps/dataviz/style.json?key=${apiKey}`; | |
| map.current = new maplibregl.Map({ | |
| container: mapContainer.current, | |
| style: mapStyle, | |
| center: [INITIAL_VIEW_STATE.longitude, INITIAL_VIEW_STATE.latitude], | |
| zoom: INITIAL_VIEW_STATE.zoom | |
| }); | |
| map.current.on('load', () => { |
This file contains hidden or 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 typing import List, Dict, Optional | |
| from utils import count_tokens, pdf_to_text_with_fonts_pdfplumber | |
| import logging | |
| # Configure logging for the chunker | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| logger = logging.getLogger(__name__) | |
| class FontAwareRecursiveChunker: | |
| """A recursive text chunker that uses font sizes to determine optimal split points. |
This file contains hidden or 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 enum | |
| class MimeType(str, enum.Enum): | |
| # Text documents | |
| TXT = "text/plain" | |
| PDF = "application/pdf" | |
| DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | |
| XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | |
| PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation" | |
This file contains hidden or 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 sys | |
| from datetime import datetime | |
| from cryptography.hazmat.primitives import hashes | |
| from cryptography.hazmat.primitives.asymmetric import rsa, padding | |
| from cryptography.exceptions import InvalidSignature | |
| from cryptography.hazmat.primitives import serialization | |
| def get_private_key(): |
This file contains hidden or 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 openai import OpenAI | |
| client = OpenAI(api_key='sk-proj-XXX') | |
| def gpt_request(prompt, model="gpt-4o-mini", max_tokens=100): | |
| try: | |
| response = client.chat.completions.create( | |
| model=model, | |
| messages=[{"role": "user", "content": prompt}], | |
| max_tokens=max_tokens, |
NewerOlder