@axvaich/ai-lib 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +43 -0
  2. package/dist/index.js +10 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,27 @@
1
1
  # @axvaich/ai-lib
2
2
 
3
+ ## Installation
4
+
5
+ ```bash
6
+ npm install @axvaich/ai-lib
7
+ ```
8
+
9
+ Create a `.env` file by copying `.env.example`:
10
+
11
+ ```bash
12
+ cp .env.example .env
13
+ ```
14
+
15
+ Then set your GROQ API key from [console.groq.com/keys](https://console.groq.com/keys):
16
+
17
+ ```env
18
+ GROQ_API_KEY=your_api_key_here
19
+ ```
20
+
3
21
  ## Using
4
22
 
23
+ ### example 1
24
+
5
25
  code you see:
6
26
 
7
27
  ```js
@@ -24,3 +44,26 @@ export default function multiplyNumbers(numbers) {
24
44
  return numbers.reduce((acc, current) => acc * current, 1);
25
45
  }
26
46
  ```
47
+
48
+ ### example 2
49
+
50
+ code you see:
51
+
52
+ ```js
53
+ const command2 = await generate("return all numbers from arguments");
54
+ console.log(command2(1, 2, 3, 54));
55
+ ```
56
+
57
+ generated code:
58
+
59
+ ```js
60
+ /**
61
+ * Returns all numbers from the given arguments.
62
+ *
63
+ * @param args A variable number of arguments of any type.
64
+ * @returns An array of numbers.
65
+ */
66
+ export default function getNumbers(...args) {
67
+ return args.filter((arg) => typeof arg === "number");
68
+ }
69
+ ```
package/dist/index.js CHANGED
@@ -42,16 +42,16 @@ var store = new Storage();
42
42
 
43
43
  // src/generator.ts
44
44
  import ts from "typescript";
45
- var SYSTEM_PROMPT = `\u0422\u044B \u0433\u0435\u043D\u0435\u0440\u0430\u0442\u043E\u0440 TypeScript \u0444\u0443\u043D\u043A\u0446\u0438\u0439. \u0421\u0442\u0440\u043E\u0433\u0438\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u0430:
46
- - \u041E\u0434\u043D\u0430 \u0444\u0443\u043D\u043A\u0446\u0438\u044F \u0441 export default
47
- - \u0421\u0442\u0440\u043E\u0433\u0430\u044F \u0442\u0438\u043F\u0438\u0437\u0430\u0446\u0438\u044F \u0432\u0441\u0435\u0445 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0438 return type
48
- - \u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u0432\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435
49
- - JSDoc \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 \u0441 \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435\u043C
50
- - Pure \u0444\u0443\u043D\u043A\u0446\u0438\u044F, \u0431\u0435\u0437 side-effects
51
- - \u0422\u043E\u043B\u044C\u043A\u043E \u043A\u043E\u0434, \u0441 \u043D\u0435\u0431\u043E\u043B\u044C\u0448\u0438\u043C \u043E\u0431\u044A\u044F\u0441\u043D\u0435\u043D\u0438\u0435\u043C
52
- - \u041D\u0438\u043A\u0430\u043A\u0438\u0445 \u0438\u043C\u043F\u043E\u0440\u0442\u043E\u0432 (\u0442\u043E\u043B\u044C\u043A\u043E \u0432\u0441\u0442\u0440\u043E\u0435\u043D\u043D\u044B\u0435 \u0442\u0438\u043F\u044B TS)
53
- - \u0415\u0441\u043B\u0438 \u0432 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u0441\u043A\u043E\u043C \u0437\u0430\u043F\u0440\u043E\u0441\u0435 \u043D\u0435\u0442 \u044F\u0432\u043D\u044B\u0445 \u0430\u0440\u0433\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u2014 \u0444\u0443\u043D\u043A\u0446\u0438\u044F \u043D\u0435 \u0434\u043E\u043B\u0436\u043D\u0430 \u043F\u0440\u0438\u043D\u0438\u043C\u0430\u0442\u044C \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B, \u043F\u0440\u043E\u0441\u0442\u043E \u0432\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442
54
- - \u0421\u043B\u0435\u0434\u0443\u0439 \u0441\u0442\u0440\u043E\u0433\u043E \u0437\u0430 \u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F\u043C\u0438 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F`;
45
+ var SYSTEM_PROMPT = `You are a TypeScript function generator. Strict rules:
46
+ - Exactly one function with export default
47
+ - Strict typing for all parameters and the return type
48
+ - Must always return a value
49
+ - Include a JSDoc comment with a description
50
+ - Pure function, no side effects
51
+ - Only code, with a brief explanation
52
+ - No imports (only built-in TypeScript types)
53
+ - If the user request does not explicitly specify arguments, the function must not accept any parameters and should simply return the result
54
+ - Follow the user's instructions strictly`;
55
55
  var groq = new Groq({
56
56
  apiKey: process.env.GROQ_API_KEY
57
57
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axvaich/ai-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"