```Jev-左填充```
Jev-Leftpad

原始链接: https://github.com/f/jev-leftpad

`jev-leftpad` 是一个幽默且刻意为之的低效工具包,旨在通过 TypeSafe SDK 调用 AI 模型(Jev)为字符串进行左填充。 与标准且高效的 `padStart()` 方法不同,该工具包需要 `TYPESAFE_API_KEY` 和 Node.js 20+ 环境,并依赖 AI 模型来选择填充空格的数量(0 到 10 个)。每次调用都会发起实时 API 请求,不具备重试机制,且极易出错或输出错误结果。 作为一个讽刺性项目,它不仅低效、昂贵,而且不可靠。作者明确建议不要将其用于生产环境或任何严肃任务。该代码库采用 MIT 许可协议,并包含不会消耗 API 点数的模拟测试。

这篇 Hacker News 讨论帖围绕 **Jev-Leftpad** 展开,这是一个使用通用分类模型“Jev”来执行字符串填充(string padding)的讽刺性项目。 讨论主要集中在三个主题: 1. **“Left-pad”梗:** 该项目调侃了 2016 年臭名昭著的 npm `left-pad` 事件,当时一个微不足道的工具包被删除,导致成千上万的 JavaScript 应用程序崩溃。许多评论者认为,该项目是对现代“万物皆 AI”趋势及将资源密集型模型用于简单任务这一荒谬现象的幽默讽刺。 2. **Jev 的角色:** 用户讨论了 Jev 作为“代理型”分类器的效用和局限性。批评者认为,由于其准确率仅为 90%,它作为预言机(oracle)表现不佳,但如果置于更大的自纠错系统中,或许能作为迭代器发挥作用。 3. **行业讽刺:** 参与者嘲讽了当前科技界用 AI 过度设计简单解决方案的风气,将其比作“氛围编程”(vibe coding)。尽管一些用户将其视为一个严肃的(尽管极其小众的)技术实验,但大多数参与者将其视为对供应链依赖和当前 AI 炒作周期的喜剧化诠释。
相关文章

原文

Left pad a value with Jev.

Could this be one line with padStart()? Yes. Does it need a model call? No. Anyway:

import leftPad from 'jev-leftpad';

const result = await leftPad('jev', 8);

console.log(JSON.stringify(result));
// "     jev" (probably)

Set TYPESAFE_API_KEY before using it. jev-leftpad uses jev-latest through TypeSafe's native @typesafe-ai/sdk. It requires Node.js 20 or newer.

await leftPad(value, targetLength)

targetLength must be a non-negative safe integer.

Jev gets one Choice with criteria named space_0, space_1, space_2, and so on, written directly up to space_10. For the example above, it should choose space_5. JavaScript reads the number, creates five spaces, and puts the value after them.

This means the package can add between 0 and 10 spaces. If more than 10 spaces are needed, Jev has no correct option. Which feels appropriate for this project.

There is one TypeSafe API request per call and retries are disabled. The request can fail, Jev can choose the wrong option, and it costs more than padStart(). Please don't use this in production. Or anything important.

The tests mock Jev. They don't need an API key and don't spend any TypeSafe credits.

MIT

联系我们 contact @ memedata.com