@garrix82/reactgenie-dsl 1.0.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 +436 -0
- package/dist/__test__/dsl-descriptor.test.d.ts +1 -0
- package/dist/__test__/dsl-descriptor.test.js +27 -0
- package/dist/__test__/dsl-descriptor.test.js.map +1 -0
- package/dist/__test__/example_descriptor.d.ts +125 -0
- package/dist/__test__/example_descriptor.js +607 -0
- package/dist/__test__/example_descriptor.js.map +1 -0
- package/dist/__test__/food_descriptor.state.json +1 -0
- package/dist/__test__/food_descriptor.test.d.ts +74 -0
- package/dist/__test__/food_descriptor.test.js +205 -0
- package/dist/__test__/food_descriptor.test.js.map +1 -0
- package/dist/__test__/nl-interpreter-provider-selection.test.d.ts +1 -0
- package/dist/__test__/nl-interpreter-provider-selection.test.js +73 -0
- package/dist/__test__/nl-interpreter-provider-selection.test.js.map +1 -0
- package/dist/__test__/nl-interpreter.test.d.ts +1 -0
- package/dist/__test__/nl-interpreter.test.js +86 -0
- package/dist/__test__/nl-interpreter.test.js.map +1 -0
- package/dist/decorators/__test__/decorators.test.d.ts +1 -0
- package/dist/decorators/__test__/decorators.test.js +182 -0
- package/dist/decorators/__test__/decorators.test.js.map +1 -0
- package/dist/decorators/__test__/inheritance-descriptor.test.d.ts +1 -0
- package/dist/decorators/__test__/inheritance-descriptor.test.js +107 -0
- package/dist/decorators/__test__/inheritance-descriptor.test.js.map +1 -0
- package/dist/decorators/decorators.d.ts +20 -0
- package/dist/decorators/decorators.js +520 -0
- package/dist/decorators/decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/store.d.ts +12 -0
- package/dist/decorators/store.js +43 -0
- package/dist/decorators/store.js.map +1 -0
- package/dist/dsl/__test__/dsl-interpreter.test.d.ts +1 -0
- package/dist/dsl/__test__/dsl-interpreter.test.js +334 -0
- package/dist/dsl/__test__/dsl-interpreter.test.js.map +1 -0
- package/dist/dsl/__test__/parser.gen.test.d.ts +1 -0
- package/dist/dsl/__test__/parser.gen.test.js +283 -0
- package/dist/dsl/__test__/parser.gen.test.js.map +1 -0
- package/dist/dsl/dsl-interpreter.d.ts +66 -0
- package/dist/dsl/dsl-interpreter.js +767 -0
- package/dist/dsl/dsl-interpreter.js.map +1 -0
- package/dist/dsl/index.d.ts +1 -0
- package/dist/dsl/index.js +18 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/dsl/parser.gen.d.ts +10 -0
- package/dist/dsl/parser.gen.js +1524 -0
- package/dist/dsl/parser.gen.js.map +1 -0
- package/dist/dsl-descriptor.d.ts +75 -0
- package/dist/dsl-descriptor.js +151 -0
- package/dist/dsl-descriptor.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/nl/__test__/context-aware-prompt.test.d.ts +1 -0
- package/dist/nl/__test__/context-aware-prompt.test.js +247 -0
- package/dist/nl/__test__/context-aware-prompt.test.js.map +1 -0
- package/dist/nl/__test__/context-selector.test.d.ts +1 -0
- package/dist/nl/__test__/context-selector.test.js +20 -0
- package/dist/nl/__test__/context-selector.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser-groq-transport.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser-groq-transport.test.js +87 -0
- package/dist/nl/__test__/nl-parser-groq-transport.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser-openai-parity.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser-openai-parity.test.js +206 -0
- package/dist/nl/__test__/nl-parser-openai-parity.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser-openai-sampling.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js +44 -0
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser-openai-transport.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser-openai-transport.test.js +55 -0
- package/dist/nl/__test__/nl-parser-openai-transport.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser-utils.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser-utils.test.js +70 -0
- package/dist/nl/__test__/nl-parser-utils.test.js.map +1 -0
- package/dist/nl/__test__/nl-parser.test.d.ts +1 -0
- package/dist/nl/__test__/nl-parser.test.js +64 -0
- package/dist/nl/__test__/nl-parser.test.js.map +1 -0
- package/dist/nl/__test__/parameter-tuning.test.d.ts +1 -0
- package/dist/nl/__test__/parameter-tuning.test.js +95 -0
- package/dist/nl/__test__/parameter-tuning.test.js.map +1 -0
- package/dist/nl/__test__/semantic-parsing-experiment.test.d.ts +1 -0
- package/dist/nl/__test__/semantic-parsing-experiment.test.js +178 -0
- package/dist/nl/__test__/semantic-parsing-experiment.test.js.map +1 -0
- package/dist/nl/context-selector.d.ts +17 -0
- package/dist/nl/context-selector.js +99 -0
- package/dist/nl/context-selector.js.map +1 -0
- package/dist/nl/index.d.ts +6 -0
- package/dist/nl/index.js +15 -0
- package/dist/nl/index.js.map +1 -0
- package/dist/nl/llm-monitoring.d.ts +49 -0
- package/dist/nl/llm-monitoring.js +243 -0
- package/dist/nl/llm-monitoring.js.map +1 -0
- package/dist/nl/llm-monitoring.test.d.ts +5 -0
- package/dist/nl/llm-monitoring.test.js +101 -0
- package/dist/nl/llm-monitoring.test.js.map +1 -0
- package/dist/nl/nl-parser-groq.d.ts +21 -0
- package/dist/nl/nl-parser-groq.js +357 -0
- package/dist/nl/nl-parser-groq.js.map +1 -0
- package/dist/nl/nl-parser-utils.d.ts +101 -0
- package/dist/nl/nl-parser-utils.js +255 -0
- package/dist/nl/nl-parser-utils.js.map +1 -0
- package/dist/nl/nl-parser.d.ts +30 -0
- package/dist/nl/nl-parser.js +433 -0
- package/dist/nl/nl-parser.js.map +1 -0
- package/dist/nl/prompt-gen.d.ts +93 -0
- package/dist/nl/prompt-gen.js +369 -0
- package/dist/nl/prompt-gen.js.map +1 -0
- package/dist/nl/prompt-res.d.ts +16 -0
- package/dist/nl/prompt-res.js +190 -0
- package/dist/nl/prompt-res.js.map +1 -0
- package/dist/nl-interpreter.d.ts +48 -0
- package/dist/nl-interpreter.js +155 -0
- package/dist/nl-interpreter.js.map +1 -0
- package/lib/__test__/dsl-descriptor.test.ts +27 -0
- package/lib/__test__/example_descriptor.ts +762 -0
- package/lib/__test__/food_descriptor.state.json +1 -0
- package/lib/__test__/food_descriptor.test.ts +331 -0
- package/lib/__test__/nl-interpreter-provider-selection.test.ts +126 -0
- package/lib/__test__/nl-interpreter.test.ts +129 -0
- package/lib/decorators/__test__/decorators.test.ts +177 -0
- package/lib/decorators/__test__/inheritance-descriptor.test.ts +92 -0
- package/lib/decorators/decorators.ts +754 -0
- package/lib/decorators/index.ts +2 -0
- package/lib/decorators/store.ts +47 -0
- package/lib/dsl/__test__/dsl-interpreter.test.ts +453 -0
- package/lib/dsl/__test__/parser.gen.test.ts +296 -0
- package/lib/dsl/dsl-interpreter.ts +974 -0
- package/lib/dsl/index.ts +1 -0
- package/lib/dsl/parser.gen.js +1479 -0
- package/lib/dsl/parser.pegjs +130 -0
- package/lib/dsl-descriptor.ts +241 -0
- package/lib/index.ts +5 -0
- package/lib/nl/__test__/context-aware-prompt.test.ts +372 -0
- package/lib/nl/__test__/context-selector.test.ts +27 -0
- package/lib/nl/__test__/nl-parser-groq-transport.test.ts +139 -0
- package/lib/nl/__test__/nl-parser-openai-parity.test.ts +381 -0
- package/lib/nl/__test__/nl-parser-openai-sampling.test.ts +73 -0
- package/lib/nl/__test__/nl-parser-openai-transport.test.ts +79 -0
- package/lib/nl/__test__/nl-parser-utils.test.ts +98 -0
- package/lib/nl/__test__/nl-parser.test.ts +119 -0
- package/lib/nl/__test__/parameter-tuning.test.ts +137 -0
- package/lib/nl/__test__/semantic-parsing-experiment.test.ts +260 -0
- package/lib/nl/context-selector.ts +123 -0
- package/lib/nl/index.ts +19 -0
- package/lib/nl/llm-monitoring.test.ts +136 -0
- package/lib/nl/llm-monitoring.ts +339 -0
- package/lib/nl/nl-parser-groq.ts +510 -0
- package/lib/nl/nl-parser-utils.ts +310 -0
- package/lib/nl/nl-parser.ts +616 -0
- package/lib/nl/prompt-gen.ts +607 -0
- package/lib/nl/prompt-res.ts +207 -0
- package/lib/nl-interpreter.ts +262 -0
- package/package.json +58 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { parse } from "../parser.gen.js";
|
|
2
|
+
|
|
3
|
+
test("parse", () => {
|
|
4
|
+
const result = parse(
|
|
5
|
+
"Order.past_orders.between(field:.order_date,from:Date.today.add_date(day:-7).day_of_the_same_week(new_day_of_the_week:Day.Monday),to:Date.today.add_date(day:-7).day_of_the_same_week(new_day_of_the_week:Day.Sunday))[0].foods[0]",
|
|
6
|
+
{}
|
|
7
|
+
)[0];
|
|
8
|
+
expect(result).toEqual({
|
|
9
|
+
type: "index",
|
|
10
|
+
parent: {
|
|
11
|
+
type: "access",
|
|
12
|
+
parent: {
|
|
13
|
+
type: "index",
|
|
14
|
+
parent: {
|
|
15
|
+
type: "access",
|
|
16
|
+
parent: { type: "access", parent: "Order", access: "past_orders" },
|
|
17
|
+
access: {
|
|
18
|
+
type: "function_call",
|
|
19
|
+
func_name: "between",
|
|
20
|
+
parameters: [
|
|
21
|
+
{
|
|
22
|
+
parameter: "field",
|
|
23
|
+
value: { type: "accessor", field: "order_date" },
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
parameter: "from",
|
|
27
|
+
value: {
|
|
28
|
+
type: "access",
|
|
29
|
+
parent: {
|
|
30
|
+
type: "access",
|
|
31
|
+
parent: { type: "access", parent: "Date", access: "today" },
|
|
32
|
+
access: {
|
|
33
|
+
type: "function_call",
|
|
34
|
+
func_name: "add_date",
|
|
35
|
+
parameters: [
|
|
36
|
+
{ parameter: "day", value: { type: "int", value: -7 } },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
access: {
|
|
41
|
+
type: "function_call",
|
|
42
|
+
func_name: "day_of_the_same_week",
|
|
43
|
+
parameters: [
|
|
44
|
+
{
|
|
45
|
+
parameter: "new_day_of_the_week",
|
|
46
|
+
value: {
|
|
47
|
+
type: "access",
|
|
48
|
+
parent: "Day",
|
|
49
|
+
access: "Monday",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
parameter: "to",
|
|
58
|
+
value: {
|
|
59
|
+
type: "access",
|
|
60
|
+
parent: {
|
|
61
|
+
type: "access",
|
|
62
|
+
parent: { type: "access", parent: "Date", access: "today" },
|
|
63
|
+
access: {
|
|
64
|
+
type: "function_call",
|
|
65
|
+
func_name: "add_date",
|
|
66
|
+
parameters: [
|
|
67
|
+
{ parameter: "day", value: { type: "int", value: -7 } },
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
access: {
|
|
72
|
+
type: "function_call",
|
|
73
|
+
func_name: "day_of_the_same_week",
|
|
74
|
+
parameters: [
|
|
75
|
+
{
|
|
76
|
+
parameter: "new_day_of_the_week",
|
|
77
|
+
value: {
|
|
78
|
+
type: "access",
|
|
79
|
+
parent: "Day",
|
|
80
|
+
access: "Sunday",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
index: 0,
|
|
91
|
+
},
|
|
92
|
+
access: "foods",
|
|
93
|
+
},
|
|
94
|
+
index: 0,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const result2 = parse(
|
|
98
|
+
'Restaurant.default.matching(field: .name, value: "Panda Express")[0].remove_favorite_restaurant()'
|
|
99
|
+
)[0];
|
|
100
|
+
expect(result2).toEqual({
|
|
101
|
+
type: "access",
|
|
102
|
+
parent: {
|
|
103
|
+
type: "index",
|
|
104
|
+
parent: {
|
|
105
|
+
type: "access",
|
|
106
|
+
parent: { type: "access", parent: "Restaurant", access: "default" },
|
|
107
|
+
access: {
|
|
108
|
+
type: "function_call",
|
|
109
|
+
func_name: "matching",
|
|
110
|
+
parameters: [
|
|
111
|
+
{ parameter: "field", value: { type: "accessor", field: "name" } },
|
|
112
|
+
{
|
|
113
|
+
parameter: "value",
|
|
114
|
+
value: { type: "string", value: "Panda Express" },
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
index: 0,
|
|
120
|
+
},
|
|
121
|
+
access: {
|
|
122
|
+
type: "function_call",
|
|
123
|
+
func_name: "remove_favorite_restaurant",
|
|
124
|
+
parameters: null,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const result3 = parse(
|
|
129
|
+
'Current.order.add_to_order(foods: [Current.food.matching(field: .name, value: "hamburger")])'
|
|
130
|
+
)[0];
|
|
131
|
+
expect(result3).toEqual({
|
|
132
|
+
type: "access",
|
|
133
|
+
parent: { type: "access", parent: "Current", access: "order" },
|
|
134
|
+
access: {
|
|
135
|
+
type: "function_call",
|
|
136
|
+
func_name: "add_to_order",
|
|
137
|
+
parameters: [
|
|
138
|
+
{
|
|
139
|
+
parameter: "foods",
|
|
140
|
+
value: {
|
|
141
|
+
type: "array",
|
|
142
|
+
value: [
|
|
143
|
+
{
|
|
144
|
+
type: "access",
|
|
145
|
+
parent: { type: "access", parent: "Current", access: "food" },
|
|
146
|
+
access: {
|
|
147
|
+
type: "function_call",
|
|
148
|
+
func_name: "matching",
|
|
149
|
+
parameters: [
|
|
150
|
+
{
|
|
151
|
+
parameter: "field",
|
|
152
|
+
value: { type: "accessor", field: "name" },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
parameter: "value",
|
|
156
|
+
value: { type: "string", value: "hamburger" },
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const result4 = parse(
|
|
169
|
+
'Order.current.add_to_order(foods: [Restaurant.all.matching(field: .name, value: "mcDonalds")[0].get_menu().matching(field: .name, value: "coke")[0]])'
|
|
170
|
+
)[0];
|
|
171
|
+
expect(result4).toEqual({
|
|
172
|
+
type: "access",
|
|
173
|
+
parent: { type: "access", parent: "Order", access: "current" },
|
|
174
|
+
access: {
|
|
175
|
+
type: "function_call",
|
|
176
|
+
func_name: "add_to_order",
|
|
177
|
+
parameters: [
|
|
178
|
+
{
|
|
179
|
+
parameter: "foods",
|
|
180
|
+
value: {
|
|
181
|
+
type: "array",
|
|
182
|
+
value: [
|
|
183
|
+
{
|
|
184
|
+
type: "index",
|
|
185
|
+
parent: {
|
|
186
|
+
type: "access",
|
|
187
|
+
parent: {
|
|
188
|
+
type: "access",
|
|
189
|
+
parent: {
|
|
190
|
+
type: "index",
|
|
191
|
+
parent: {
|
|
192
|
+
type: "access",
|
|
193
|
+
parent: {
|
|
194
|
+
type: "access",
|
|
195
|
+
parent: "Restaurant",
|
|
196
|
+
access: "all",
|
|
197
|
+
},
|
|
198
|
+
access: {
|
|
199
|
+
type: "function_call",
|
|
200
|
+
func_name: "matching",
|
|
201
|
+
parameters: [
|
|
202
|
+
{
|
|
203
|
+
parameter: "field",
|
|
204
|
+
value: { type: "accessor", field: "name" },
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
parameter: "value",
|
|
208
|
+
value: { type: "string", value: "mcDonalds" },
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
index: 0,
|
|
214
|
+
},
|
|
215
|
+
access: {
|
|
216
|
+
type: "function_call",
|
|
217
|
+
func_name: "get_menu",
|
|
218
|
+
parameters: null,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
access: {
|
|
222
|
+
type: "function_call",
|
|
223
|
+
func_name: "matching",
|
|
224
|
+
parameters: [
|
|
225
|
+
{
|
|
226
|
+
parameter: "field",
|
|
227
|
+
value: { type: "accessor", field: "name" },
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
parameter: "value",
|
|
231
|
+
value: { type: "string", value: "coke" },
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
index: 0,
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
const result5 = parse(
|
|
245
|
+
"Order.all().sort(field: .date, ascending: true)[0].restaurant.name"
|
|
246
|
+
)[0];
|
|
247
|
+
expect(result5).toEqual({
|
|
248
|
+
access: "name",
|
|
249
|
+
parent: {
|
|
250
|
+
access: "restaurant",
|
|
251
|
+
parent: {
|
|
252
|
+
index: 0,
|
|
253
|
+
parent: {
|
|
254
|
+
access: {
|
|
255
|
+
func_name: "sort",
|
|
256
|
+
parameters: [
|
|
257
|
+
{
|
|
258
|
+
parameter: "field",
|
|
259
|
+
value: {
|
|
260
|
+
field: "date",
|
|
261
|
+
type: "accessor",
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
parameter: "ascending",
|
|
266
|
+
value: {
|
|
267
|
+
type: "boolean",
|
|
268
|
+
value: true,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
type: "function_call",
|
|
273
|
+
},
|
|
274
|
+
parent: {
|
|
275
|
+
access: {
|
|
276
|
+
func_name: "all",
|
|
277
|
+
parameters: null,
|
|
278
|
+
type: "function_call",
|
|
279
|
+
},
|
|
280
|
+
parent: "Order",
|
|
281
|
+
type: "access",
|
|
282
|
+
},
|
|
283
|
+
type: "access",
|
|
284
|
+
},
|
|
285
|
+
type: "index",
|
|
286
|
+
},
|
|
287
|
+
type: "access",
|
|
288
|
+
},
|
|
289
|
+
type: "access",
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test("parser error test", () => {
|
|
294
|
+
const result = parse("Booking.Current().payment.setProperty(method: \"MasterCard\"); Booking.Current().confirm();");
|
|
295
|
+
console.log(result);
|
|
296
|
+
});
|