Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import type { $ZodCheck, $ZodStringFormats } from "./checks.js";2import { $constructor } from "./core.js";3import type { $ZodType } from "./schemas.js";4import type { StandardSchemaV1 } from "./standard-schema.js";5import * as util from "./util.js";6 7///////////////////////////8//// base type ////9///////////////////////////10export interface $ZodIssueBase {11 readonly code?: string;12 readonly input?: unknown;13 readonly path: PropertyKey[];14 readonly message: string;15}16 17////////////////////////////////18//// issue subtypes ////19////////////////////////////////20export type $ZodInvalidTypeExpected =21 | "string"22 | "number"23 | "int"24 | "boolean"25 | "bigint"26 | "symbol"27 | "undefined"28 | "null"29 | "never"30 | "void"31 | "date"32 | "array"33 | "object"34 | "tuple"35 | "record"36 | "map"37 | "set"38 | "file"39 | "nonoptional"40 | "nan"41 | "function"42 | (string & {}); // class names for instanceof43 44export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {45 readonly code: "invalid_type";46 readonly expected: $ZodInvalidTypeExpected;47 readonly input?: Input;48}49 50export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {51 readonly code: "too_big";52 readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});53 readonly maximum: number | bigint;54 readonly inclusive?: boolean;55 readonly exact?: boolean;56 readonly input?: Input;57}58 59export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {60 readonly code: "too_small";61 readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});62 readonly minimum: number | bigint;63 /** True if the allowable range includes the minimum */64 readonly inclusive?: boolean;65 /** True if the allowed value is fixed (e.g.` z.length(5)`), not a range (`z.minLength(5)`) */66 readonly exact?: boolean;67 readonly input?: Input;68}69 70export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {71 readonly code: "invalid_format";72 readonly format: $ZodStringFormats | (string & {});73 readonly pattern?: string;74 readonly input?: string;75}76 77export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {78 readonly code: "not_multiple_of";79 readonly divisor: number;80 readonly input?: Input;81}82 83export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {84 readonly code: "unrecognized_keys";85 readonly keys: string[];86 readonly input?: Record<string, unknown>;87}88 89interface $ZodIssueInvalidUnionNoMatch extends $ZodIssueBase {90 readonly code: "invalid_union";91 readonly errors: $ZodIssue[][];92 readonly input?: unknown;93 readonly discriminator?: string | undefined;94 readonly options?: util.Primitive[];95 readonly inclusive?: true;96}97 98interface $ZodIssueInvalidUnionMultipleMatch extends $ZodIssueBase {99 readonly code: "invalid_union";100 readonly errors: [];101 readonly input?: unknown;102 readonly discriminator?: string | undefined;103 readonly inclusive: false;104}105 106export type $ZodIssueInvalidUnion = $ZodIssueInvalidUnionNoMatch | $ZodIssueInvalidUnionMultipleMatch;107 108export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {109 readonly code: "invalid_key";110 readonly origin: "map" | "record";111 readonly issues: $ZodIssue[];112 readonly input?: Input;113}114 115export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {116 readonly code: "invalid_element";117 readonly origin: "map" | "set";118 readonly key: unknown;119 readonly issues: $ZodIssue[];120 readonly input?: Input;121}122 123export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {124 readonly code: "invalid_value";125 readonly values: util.Primitive[];126 readonly input?: Input;127}128 129export interface $ZodIssueCustom extends $ZodIssueBase {130 readonly code: "custom";131 readonly params?: Record<string, any> | undefined;132 readonly input?: unknown;133}134 135////////////////////////////////////////////136//// first-party string formats ////137////////////////////////////////////////////138 139export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {140 format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;141}142 143export interface $ZodIssueStringInvalidRegex extends $ZodIssueInvalidStringFormat {144 format: "regex";145 pattern: string;146}147 148export interface $ZodIssueStringInvalidJWT extends $ZodIssueInvalidStringFormat {149 format: "jwt";150 algorithm?: string;151}152 153export interface $ZodIssueStringStartsWith extends $ZodIssueInvalidStringFormat {154 format: "starts_with";155 prefix: string;156}157 158export interface $ZodIssueStringEndsWith extends $ZodIssueInvalidStringFormat {159 format: "ends_with";160 suffix: string;161}162 163export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {164 format: "includes";165 includes: string;166}167 168export type $ZodStringFormatIssues =169 | $ZodIssueStringCommonFormats170 | $ZodIssueStringInvalidRegex171 | $ZodIssueStringInvalidJWT172 | $ZodIssueStringStartsWith173 | $ZodIssueStringEndsWith174 | $ZodIssueStringIncludes;175 176////////////////////////177//// utils /////178////////////////////////179 180export type $ZodIssue =181 | $ZodIssueInvalidType182 | $ZodIssueTooBig183 | $ZodIssueTooSmall184 | $ZodIssueInvalidStringFormat185 | $ZodIssueNotMultipleOf186 | $ZodIssueUnrecognizedKeys187 | $ZodIssueInvalidUnion188 | $ZodIssueInvalidKey189 | $ZodIssueInvalidElement190 | $ZodIssueInvalidValue191 | $ZodIssueCustom;192 193export type $ZodIssueCode = $ZodIssue["code"];194 195export type $ZodInternalIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;196type RawIssue<T extends $ZodIssueBase> = T extends any197 ? util.Flatten<198 util.MakePartial<T, "message" | "path"> & {199 /** The input data */200 readonly input: unknown;201 /** The schema or check that originated this issue. */202 readonly inst?: $ZodType | $ZodCheck;203 /** If `true`, Zod will continue executing checks/refinements after this issue. */204 readonly continue?: boolean | undefined;205 } & Record<string, unknown>206 >207 : never;208 209export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = $ZodInternalIssue<T>;210 211export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {212 // biome-ignore lint:213 (issue: $ZodRawIssue<T>): { message: string } | string | undefined | null;214}215 216//////////////////////// ERROR CLASS ////////////////////////217 218// const ZOD_ERROR: symbol = Symbol.for("{{zod.error}}");219export interface $ZodError<T = unknown> extends Error {220 type: T;221 issues: $ZodIssue[];222 _zod: {223 output: T;224 def: $ZodIssue[];225 };226 stack?: string;227 name: string;228}229 230const initializer = (inst: $ZodError, def: $ZodIssue[]): void => {231 inst.name = "$ZodError";232 Object.defineProperty(inst, "_zod", {233 value: inst._zod,234 enumerable: false,235 });236 Object.defineProperty(inst, "issues", {237 value: def,238 enumerable: false,239 });240 inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);241 242 Object.defineProperty(inst, "toString", {243 value: () => inst.message,244 enumerable: false,245 });246};247 248export const $ZodError: $constructor<$ZodError> = $constructor("$ZodError", initializer);249interface $ZodRealError<T = any> extends $ZodError<T> {}250export const $ZodRealError: $constructor<$ZodRealError> = $constructor("$ZodError", initializer, { Parent: Error });251 252/////////////////// ERROR UTILITIES ////////////////////////253 254// flatten255export type $ZodFlattenedError<T, U = string> = _FlattenedError<T, U>;256type _FlattenedError<T, U = string> = {257 formErrors: U[];258 fieldErrors: {259 [P in keyof T]?: U[];260 };261};262 263export function flattenError<T>(error: $ZodError<T>): _FlattenedError<T>;264export function flattenError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): _FlattenedError<T, U>;265export function flattenError<T, U>(error: $ZodError<T>, mapper = (issue: $ZodIssue) => issue.message as U) {266 const fieldErrors: Record<PropertyKey, any> = {};267 const formErrors: U[] = [];268 for (const sub of error.issues) {269 if (sub.path.length > 0) {270 fieldErrors[sub.path[0]!] = fieldErrors[sub.path[0]!] || [];271 fieldErrors[sub.path[0]!].push(mapper(sub));272 } else {273 formErrors.push(mapper(sub));274 }275 }276 return { formErrors, fieldErrors };277}278 279type _ZodFormattedError<T, U = string> = T extends [any, ...any[]]280 ? { [K in keyof T]?: $ZodFormattedError<T[K], U> }281 : T extends any[]282 ? { [k: number]: $ZodFormattedError<T[number], U> }283 : T extends object284 ? util.Flatten<{ [K in keyof T]?: $ZodFormattedError<T[K], U> }>285 : any;286 287export type $ZodFormattedError<T, U = string> = {288 _errors: U[];289} & util.Flatten<_ZodFormattedError<T, U>>;290 291export function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;292export function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;293export function formatError<T, U>(error: $ZodError<T>, mapper = (issue: $ZodIssue) => issue.message as U) {294 const fieldErrors: $ZodFormattedError<T> = { _errors: [] } as any;295 const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {296 for (const issue of error.issues) {297 if (issue.code === "invalid_union" && issue.errors.length) {298 issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));299 } else if (issue.code === "invalid_key") {300 processError({ issues: issue.issues }, [...path, ...issue.path]);301 } else if (issue.code === "invalid_element") {302 processError({ issues: issue.issues }, [...path, ...issue.path]);303 } else {304 const fullpath = [...path, ...issue.path];305 if (fullpath.length === 0) {306 (fieldErrors as any)._errors.push(mapper(issue));307 } else {308 let curr: any = fieldErrors;309 let i = 0;310 while (i < fullpath.length) {311 const el = fullpath[i]!;312 const terminal = i === fullpath.length - 1;313 314 if (!terminal) {315 curr[el] = curr[el] || { _errors: [] };316 } else {317 curr[el] = curr[el] || { _errors: [] };318 curr[el]._errors.push(mapper(issue));319 }320 321 curr = curr[el];322 i++;323 }324 }325 }326 }327 };328 processError(error);329 return fieldErrors;330}331 332export type $ZodErrorTree<T, U = string> = T extends util.Primitive333 ? { errors: U[] }334 : T extends [any, ...any[]]335 ? { errors: U[]; items?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }336 : T extends any[]337 ? { errors: U[]; items?: Array<$ZodErrorTree<T[number], U>> }338 : T extends object339 ? {340 errors: U[];341 properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> };342 }343 : { errors: U[] };344 345export function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;346export function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;347export function treeifyError<T, U>(error: $ZodError<T>, mapper = (issue: $ZodIssue) => issue.message as U) {348 const result: $ZodErrorTree<T, U> = { errors: [] } as any;349 const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {350 for (const issue of error.issues) {351 if (issue.code === "invalid_union" && issue.errors.length) {352 // regular union error353 issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));354 } else if (issue.code === "invalid_key") {355 processError({ issues: issue.issues }, [...path, ...issue.path]);356 } else if (issue.code === "invalid_element") {357 processError({ issues: issue.issues }, [...path, ...issue.path]);358 } else {359 const fullpath = [...path, ...issue.path];360 if (fullpath.length === 0) {361 result.errors.push(mapper(issue));362 continue;363 }364 365 let curr: any = result;366 let i = 0;367 while (i < fullpath.length) {368 const el = fullpath[i]!;369 370 const terminal = i === fullpath.length - 1;371 if (typeof el === "string") {372 curr.properties ??= {};373 curr.properties[el] ??= { errors: [] };374 curr = curr.properties[el];375 } else {376 curr.items ??= [];377 curr.items[el] ??= { errors: [] };378 curr = curr.items[el];379 }380 381 if (terminal) {382 curr.errors.push(mapper(issue));383 }384 385 i++;386 }387 }388 }389 };390 processError(error);391 return result;392}393 394/** Format a ZodError as a human-readable string in the following form.395 *396 * From397 *398 * ```ts399 * ZodError {400 * issues: [401 * {402 * expected: 'string',403 * code: 'invalid_type',404 * path: [ 'username' ],405 * message: 'Invalid input: expected string'406 * },407 * {408 * expected: 'number',409 * code: 'invalid_type',410 * path: [ 'favoriteNumbers', 1 ],411 * message: 'Invalid input: expected number'412 * }413 * ];414 * }415 * ```416 *417 * to418 *419 * ```420 * username421 * ✖ Expected number, received string at "username422 * favoriteNumbers[0]423 * ✖ Invalid input: expected number424 * ```425 */426export function toDotPath(_path: readonly (string | number | symbol | StandardSchemaV1.PathSegment)[]): string {427 const segs: string[] = [];428 const path: PropertyKey[] = _path.map((seg: any) => (typeof seg === "object" ? seg.key : seg));429 for (const seg of path) {430 if (typeof seg === "number") segs.push(`[${seg}]`);431 else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);432 else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);433 else {434 if (segs.length) segs.push(".");435 segs.push(seg);436 }437 }438 439 return segs.join("");440}441 442export function prettifyError(error: StandardSchemaV1.FailureResult): string {443 const lines: string[] = [];444 // sort by path length445 const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);446 447 // Process each issue448 for (const issue of issues) {449 lines.push(`✖ ${issue.message}`);450 if (issue.path?.length) lines.push(` → at ${toDotPath(issue.path)}`);451 }452 453 // Convert Map to formatted string454 return lines.join("\n");455}456 