SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
3.5 KB · 52 lines typescript
Raw Blame History
1import { BASE, post, raw, save, short } from "./lib.ts";23const results: Record<string, any> = {};4const tiny = (model: string) => ({ model, messages: [{ role: "user", content: "Hi" }], max_tokens: 5 });56results.invalidKey = await post("/chat/completions", tiny("mistral-small-latest"), "sk-invalid-key-0000");7console.log("invalid key", results.invalidKey.status, JSON.stringify(results.invalidKey.headers), short(results.invalidKey.body, 400));89const noAuth = await fetch(`${BASE}/chat/completions`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(tiny("mistral-small-latest")) });10results.noAuth = { status: noAuth.status, body: await noAuth.text() };11console.log("no auth", results.noAuth.status, short(results.noAuth.body, 300));1213results.invalidKeyModels = await raw("/models", { key: "sk-invalid-key-0000" });14console.log("invalid key GET /models", results.invalidKeyModels.status, short(results.invalidKeyModels.body, 300));1516results.unknownModel = await post("/chat/completions", tiny("mistral-99-ultra"));17console.log("unknown model", results.unknownModel.status, short(results.unknownModel.body, 400));1819for (const slug of ["mistral-small-2506", "mistral-medium-2508", "magistral-medium-2509", "magistral-small-2509", "pixtral-12b-2409", "open-mistral-7b", "mistral-large-2411", "devstral-medium-2507", "mistral-medium-2505", "ministral-8b-2410", "open-mistral-nemo", "pixtral-large-latest", "codestral-2501", "mistral-small-2501", "mistral-saba-latest", "magistral-medium-2507", "mistral-large-2407"]) {20  const r = await post("/chat/completions", tiny(slug));21  results[`retired_${slug}`] = r;22  console.log(`retired ${slug.padEnd(26)} ${r.status} model=${(r.body as any)?.model ?? ""} ${r.status !== 200 ? short(r.body, 200) : ""}`);23}2425const malformed = await fetch(`${BASE}/chat/completions`, {26  method: "POST",27  headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.MISTRAL_API_KEY}` },28  body: '{"model":"mistral-small-latest","messages":"nope"}',29});30results.malformed = { status: malformed.status, body: await malformed.text() };31console.log("messages as string", results.malformed.status, short(results.malformed.body, 400));3233results.emptyMessages = await post("/chat/completions", { model: "mistral-small-latest", messages: [] });34console.log("empty messages", results.emptyMessages.status, short(results.emptyMessages.body, 300));3536results.maxTokensHuge = await post("/chat/completions", { model: "mistral-small-latest", messages: [{ role: "user", content: "Hi" }], max_tokens: 10_000_000 });37console.log("max_tokens 10M", results.maxTokensHuge.status, short(results.maxTokensHuge.body, 300));3839results.badTemp = await post("/chat/completions", { model: "mistral-small-latest", messages: [{ role: "user", content: "Hi" }], max_tokens: 5, temperature: 3 });40console.log("temperature 3", results.badTemp.status, short(results.badTemp.body, 300));4142results.badTopP = await post("/chat/completions", { model: "mistral-small-latest", messages: [{ role: "user", content: "Hi" }], max_tokens: 5, top_p: 1.5 });43console.log("top_p 1.5", results.badTopP.status, short(results.badTopP.body, 300));4445results.embedOnChat = await post("/chat/completions", tiny("mistral-embed"));46console.log("embed model on chat", results.embedOnChat.status, short(results.embedOnChat.body, 300));4748results.ocrOnChat = await post("/chat/completions", tiny("mistral-ocr-latest"));49console.log("ocr model on chat", results.ocrOnChat.status, short(results.ocrOnChat.body, 300));5051save("06-errors.json", results);52