Please note we have a code of conduct, please follow it in all your interactions with the project.
Branch names should be
function getRandomElement(arr) { | |
if (!Array.isArray(arr) || arr.length === 0) { | |
throw new Error('The input must be a non-empty array.'); | |
} | |
const randomIndex = Math.floor(Math.random() * arr.length); | |
return arr[randomIndex]; | |
} | |
const items = $input.all(); |
from typing import Any, List, Mapping, Optional | |
# pip install httpx langchain | |
import httpx | |
from langchain.callbacks.manager import CallbackManagerForLLMRun | |
from langchain_core.language_models.llms import LLM | |
class LlamaCppServer(LLM): | |
'''Use Llama.cpp's builtin server to remotely host an LLM for use with Langchain''' |
from pathlib import Path | |
from modal import Image, Mount, Stub, asgi_app, gpu, method | |
from pydantic import BaseModel | |
def download_models(): | |
from huggingface_hub import snapshot_download | |
ignore = ["*.bin", "*.onnx_data", "*/diffusion_pytorch_model.safetensors"] |
#!/bin/bash | |
# This script squashes a git repo into a single commit with a specified commit message | |
# Check if git is installed | |
if ! git --version 1>/dev/null 2>&1; then | |
echo "Error: git is not installed. Please install git and try again." | |
exit 1 | |
fi |
// LICENSE: https://chand1012.mit-license.org | |
const fetchWithTimeout = (url: string, options: RequestInit, timeout: number = 10000): Promise<any> => { | |
return new Promise(async (resolve, reject) => { | |
const controller = new AbortController(); | |
const signal = controller.signal; | |
const timer = setTimeout(() => { | |
controller.abort(); | |
reject(new Error("Request timed out")); | |
}, timeout); |
const endpoint = (key: string) => { | |
const accountID = Deno.env.get("WORKERS_KV_ACCOUNT_ID"); | |
const namespaceID = Deno.env.get("WORKERS_KV_NAMESPACE_ID"); | |
return `https://api.cloudflare.com/client/v4/accounts/${accountID}/storage/kv/namespaces/${namespaceID}/values/${key}` | |
}; | |
export const set = async (key: string, value: string, ttl: number = 0, expiration: number = 0) => { | |
const { success, result, errors } = await fetch(`https://api.cloudflare.com/client/v4/accounts/${Deno.env.get("WORKERS_KV_ACCOUNT_ID")}/storage/kv/namespaces/${Deno.env.get("WORKERS_KV_NAMESPACE_ID")}/bulk`, { | |
method: "PUT", |
import os | |
import requests | |
def endpoint(key): | |
accountID = os.getenv("WORKERS_KV_ACCOUNT_ID") | |
namespaceID = os.getenv("WORKERS_KV_NAMESPACE_ID") | |
return f"https://api.cloudflare.com/client/v4/accounts/{accountID}/storage/kv/namespaces/{namespaceID}/values/{key}" | |
def set(key, value, ttl=0, expiration=0): | |
headers = { |
// info https://giuseppegurgone.com/vercel-cloudflare-kv | |
// api docs https://developers.cloudflare.com/api/operations/workers-kv-namespace-write-multiple-key-value-pairs | |
const endpoint = (key: string) => { | |
const accountID = process.env.WORKERS_KV_ACCOUNT_ID; | |
const namespaceID = process.env.WORKERS_KV_NAMESPACE_ID; | |
return `https://api.cloudflare.com/client/v4/accounts/${accountID}/storage/kv/namespaces/${namespaceID}/values/${key}` | |
}; | |
export const set = async (key: string, value: string, ttl: number = 0, expiration: number = 0) => { |
import os | |
import json | |
from pymongo import MongoClient | |
import pymysql | |
from dotenv import load_dotenv | |
# Load environment variables | |
load_dotenv() |