```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 ( github.com/f ) 15 点 由 fka 发布 1 小时前 | 隐藏 | 过往 | 收藏 | 2 条评论 帮助 Topfi 8 分钟前 | 下一条 [–] 超出我理解范畴的人造恐怖,妙啊。 回复 serious_angel 5 分钟前 | 上一条 | 下一条 [–] 这倒是个稀有的 GitHub 用户名! 不过话说回来,这又是一个让某人更加依赖“AI”的项目…… 相关内容: https://en.wikipedia.org/wiki/Jev_(AI_model) https://typesafe.ai/ 回复 社区指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:
相关文章

原文

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