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 LegalHallucinationAnalysis = z.object({ | |
// Case identification | |
case_id: z.string(), | |
case_name: z.string(), | |
date_occurred: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), | |
ai_model_used: z.string(), | |
source_url: z.string().url().optional(), | |
// Hallucination details | |
hallucination_details: z.object({ |
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 { createAnthropic } from "@ai-sdk/anthropic" | |
// import { createGroq } from "@ai-sdk/groq" | |
// import { createGoogleGenerativeAI } from "@ai-sdk/google" | |
import { createOpenAI } from '@ai-sdk/openai'; | |
import { createAiGateway } from '../../packages/ai-gateway-provider/src/index.js'; | |
import { generateText } from 'ai'; | |
export default { | |
async fetch() { | |
const originalFetch = fetch; |
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 { CloudClient } from 'chromadb'; | |
import {createOpenAI} from "@ai-sdk/openai" | |
export default { | |
async fetch(request, env, ctx): Promise<Response> { | |
const openai = createOpenAI({ | |
apiKey: "sk-proj-" | |
}) | |
const model = openai.textEmbeddingModel("text-embedding-3-small") |
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 { | |
type AgentNamespace, | |
type Connection, | |
routeAgentRequest, | |
type Agent, | |
type Schedule, | |
} from "agents-sdk"; | |
import { AIChatAgent } from "agents-sdk/ai-chat-agent"; | |
import { | |
createDataStreamResponse, |
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 torch | |
import re | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
from typing import List, Dict, Tuple | |
from tqdm import tqdm | |
class InfiniRetri: | |
def __init__(self, model_name, chunk_size=512, top_k=50, phrase_window=5, device=None): | |
self.chunk_size = chunk_size | |
self.top_k = top_k |
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 { type NextApiRequest, type NextApiResponse } from 'next'; | |
import Ffmpeg from 'fluent-ffmpeg'; | |
export default function handler(req: NextApiRequest, res: NextApiResponse) { | |
if (req.method === 'GET') { | |
// Set response headers | |
res.setHeader('Content-Type', 'video/mp4'); | |
res.setHeader('Connection', 'keep-alive'); | |
res.setHeader('Accept-Ranges', 'bytes'); |
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 { createToolsFromOpenAPISpec, runWithTools } from "@cloudflare/ai-utils"; | |
export default { | |
async fetch(request, env, ctx) { | |
const response = (await runWithTools( | |
env.AI, | |
"@hf/nousresearch/hermes-2-pro-mistral-7b", | |
{ | |
messages: [ | |
{ |
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
await runWithTools(env.AI, "@hf/nousresearch/hermes-2-pro-mistral-7b", { | |
messages: [ | |
{ role: "system", content: "Put user given values in KV" }, | |
{ role: "user", content: prompt }, | |
], | |
tools: [ | |
{ | |
name: "KV update", | |
description: "Update a key-value pair in the database", | |
parameters: { |
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
let tweets = []; // Initialize an empty array to hold all tweet elements | |
const scrollInterval = 1000; | |
const scrollStep = 5000; // Pixels to scroll on each step | |
let previousTweetCount = 0; | |
let unchangedCount = 0; | |
const scrollToEndIntervalID = setInterval(() => { | |
window.scrollBy(0, scrollStep); |
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 rich import print | |
import time | |
FORBIDDEN_CHARS = ["⍼", "⳧"] | |
text= "really really really long text that has a lot of repeating stuff so that it can be coompressed" | |
def find_all_non_overlapping_repeating_substrings(text: str): | |
text = (text + ' ') if text[-1] != ' ' else text |
NewerOlder