@axvaich/ai-lib
v1.0.7
Published
AI-powered TypeScript function generator with strict typing and zero side effects.
Readme
@axvaich/ai-lib
AI-powered TypeScript function generator with strict typing and zero side effects.
Installation
npm install @axvaich/ai-libCreate a .env file by copying .env.example:
cp .env.example .envThen set your GROQ API key from console.groq.com/keys:
GROQ_API_KEY=your_api_key_hereUsing
example 1
code you see:
import { generate } from "@axvaich/ai-lib";
async function main() {
const command2 = await generate("return all numbers from arguments");
console.log(command2(1, 2, 3, "asd", 54));
}
main(); // output [ 1, 2, 3, 54 ]generated code:
/**
* Returns all numbers from the given arguments.
*
* @param args A variable number of arguments of any type.
* @returns An array of numbers.
*/
export default function getNumbers(...args) {
return args.filter((arg) => typeof arg === "number");
}example 2
code you see:
import { generate } from "@axvaich/ai-lib";
async function main() {
const button = await generate(
"function that returns HTML markup as a string with a styled button in a template literal",
);
console.log(button());
}
main();generated code:
/**
* Returns HTML markup as a string with a styled button.
*
* @returns {string} The HTML markup with a styled button.
*/
export default function getStyledButton() {
return `
<button style="background-color: #4CAF50; color: #fff; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer;">
Click me
</button>
`;
}Performance
Functions are cached by prompt hash. Existing functions are reused without additional API requests.
