Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Instantly convert your JavaScript functions into functions which can be called by GPT-3.5 and GPT-4.
ai-fns is a a library for building 100% type-safe functions which can be called by OpenAI's ChatGPT
pnpm install ai-fns
Here's an example of a function that calculates the output of a given mathematical expression:
import { Parser } from "expr-eval";
import { z } from "zod";
import { aifn } from "../utils";
const parser = new Parser();
export default aifn(
"calculator",
"Calculate the output of a given mathematical expression",
z.object({
expression: z.string(),
}),
({ expression }) => {
try {
const result = parser.parse(expression).evaluate();
return result;
} catch (error) {
return `Failed to execute script: ${error.message}`;
}
}
);
Now, you can just ask ChatGPT to do some math for you:
User: What's 45^(2.12) / 45?
Assistant: The result of 45^(2.12) / 45 is approximately 71.06.
Here's an example of a function that fetches the latest news from an rss feed:
import Parser from "rss-parser";
import { z } from "zod";
import { aifn } from "../utils";
const parser = new Parser();
export const name = "rss";
export const description = "Get the latest news from an rss feed";
export const schema = z.object({
url: z.string(),
});
export const rss = async ({ url }: z.infer<typeof schema>) => {
try {
const feed = await parser.parseURL(url);
return feed;
} catch (error) {
return `Failed to execute script: ${error.message}`;
}
};
export default aifn(name, description, schema, rss);
Let's ask ChatGPT to fetch the latest news from the Hacker News RSS feed
User: What's the top story on Hacker News today?
Assistant: The top story on Hacker News today is "A new method to reprogram human cells to better mimic embryonic stem cells". It has a score of 294 and 72 comments. You can read more about it [here](https://www.uwa.edu.au/news/Article/2023/August/Scientists-find-way-to-wipe-a-cells-memory-to-reprogram-it-as-a-stem-cell).
You can make your own functions by creating a new file in the tools
directory. Here's a template:
import { z } from "zod";
import { aifn } from "../utils";
export const name = "name";
export const description = "description";
export const schema = z.object({
// schema
});
export const fn = async ({}: /* schema */ z.infer<typeof schema>) => {
// function body
};
export default aifn(name, description, schema, fn);
FAQs
Instantly convert your JavaScript functions into functions which can be called by GPT-3.5 and GPT-4.
The npm package ai-fns receives a total of 5 weekly downloads. As such, ai-fns popularity was classified as not popular.
We found that ai-fns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.