Skip to content

Instantly share code, notes, and snippets.

@goofansu
goofansu / client_with_guardrails.py
Last active December 9, 2024 06:39
Use Guardrails AI with OpenRouter (you need to set OPENAI_API_KEY environment variable to the OpenRouter API key)
import os
from openai import OpenAI
client = OpenAI(
base_url='http://127.0.0.1:8000/guards/my-first-guard/openai/v1',
)
response = client.chat.completions.create(
model="openrouter/anthropic/claude-3-5-haiku",
messages=[{

ogp

Mix.install([
  {:kino, "~> 0.6.1"},
  {:ogp, "~> 1.0"}
])
@goofansu
goofansu / app.js
Last active August 5, 2023 04:05
LiveView upload directly to AWS China S3
let Uploaders = {}
Uploaders.S3 = function (entries, onViewError) {
entries.forEach(entry => {
let xhr = new XMLHttpRequest()
onViewError(() => xhr.abort())
xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error())
xhr.onerror = () => entry.error()
xhr.upload.addEventListener("progress", event => {
if (event.lengthComputable) {