Docs: Update benchmark for openrouter/bert-nebulon-alpha

This commit is contained in:
github-actions[bot]
2025-11-25 21:20:48 +00:00
parent 40160415c2
commit a175f18319
12 changed files with 333 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
const hashPassword = async (password, salt) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.min.js')
const encoder = new TextEncoder()
const passwordBytes = encoder.encode(password)
const saltBytes = encoder.encode(salt)
const hashBytes = await scrypt(passwordBytes, saltBytes, 1024, 8, 1, 32)
return Array.from(hashBytes)
.map(b => b.toString(16).padStart(2, '0'))
.join('')
}
export default hashPassword;

View File

@@ -0,0 +1,16 @@
export const analyzeGPS = async (readings, boundary) => {
const { default: turf } = await import('https://unpkg.com/@turf/turf@6/turf.min.js')
const inside = readings.filter(({ loc }) =>
turf.booleanPointInPolygon(turf.point(loc), boundary, { ignoreBoundary: false })
)
if (inside.length < 2) return 0
const sorted = inside.sort((a, b) => a.ts - b.ts)
const line = turf.lineString(sorted.map(({ loc }) => loc))
const length = turf.length(line, { units: 'kilometers' })
return Math.round(length * 100) / 100
}
export default analyzeGPS;

View File

@@ -0,0 +1,37 @@
const findShortestPath = async (graph, start, end) => {
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@1.0.0/+esm')
if (!graph[start] || !graph[end]) return Infinity
const distances = Object.keys(graph).reduce((acc, node) => {
acc[node] = node === start ? 0 : Infinity
return acc
}, {})
const pq = new PriorityQueue({ comparator: (a, b) => a.distance - b.distance })
pq.queue({ node: start, distance: 0 })
const visited = new Set()
while (pq.length) {
const { node, distance } = pq.dequeue()
if (node === end) return distance
if (visited.has(node)) continue
visited.add(node)
Object.entries(graph[node]).forEach(([neighbor, weight]) => {
if (visited.has(neighbor)) return
const newDistance = distance + weight
if (newDistance < distances[neighbor]) {
distances[neighbor] = newDistance
pq.queue({ node: neighbor, distance: newDistance })
}
})
}
return Infinity
}
export default findShortestPath;

View File

@@ -0,0 +1,38 @@
const findConvexHull = async points => {
const { sortBy, uniqWith, isEqual } = await import('https://cdn.skypack.dev/lodash')
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const preparePoints = pts => {
const unique = uniqWith(pts, isEqual)
return sortBy(unique, ['x', 'y'])
}
const buildHull = pts => {
const hull = []
for (const p of pts) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop()
}
hull.push(p)
}
const lowerHullSize = hull.length + 1
for (let i = pts.length - 1; i >= 0; i--) {
const p = pts[i]
while (hull.length >= lowerHullSize && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop()
}
hull.push(p)
}
hull.pop()
return hull
}
if (points.length < 3) return [...points]
const prepared = preparePoints(points)
return buildHull(prepared)
}
export default findConvexHull;

View File

@@ -0,0 +1,14 @@
const findLISLength = async (nums) => {
if (!nums.length) return 0
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const num of nums) {
const i = bisectLeft(tails, num)
tails[i] = num
}
return tails.length
}
export default findLISLength;

View File

@@ -0,0 +1,15 @@
const calculateDeterminant = async matrix => {
const { create } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.7.0/+esm')
const math = create()
if (!Array.isArray(matrix) || !matrix.every(Array.isArray)) {
throw new TypeError('Input must be an array of arrays')
}
if (matrix.length === 0 || matrix.some(row => row.length !== matrix.length)) {
throw new Error('Matrix must be square (n x n)')
}
return math.det(matrix)
}
export default calculateDeterminant;

View File

@@ -0,0 +1,15 @@
const parseMarkdown = async (markdown) => {
const { default: marked } = await import('https://cdn.jsdelivr.net/npm/marked@4.0.12/lib/marked.esm.js')
const { default: DOMPurify } = await import('https://cdn.jsdelivr.net/npm/dompurify@3.0.5/dist/purify.es.mjs')
marked.setOptions({
gfm: true,
breaks: true,
headerIds: false,
mangle: false
})
const html = marked.parse(markdown)
return DOMPurify.sanitize(html)
}
export default parseMarkdown;

View File

