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
#!/usr/local/bin/python3.12 | |
# -*- coding: utf-8 -*- | |
import re | |
import sys | |
# LiteLLM doesn't support DefaultAzureCredential and get_bearer_token_provider | |
# There has been a discussion on the subject but no clear path forward: | |
# See https://github.com/BerriAI/litellm/issues/4417 | |
# This monkey patches LiteLLM to force it to use the DefaultAzureCredential and get_bearer_token_provider |
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 | |
dedup_env() { | |
local -A env_ary | |
while IFS== read -r key value; do | |
value=$(echo "$value" | sed 's/^ *"//' | sed 's/" *$//') | |
env_ary[$key]=$value | |
done <<EOM | |
$(cat $*) | |
EOM |
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
var deployments = [ | |
{ | |
name: 'text-embedding-ada-002' | |
format: 'OpenAI' | |
} | |
{ | |
name: 'llama' | |
format: 'serverless' | |
} | |
] |
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 typing import Any | |
def constant_hash(func): | |
""" | |
Wraps a function and changes its hashing behavior to a constant. | |
This allows Hugginface to only use functiona parameters for hashing and nothing else in | |
the function's captured context | |
""" | |
return ConstantHash(func) |
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
# Those endpoints don't use the usual Azure OpenAI scheme, they use the OpenAI scheme. | |
# They also take the model field to route to the proper deployment, but I haven't verified this works | |
# Tested with openai 1.13.3 | |
from openai import OpenAI | |
import logging | |
logging.basicConfig(level=logging.DEBUG, | |
format='%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s:%(lineno)d - %(message)s', |
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
# Generate a UUID5 from a name using SHA-256 | |
def uuid5_sha256(namespace, name): | |
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name.""" | |
if isinstance(name, str): | |
name = bytes(name, "utf-8") | |
from uuid import UUID | |
import hashlib | |
hash = hashlib.sha256(namespace.bytes + name).digest() | |
return UUID(bytes=hash[:16], version=5) |
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 yaml | |
import logging.config | |
import logging | |
import coloredlogs | |
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'): | |
""" | |
| **@author:** Prathyush SP | |
| Logging Setup |
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
use AppleScript version "2.4" | |
use framework "Foundation" | |
use scripting additions | |
# This script fixes timestamps of photos currently selected in OSX Photos application. | |
# It does so by reading a CSV file containing mappings from file names to timestamps. | |
# The user is requested to select the CSV file when running this script. | |
# Author: Cedric Vidal (https://vidal.biz) |
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
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html | |
# First of all you need to have a clean clone of the source repository so we didn't screw the things up. | |
git clone git://server.com/my-repo1.git | |
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command | |
git filter-branch --subdirectory-filter your_dir -- -- all | |
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command. |
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
^(?'remote'[a-zA-Z]+)\/(?'sub'[a-zA-Z]+\/)?(?'jira_project'[A-Z]+)-(?'jira_ticket'[0-9]+).*$ |
NewerOlder