lua-cli 2.1.0-alpha.4 → 2.1.0
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.
- package/README.md +2 -2
- package/dist/commands/compile.js +18 -2
- package/dist/product-api.d.ts +37 -2
- package/dist/product-api.js +43 -9
- package/dist/services/api.d.ts +20 -5
- package/dist/services/api.js +54 -9
- package/dist/utils/files.js +2 -2
- package/dist/utils/sandbox.js +8 -5
- package/dist/web/app.css +447 -0
- package/dist/web/app.js +20 -20
- package/package.json +4 -3
- package/template/lua.skill.yaml +2 -13
- package/template/package.json +2 -1
- package/template/src/index.ts +6 -1
- package/template/src/tools/ProductsTool.ts +59 -27
- package/template/package-lock.json +0 -3702
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
".": "./dist/index.js",
|
|
9
9
|
"./types": "./dist/types.js",
|
|
10
10
|
"./skill": "./dist/skill.js",
|
|
11
|
-
"./user-data-api": "./dist/user-data-api.js"
|
|
11
|
+
"./user-data-api": "./dist/user-data-api.js",
|
|
12
|
+
"./product-api": "./dist/product-api.js"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
14
15
|
"clean": "rm -rf dist",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"deployment",
|
|
35
36
|
"skills"
|
|
36
37
|
],
|
|
37
|
-
"author": "Stefan Kruger <stefan@
|
|
38
|
+
"author": "Stefan Kruger <stefan@heylua.ai>",
|
|
38
39
|
"license": "MIT",
|
|
39
40
|
"type": "module",
|
|
40
41
|
"repository": {
|
package/template/lua.skill.yaml
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
agent:
|
|
2
|
-
agentId:
|
|
3
|
-
orgId:
|
|
4
|
-
persona: Your name is Stefan always remember that
|
|
5
|
-
welcomeMessage: 'Hi, I am your AI assistant. How can I help you today?'
|
|
2
|
+
agentId: baseAgent_agent_1759165790010_cmu8t35ta
|
|
3
|
+
orgId: 845c77a8-88b9-4381-ba4a-fd7496ef1f57
|
|
6
4
|
skills:
|
|
7
|
-
- name: general-skill
|
|
8
|
-
version: 0.0.2
|
|
9
|
-
skillId: 24294a5a-bd95-4167-89b1-aebad352196a
|
|
10
|
-
- name: user-data-skill
|
|
11
|
-
version: 0.0.1
|
|
12
|
-
skillId: 5c167305-9f59-4e20-84e9-fd1b50856ec4
|
|
13
|
-
- name: eccomerce-skill
|
|
14
|
-
version: 0.0.1
|
|
15
|
-
skillId: dbec43db-9786-4223-9eac-8087d976d22d
|
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { LuaSkill } from "lua-cli/skill";
|
|
|
2
2
|
import GetWeatherTool from "./tools/GetWeatherTool";
|
|
3
3
|
import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
4
4
|
import CreatePostTool from "./tools/CreatePostTool";
|
|
5
|
-
import { SearchProductsTool } from "./tools/
|
|
5
|
+
import { SearchProductsTool, GetAllProductsTool, CreateProductTool, UpdateProductTool, DeleteProductTool } from "./tools/ProductsTool";
|
|
6
6
|
import CreatePaymentLinkTool from "./tools/PaymentTool";
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
// Initialize skill with tools
|
|
9
10
|
const generalSkill = new LuaSkill({
|
|
10
11
|
name: "general-skill",
|
|
@@ -42,6 +43,10 @@ const eccomerceSkill = new LuaSkill({
|
|
|
42
43
|
|
|
43
44
|
eccomerceSkill.addTools([
|
|
44
45
|
new SearchProductsTool(),
|
|
46
|
+
new GetAllProductsTool(),
|
|
47
|
+
new CreateProductTool(),
|
|
48
|
+
new UpdateProductTool(),
|
|
49
|
+
new DeleteProductTool(),
|
|
45
50
|
new CreatePaymentLinkTool()
|
|
46
51
|
]);
|
|
47
52
|
|
|
@@ -1,43 +1,75 @@
|
|
|
1
1
|
import { env, LuaTool } from "lua-cli/skill";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { product } from 'lua-cli/product-api';
|
|
4
|
-
import {
|
|
5
|
-
import OpenAI from "openai";
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
5
|
export class SearchProductsTool implements LuaTool {
|
|
7
6
|
name = "search_products";
|
|
8
7
|
description = "Search for products";
|
|
9
8
|
inputSchema = z.object({
|
|
10
9
|
query: z.string()
|
|
11
10
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const pinecone = new Pinecone({
|
|
18
|
-
apiKey: env('PINECONE_API_KEY') || ''
|
|
19
|
-
});
|
|
20
|
-
this.openai = new OpenAI({ apiKey: env('OPENAI_API_KEY') || '' });
|
|
21
|
-
this.pinecone = pinecone;
|
|
22
|
-
this.index = pinecone.Index('products-demo');
|
|
11
|
+
|
|
12
|
+
constructor() {}
|
|
13
|
+
|
|
14
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
15
|
+
return await product.data.search(input.query);
|
|
23
16
|
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class GetAllProductsTool implements LuaTool {
|
|
20
|
+
name = "get_all_products";
|
|
21
|
+
description = "Get all products";
|
|
22
|
+
inputSchema = z.object({
|
|
23
|
+
page: z.number().optional(),
|
|
24
|
+
limit: z.number().optional()
|
|
25
|
+
});
|
|
24
26
|
|
|
25
|
-
async
|
|
26
|
-
|
|
27
|
-
model: "text-embedding-3-small",
|
|
28
|
-
input: text,
|
|
29
|
-
});
|
|
30
|
-
return embeddingResponse.data[0].embedding;
|
|
27
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
28
|
+
return product.data.get(input.page, input.limit);
|
|
31
29
|
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class CreateProductTool implements LuaTool {
|
|
33
|
+
name = "create_product";
|
|
34
|
+
description = "Create a new product";
|
|
35
|
+
inputSchema = z.object({
|
|
36
|
+
product: z.object({
|
|
37
|
+
name: z.string(),
|
|
38
|
+
description: z.string(),
|
|
39
|
+
price: z.number()
|
|
40
|
+
})
|
|
41
|
+
});
|
|
32
42
|
|
|
33
43
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
return product.data.create({...input.product, id: uuidv4()});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class UpdateProductTool implements LuaTool {
|
|
49
|
+
name = "update_product";
|
|
50
|
+
description = "Update an existing product";
|
|
51
|
+
inputSchema = z.object({
|
|
52
|
+
product: z.object({
|
|
53
|
+
id: z.string(),
|
|
54
|
+
name: z.string(),
|
|
55
|
+
description: z.string(),
|
|
56
|
+
price: z.number()
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
61
|
+
return product.data.update({...input.product, id: uuidv4()}, input.product.id);
|
|
42
62
|
}
|
|
43
63
|
}
|
|
64
|
+
|
|
65
|
+
export class DeleteProductTool implements LuaTool {
|
|
66
|
+
name = "delete_product";
|
|
67
|
+
description = "Delete an existing product";
|
|
68
|
+
inputSchema = z.object({
|
|
69
|
+
id: z.string()
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
73
|
+
return product.data.delete(input.id);
|
|
74
|
+
}
|
|
75
|
+
}
|