@garrix82/reactgenie-dsl 1.0.0 → 1.0.2
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/.env +10 -0
- package/.env.example +17 -0
- package/.github/workflows/publish.yml +20 -0
- package/README.md +5 -1
- package/package.json +1 -5
- package/dist/__test__/dsl-descriptor.test.d.ts +0 -1
- package/dist/__test__/dsl-descriptor.test.js +0 -27
- package/dist/__test__/dsl-descriptor.test.js.map +0 -1
- package/dist/__test__/example_descriptor.d.ts +0 -125
- package/dist/__test__/example_descriptor.js +0 -607
- package/dist/__test__/example_descriptor.js.map +0 -1
- package/dist/__test__/food_descriptor.state.json +0 -1
- package/dist/__test__/food_descriptor.test.d.ts +0 -74
- package/dist/__test__/food_descriptor.test.js +0 -205
- package/dist/__test__/food_descriptor.test.js.map +0 -1
- package/dist/__test__/nl-interpreter-provider-selection.test.d.ts +0 -1
- package/dist/__test__/nl-interpreter-provider-selection.test.js +0 -73
- package/dist/__test__/nl-interpreter-provider-selection.test.js.map +0 -1
- package/dist/__test__/nl-interpreter.test.d.ts +0 -1
- package/dist/__test__/nl-interpreter.test.js +0 -86
- package/dist/__test__/nl-interpreter.test.js.map +0 -1
- package/dist/decorators/__test__/decorators.test.d.ts +0 -1
- package/dist/decorators/__test__/decorators.test.js +0 -182
- package/dist/decorators/__test__/decorators.test.js.map +0 -1
- package/dist/decorators/__test__/inheritance-descriptor.test.d.ts +0 -1
- package/dist/decorators/__test__/inheritance-descriptor.test.js +0 -107
- package/dist/decorators/__test__/inheritance-descriptor.test.js.map +0 -1
- package/dist/dsl/__test__/dsl-interpreter.test.d.ts +0 -1
- package/dist/dsl/__test__/dsl-interpreter.test.js +0 -334
- package/dist/dsl/__test__/dsl-interpreter.test.js.map +0 -1
- package/dist/dsl/__test__/parser.gen.test.d.ts +0 -1
- package/dist/dsl/__test__/parser.gen.test.js +0 -283
- package/dist/dsl/__test__/parser.gen.test.js.map +0 -1
- package/dist/nl/__test__/context-aware-prompt.test.d.ts +0 -1
- package/dist/nl/__test__/context-aware-prompt.test.js +0 -247
- package/dist/nl/__test__/context-aware-prompt.test.js.map +0 -1
- package/dist/nl/__test__/context-selector.test.d.ts +0 -1
- package/dist/nl/__test__/context-selector.test.js +0 -20
- package/dist/nl/__test__/context-selector.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-groq-transport.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-groq-transport.test.js +0 -87
- package/dist/nl/__test__/nl-parser-groq-transport.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-parity.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-parity.test.js +0 -206
- package/dist/nl/__test__/nl-parser-openai-parity.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-sampling.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js +0 -44
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-transport.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-transport.test.js +0 -55
- package/dist/nl/__test__/nl-parser-openai-transport.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-utils.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-utils.test.js +0 -70
- package/dist/nl/__test__/nl-parser-utils.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser.test.js +0 -64
- package/dist/nl/__test__/nl-parser.test.js.map +0 -1
- package/dist/nl/__test__/parameter-tuning.test.d.ts +0 -1
- package/dist/nl/__test__/parameter-tuning.test.js +0 -95
- package/dist/nl/__test__/parameter-tuning.test.js.map +0 -1
- package/dist/nl/__test__/semantic-parsing-experiment.test.d.ts +0 -1
- package/dist/nl/__test__/semantic-parsing-experiment.test.js +0 -178
- package/dist/nl/__test__/semantic-parsing-experiment.test.js.map +0 -1
- package/dist/nl/llm-monitoring.test.d.ts +0 -5
- package/dist/nl/llm-monitoring.test.js +0 -101
- package/dist/nl/llm-monitoring.test.js.map +0 -1
- package/lib/__test__/dsl-descriptor.test.ts +0 -27
- package/lib/__test__/example_descriptor.ts +0 -762
- package/lib/__test__/food_descriptor.state.json +0 -1
- package/lib/__test__/food_descriptor.test.ts +0 -331
- package/lib/__test__/nl-interpreter-provider-selection.test.ts +0 -126
- package/lib/__test__/nl-interpreter.test.ts +0 -129
- package/lib/decorators/__test__/decorators.test.ts +0 -177
- package/lib/decorators/__test__/inheritance-descriptor.test.ts +0 -92
- package/lib/decorators/decorators.ts +0 -754
- package/lib/decorators/index.ts +0 -2
- package/lib/decorators/store.ts +0 -47
- package/lib/dsl/__test__/dsl-interpreter.test.ts +0 -453
- package/lib/dsl/__test__/parser.gen.test.ts +0 -296
- package/lib/dsl/dsl-interpreter.ts +0 -974
- package/lib/dsl/index.ts +0 -1
- package/lib/dsl/parser.gen.js +0 -1479
- package/lib/dsl/parser.pegjs +0 -130
- package/lib/dsl-descriptor.ts +0 -241
- package/lib/index.ts +0 -5
- package/lib/nl/__test__/context-aware-prompt.test.ts +0 -372
- package/lib/nl/__test__/context-selector.test.ts +0 -27
- package/lib/nl/__test__/nl-parser-groq-transport.test.ts +0 -139
- package/lib/nl/__test__/nl-parser-openai-parity.test.ts +0 -381
- package/lib/nl/__test__/nl-parser-openai-sampling.test.ts +0 -73
- package/lib/nl/__test__/nl-parser-openai-transport.test.ts +0 -79
- package/lib/nl/__test__/nl-parser-utils.test.ts +0 -98
- package/lib/nl/__test__/nl-parser.test.ts +0 -119
- package/lib/nl/__test__/parameter-tuning.test.ts +0 -137
- package/lib/nl/__test__/semantic-parsing-experiment.test.ts +0 -260
- package/lib/nl/context-selector.ts +0 -123
- package/lib/nl/index.ts +0 -19
- package/lib/nl/llm-monitoring.test.ts +0 -136
- package/lib/nl/llm-monitoring.ts +0 -339
- package/lib/nl/nl-parser-groq.ts +0 -510
- package/lib/nl/nl-parser-utils.ts +0 -310
- package/lib/nl/nl-parser.ts +0 -616
- package/lib/nl/prompt-gen.ts +0 -607
- package/lib/nl/prompt-res.ts +0 -207
- package/lib/nl-interpreter.ts +0 -262
|
@@ -1,296 +0,0 @@
|
|
|
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
|
-
});
|