is-even-ai——利用AI的力量检查数字是否为偶数
Is-even-ai – Check if a number is even using the power of AI

原始链接: https://www.npmjs.com/package/is-even-ai

`is-even-ai` npm 包利用 OpenAI 的 GPT-3.5-turbo 来判断数字属性。它包含 `isEven`、`isOdd`、`areEqual`、`areNotEqual`、`isGreaterThan` 和 `isLessThan` 等函数。 使用该包需要一个 OpenAI API 密钥,可以通过 `setApiKey` 函数或 `OPENAI_API_KEY` 环境变量设置。基本用法是调用所需函数并传入数字,然后等待结果(例如:`await isEven(2)`)。 对于更高级的配置,例如指定 OpenAI 模型和温度,可以使用 `IsEvenAiOpenAi` 类,在构造函数中传入 API 密钥和配置选项。这允许更精细地控制 AI 的行为。 该包旨在作为将 AI 集成到简单任务中的一个有趣的演示,其灵感来自于臭名昭著的 `is-even` npm 包以及在意外方式中使用 AI 的潜力。它也欢迎贡献者扩展对其他 AI 平台的支持。

Hacker News 用户正在讽刺地讨论 “is-even-ai” 包,这个包用 AI 来判断一个数字是否是偶数。评论嘲笑了这个包的荒谬之处,强调了将 AI 用于如此简单任务的低效性和潜在不可靠性。一些用户开玩笑说可以用它来快速地为产品添加 AI 以讨好管理层,而另一些用户则建议改进,例如添加 “isOdd” 或 “isVeryEven” 方法。还有人讨论了使用大型语言模型来判断某事物是否为真。整体基调轻松幽默,用户都在取笑过度使用 AI 来解决问题的趋势。

原文

NPM Version NPM License NPM Downloads

Check if a number is even using the power of ✨AI✨.

Uses OpenAI's GPT-3.5-turbo model under the hood to determine if a number is even.

For all those who want to use AI in their product but don't know how.

Inspired by the famous is-even npm package and this tweet.

This package is on npm.

import {
  areEqual,
  areNotEqual,
  isEven,
  isGreaterThan,
  isLessThan,
  isOdd,
  setApiKey,
} from "is-even-ai";

// won't need this if you have OPENAI_API_KEY in your environment
setApiKey("YOUR_API_KEY");

console.log(await isEven(2)); // true
console.log(await isEven(3)); // false
console.log(await isOdd(4)); // false
console.log(await isOdd(5)); // true
console.log(await areEqual(6, 6)); // true
console.log(await areEqual(6, 7)); // false
console.log(await areNotEqual(6, 7)); // true
console.log(await areNotEqual(7, 7)); // false
console.log(await isGreaterThan(8, 7)); // true
console.log(await isGreaterThan(7, 8)); // false
console.log(await isLessThan(9, 8)); // false
console.log(await isLessThan(8, 9)); // true

for more advance usage like changing which model to use and setting the temperature, use IsEvenAiOpenAi instead

import { IsEvenAiOpenAi } from "is-even-ai";

const isEvenAiOpenAi = new IsEvenAiOpenAi(
  {
    // won't need this if you have OPENAI_API_KEY in your environment
    apiKey: "YOUR_API_KEY",
  },
  {
    model: "gpt-3.5-turbo",
    temperature: 0,
  }
);

console.log(await isEvenAiOpenAi.isEven(2)); // true
console.log(await isEvenAiOpenAi.isEven(3)); // false
console.log(await isEvenAiOpenAi.isOdd(4)); // false
console.log(await isEvenAiOpenAi.isOdd(5)); // true
console.log(await isEvenAiOpenAi.areEqual(6, 6)); // true
console.log(await isEvenAiOpenAi.areEqual(6, 7)); // false
console.log(await isEvenAiOpenAi.areNotEqual(6, 7)); // true
console.log(await isEvenAiOpenAi.areNotEqual(7, 7)); // false
console.log(await isEvenAiOpenAi.isGreaterThan(8, 7)); // true
console.log(await isEvenAiOpenAi.isGreaterThan(7, 8)); // false
console.log(await isEvenAiOpenAi.isLessThan(8, 9)); // true
console.log(await isEvenAiOpenAi.isLessThan(9, 8)); // false

Feel free to make a PR to add more AI platforms.

  • isEven(n: number)
  • isOdd(n: number)
  • areEqual(a: number, b: number)
  • areNotEqual(a: number, b: number)
  • isGreaterThan(a: number, b: number)
  • isLessThan(a: number, b: number)
联系我们 contact @ memedata.com