@@ -0,0 +1,25 @@
const processCSV = async (csvData, config) => {
const { parse } = await import('https://cdn.skypack.dev/papaparse@5.3.0')
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config
const { data } = parse(csvData, { header: true })
const filtered = data.filter(row => row[filterColumn] == filterValue)
const groups = filtered.reduce((acc, row) => {
const key = row[groupBy]
if (!acc[key]) acc[key] = []
acc[key].push(row)
return acc
}, {})
return Object.entries(groups).map(([groupValue, rows]) => {
const numbers = rows.map(row => +row[aggregateColumn] || 0)
let result
if (operation === 'sum') result = numbers.reduce((a, b) => a + b, 0)
if (operation === 'avg') result = numbers.reduce((a, b) => a + b, 0) / numbers.length
if (operation === 'count') result = numbers.length
return { [groupBy]: groupValue, result }
})
}
export default processCSV;

View File

@@ -0,0 +1,71 @@
const findAvailableSlots = async (calendar1, calendar2, constraints) => {
const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon@3.0.1')
const { durationMinutes, searchRange, workHours } = constraints
const workStart = DateTime.fromISO(`${searchRange.start.split('T')[0]}T${workHours.start}:00Z`)
const workEnd = DateTime.fromISO(`${searchRange.start.split('T')[0]}T${workHours.end}:00Z`)
const searchStart = DateTime.fromISO(searchRange.start)
const searchEnd = DateTime.fromISO(searchRange.end)
const mergeCalendars = (cal1, cal2) => {
const allSlots = [...cal1, ...cal2].map(slot => ({
start: DateTime.fromISO(slot.start),
end: DateTime.fromISO(slot.end)
})).sort((a, b) => a.start - b.start)
return allSlots.reduce((merged, current) => {
if (merged.length === 0) return [current]
const last = merged[merged.length - 1]
if (current.start <= last.end) {
last.end = current.end > last.end ? current.end : last.end
return merged
}
return [...merged, current]
}, [])
}
const mergedBusy = mergeCalendars(calendar1, calendar2)
const freeIntervals = []
let currentStart = searchStart
for (const busy of mergedBusy) {
if (busy.start > currentStart) {
freeIntervals.push(Interval.fromDateTimes(currentStart, busy.start))
}
currentStart = busy.end > currentStart ? busy.end : currentStart
}
if (currentStart < searchEnd) {
freeIntervals.push(Interval.fromDateTimes(currentStart, searchEnd))
}
const availableSlots = freeIntervals.flatMap(interval => {
const slots = []
let slotStart = interval.start
while (slotStart.plus({ minutes: durationMinutes }) <= interval.end) {
const slotEnd = slotStart.plus({ minutes: durationMinutes })
const slotInterval = Interval.fromDateTimes(slotStart, slotEnd)
if (slotInterval.engulfs(workStart) && slotInterval.engulfs(workEnd)) {
slots.push({
start: slotStart.toISO(),
end: slotEnd.toISO()
})
}
slotStart = slotEnd
}
return slots
})
return availableSlots.filter(slot => {
const slotStart = DateTime.fromISO(slot.start)
const slotEnd = DateTime.fromISO(slot.end)
return slotStart >= workStart && slotEnd <= workEnd
})
}
export default findAvailableSlots;

View File

@@ -0,0 +1,36 @@
const validateJSON = async (json, schema) => {
try {
const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/+esm')
const { default: addFormats } = await import('https://cdn.jsdelivr.net/npm/ajv-formats@2.1.1/+esm')
const ajv = new Ajv({
allErrors: true,
strict: false,
validateSchema: true
})
addFormats(ajv)
const validate = ajv.compile(schema)
const valid = validate(json)
return {
valid,
errors: valid ? [] : validate.errors.map(err => ({
message: err.message,
instancePath: err.instancePath,
schemaPath: err.schemaPath,
params: err.params
}))
}
} catch (error) {
return {
valid: false,
errors: [{
message: error.message,
stack: error.stack
}]
}
}
}
export default validateJSON;

View File

@@ -0,0 +1,41 @@
const createStreamVisualizer = async (asyncIterable, {
maxPoints = 1000,
alpha = 0.3,
width = 800,
height = 400,
yDomain = [0, 1]
} = {}) => {
const { scaleLinear, line } = await import('https://cdn.skypack.dev/d3@7');
const data = [];
let prevEma;
for await (const { timestamp, value } of asyncIterable) {
const ema = prevEma === undefined
? value
: alpha * value + (1 - alpha) * prevEma;
prevEma = ema;
data.push({ timestamp, value, ema });
if (data.length > maxPoints) data.shift();
}
if (!data.length) return { data: [], path: '' };
const xScale = scaleLinear()
.domain([data[0].timestamp, data[data.length - 1].timestamp])
.range([0, width]);
const yScale = scaleLinear()
.domain(yDomain)
.range([height, 0]);
const pathGenerator = line()
.x(d => xScale(d.timestamp))
.y(d => yScale(d.ema));
return {
data,
path: pathGenerator(data)
};
};
export default createStreamVisualizer;