lua-cli 2.1.0-alpha.3 → 2.1.0-alpha.6
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/product-api.d.ts +48 -0
- package/dist/product-api.js +27 -0
- package/package.json +1 -1
- package/template/lua.skill.yaml +5 -7
- package/template/package-lock.json +88 -2279
- package/template/package.json +1 -1
- package/template/src/index.ts +6 -1
- package/template/src/tools/ProductsTool.ts +56 -28
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,71 @@
|
|
|
1
1
|
import { env, LuaTool } from "lua-cli/skill";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { product } from 'lua-cli
|
|
4
|
-
import { Pinecone, Index } from '@pinecone-database/pinecone';
|
|
5
|
-
import OpenAI from "openai";
|
|
3
|
+
import { product } from 'lua-cli';
|
|
6
4
|
export class SearchProductsTool implements LuaTool {
|
|
7
5
|
name = "search_products";
|
|
8
6
|
description = "Search for products";
|
|
9
7
|
inputSchema = z.object({
|
|
10
8
|
query: z.string()
|
|
11
9
|
});
|
|
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');
|
|
10
|
+
|
|
11
|
+
constructor() {}
|
|
12
|
+
|
|
13
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
14
|
+
const products = await product.data.search(input.query);
|
|
23
15
|
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class GetAllProductsTool implements LuaTool {
|
|
19
|
+
name = "get_all_products";
|
|
20
|
+
description = "Get all products";
|
|
21
|
+
inputSchema = z.object({ });
|
|
24
22
|
|
|
25
|
-
async
|
|
26
|
-
|
|
27
|
-
model: "text-embedding-3-small",
|
|
28
|
-
input: text,
|
|
29
|
-
});
|
|
30
|
-
return embeddingResponse.data[0].embedding;
|
|
23
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
24
|
+
return product.data.get();
|
|
31
25
|
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class CreateProductTool implements LuaTool {
|
|
29
|
+
name = "create_product";
|
|
30
|
+
description = "Create a new product";
|
|
31
|
+
inputSchema = z.object({
|
|
32
|
+
product: z.object({
|
|
33
|
+
name: z.string(),
|
|
34
|
+
description: z.string(),
|
|
35
|
+
price: z.number()
|
|
36
|
+
})
|
|
37
|
+
});
|
|
32
38
|
|
|
33
39
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
return product.data.create(input.product);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class UpdateProductTool implements LuaTool {
|
|
45
|
+
name = "update_product";
|
|
46
|
+
description = "Update an existing product";
|
|
47
|
+
inputSchema = z.object({
|
|
48
|
+
product: z.object({
|
|
49
|
+
id: z.string(),
|
|
50
|
+
name: z.string(),
|
|
51
|
+
description: z.string(),
|
|
52
|
+
price: z.number()
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
57
|
+
return product.data.update(input.product, input.product.id);
|
|
42
58
|
}
|
|
43
59
|
}
|
|
60
|
+
|
|
61
|
+
export class DeleteProductTool implements LuaTool {
|
|
62
|
+
name = "delete_product";
|
|
63
|
+
description = "Delete an existing product";
|
|
64
|
+
inputSchema = z.object({
|
|
65
|
+
id: z.string()
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
69
|
+
return product.data.delete(input.id);
|
|
70
|
+
}
|
|
71
|
+
}
|