@xuda.io/ai_module 1.1.4157 → 1.1.4159
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/index.mjs +606 -614
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1062,638 +1062,626 @@ const check_studio_doc_tool = tool({
|
|
|
1062
1062
|
},
|
|
1063
1063
|
});
|
|
1064
1064
|
|
|
1065
|
-
export const submit_agentic_studio_chat_gpt_prompt = async function (req) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1065
|
+
// export const submit_agentic_studio_chat_gpt_prompt = async function (req) {
|
|
1066
|
+
// try {
|
|
1067
|
+
// const { user_prompt, object_unit = 'app', uid, app_id } = req;
|
|
1068
|
+
// // const model = 'ft:gpt-4o-2024-08-06:xuda-io:vps-hosting-plans:CDaxQiXo'; // 'gpt-4o'; //'gpt-4.1'; //
|
|
1069
1069
|
|
|
1070
|
-
|
|
1070
|
+
// const app_obj = await get_app_obj(app_id);
|
|
1071
1071
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1072
|
+
// // let check_results = {};
|
|
1073
|
+
// const auth = async function () {
|
|
1074
|
+
// if (app_obj.app_uId !== uid) {
|
|
1075
|
+
// const db_team = get_xuda_couch('xuda_team');
|
|
1076
|
+
// let master_auth_users = await db_team.view('xuda', 'user_active_shares', {
|
|
1077
|
+
// key: [uid, app_id],
|
|
1078
|
+
// });
|
|
1079
|
+
// if (!master_auth_users.rows.includes(uid)) {
|
|
1080
|
+
// throw new Error('user unauthorized');
|
|
1081
|
+
// }
|
|
1082
|
+
// }
|
|
1083
|
+
// };
|
|
1084
1084
|
|
|
1085
|
-
|
|
1085
|
+
// await auth();
|
|
1086
1086
|
|
|
1087
|
-
|
|
1087
|
+
// const userName = await get_user_name(uid);
|
|
1088
1088
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1089
|
+
// const get_zod_unit_schema = function (type) {
|
|
1090
|
+
// init(app_obj, {}, _, true, null, null, UglifyJS, JSON5, _conf, false, z);
|
|
1091
|
+
// const schema = get_zod_schema(type);
|
|
1092
|
+
// const jsonSchema = zodToJsonSchema(schema);
|
|
1093
|
+
// return JSON.stringify(jsonSchema, null, 2);
|
|
1094
|
+
// };
|
|
1095
1095
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
### Persona & Role ###
|
|
1103
|
-
- You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1104
|
-
|
|
1105
|
-
### Tasks ###
|
|
1106
|
-
|
|
1107
|
-
Your job is to assist the user with creating a ${user_prompt} that includes all tasks needed.
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
### workflow ###
|
|
1111
|
-
|
|
1112
|
-
Steps:
|
|
1113
|
-
1. list all the tables needed for the task.
|
|
1114
|
-
2. prefix each table with the subject of the ${user_prompt} (e.g: CRM - Tasks).
|
|
1115
|
-
3. iterate the table list and build tables array using the Table builder tool, add the Table builder tool results and the table name in array RESULTS_ARR.
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
### Additional information ###
|
|
1119
|
-
|
|
1120
|
-
|
|
1096
|
+
// const get_app_instructions = function (object_unit) {
|
|
1097
|
+
// return `
|
|
1098
|
+
// ### context ###
|
|
1099
|
+
// uid=${uid}
|
|
1100
|
+
// app_id=${app_id}
|
|
1121
1101
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1102
|
+
// ### Persona & Role ###
|
|
1103
|
+
// - You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1124
1104
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
`;
|
|
1128
|
-
};
|
|
1105
|
+
// ### Tasks ###
|
|
1129
1106
|
|
|
1130
|
-
|
|
1131
|
-
return `
|
|
1132
|
-
### context ###
|
|
1133
|
-
uid=${uid}
|
|
1134
|
-
app_id=${app_id}
|
|
1135
|
-
|
|
1136
|
-
### Persona & Role ###
|
|
1137
|
-
- You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1138
|
-
|
|
1139
|
-
### Tasks ###
|
|
1140
|
-
|
|
1141
|
-
Your job is to assist the user with creating a ${user_prompt} that includes a full set of fields according to the provided ${object_unit} structure.
|
|
1142
|
-
|
|
1143
|
-
- You must include all relevant fields a typical ${user_prompt} would require
|
|
1144
|
-
- Add **multiple entries** in the "tableFields" array as needed to fully represent the structure.
|
|
1145
|
-
- Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1146
|
-
- use uid for "createdByUid" and "checkedInUserId"
|
|
1147
|
-
|
|
1148
|
-
### workflow ###
|
|
1149
|
-
|
|
1150
|
-
Steps:
|
|
1151
|
-
1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1152
|
-
|
|
1153
|
-
3. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 3 times the throw error, skip **Save Doc** tool if errors exist
|
|
1154
|
-
4. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
### Output ###
|
|
1158
|
-
if success: {code:1,data:save_result}
|
|
1159
|
-
if fail: {code:-1,data:error}
|
|
1160
|
-
|
|
1161
|
-
### EXAMPLE
|
|
1162
|
-
|
|
1163
|
-
{
|
|
1164
|
-
"_id": "5b1_tbl_47f0ac6059ca",
|
|
1165
|
-
"app_id": "prj3937cb6f9a31c8c7dea25055bba845b1",
|
|
1166
|
-
"stat": 3,
|
|
1167
|
-
"docType": "studio",
|
|
1168
|
-
"docDate": 1714916369797,
|
|
1169
|
-
"ts": 1762953659001,
|
|
1170
|
-
"order_ts": 1714916369797,
|
|
1171
|
-
"studio_meta": {
|
|
1172
|
-
"created": 1714916369797,
|
|
1173
|
-
"createdByUid": "341cf2d32991a68e4d8aaba6c16e15cc",
|
|
1174
|
-
"checkedInUserId": "341cf2d32991a68e4d8aaba6c16e15cc",
|
|
1175
|
-
"checkedInUserName": "Ioshka Media",
|
|
1176
|
-
"parentId": "database",
|
|
1177
|
-
"savedByUid": "341cf2d32991a68e4d8aaba6c16e15cc"
|
|
1178
|
-
},
|
|
1179
|
-
"properties": {
|
|
1180
|
-
"menuType": "table",
|
|
1181
|
-
"menuName": "PT - Practice Table",
|
|
1182
|
-
"databaseSocket": "@xuda.io/xuda-dbs-plugin-xuda",
|
|
1183
|
-
"menuTitle": "PT - Practice Table"
|
|
1184
|
-
},
|
|
1185
|
-
"tableIndexes": [
|
|
1186
|
-
{
|
|
1187
|
-
"id": "76bbf201-997e-402c-b435-0649cc25d117",
|
|
1188
|
-
"data": {
|
|
1189
|
-
"name": "Primary_Index",
|
|
1190
|
-
"unique": true,
|
|
1191
|
-
"keys": [
|
|
1192
|
-
"PT_Id"
|
|
1193
|
-
]
|
|
1194
|
-
},
|
|
1195
|
-
"props": {} <-- must appear even if empty
|
|
1196
|
-
},
|
|
1197
|
-
{
|
|
1198
|
-
"id": "89f1609d-de4e-4b61-9357-284b1261314c",
|
|
1199
|
-
"data": {
|
|
1200
|
-
"name": "Index_2",
|
|
1201
|
-
"unique": false,
|
|
1202
|
-
"keys": [
|
|
1203
|
-
"PT_Stat",
|
|
1204
|
-
"PT_Group_Id"
|
|
1205
|
-
]
|
|
1206
|
-
},
|
|
1207
|
-
"props": {} <-- must appear even if empty
|
|
1208
|
-
}
|
|
1209
|
-
],
|
|
1210
|
-
"tableFields": [
|
|
1211
|
-
{
|
|
1212
|
-
"id": "b41aa880-56ec-4029-a21b-60c89a52b62e",
|
|
1213
|
-
"data": {
|
|
1214
|
-
"field_id": "PT_Id"
|
|
1215
|
-
},
|
|
1216
|
-
"props": {
|
|
1217
|
-
"label":"Practice Id",
|
|
1218
|
-
"fieldType": "string",
|
|
1219
|
-
"mandatory": true
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
"id": "8aec82db-35d9-4828-9fc7-49373c531cc3",
|
|
1225
|
-
"data": {
|
|
1226
|
-
"field_id": "PT_Type"
|
|
1227
|
-
},
|
|
1228
|
-
"props": {
|
|
1229
|
-
"label":"Practice Type",
|
|
1230
|
-
"fieldType": "string",
|
|
1231
|
-
"mandatory": true
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
},
|
|
1235
|
-
{
|
|
1236
|
-
"id": "d27c56e5-faec-4a0a-ad42-7bf55f8c67b3",
|
|
1237
|
-
"data": {
|
|
1238
|
-
"field_id": "PT_Stat"
|
|
1239
|
-
},
|
|
1240
|
-
"props": {
|
|
1241
|
-
"label":"Practice Status",
|
|
1242
|
-
"fieldType": "number",
|
|
1243
|
-
"fieldComment": "1 = Draft\n2 = Private\n3 = Public\n4 = Deleted",
|
|
1244
|
-
"mandatory": true
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
},
|
|
1248
|
-
{
|
|
1249
|
-
"id": "659fbfb3-7dcc-4ea0-b1e9-5dd9553a99fc",
|
|
1250
|
-
"data": {
|
|
1251
|
-
"field_id": "PT_Question"
|
|
1252
|
-
},
|
|
1253
|
-
"props": {
|
|
1254
|
-
"label":"Practice Question",
|
|
1255
|
-
"fieldType": "string"
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
},
|
|
1259
|
-
{
|
|
1260
|
-
"id": "080c8ceb-5a51-437b-8ad1-9fc005c79011",
|
|
1261
|
-
"data": {
|
|
1262
|
-
"field_id": "PT_Options"
|
|
1263
|
-
},
|
|
1264
|
-
"props": {
|
|
1265
|
-
"label":"Practice Options",
|
|
1266
|
-
"fieldType": "array"
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
},
|
|
1270
|
-
{
|
|
1271
|
-
"id": "72c04aac-b3e7-4e7a-8a74-31075de3dbec",
|
|
1272
|
-
"data": {
|
|
1273
|
-
"field_id": "PT_Answer"
|
|
1274
|
-
},
|
|
1275
|
-
"props": {
|
|
1276
|
-
"label":"Practice Answer",
|
|
1277
|
-
"fieldType": "string"
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
"id": "e37b08c6-f340-425a-bf01-809b28a486d3",
|
|
1283
|
-
"data": {
|
|
1284
|
-
"field_id": "PT_Matching_Answer"
|
|
1285
|
-
},
|
|
1286
|
-
"props": {
|
|
1287
|
-
"label":"Practice Matching Answer",
|
|
1288
|
-
"fieldType": "object"
|
|
1289
|
-
},
|
|
1290
|
-
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
"id": "8ca4ace1-2010-45be-b7aa-2672ce0e6fea",
|
|
1294
|
-
"data": {
|
|
1295
|
-
"field_id": "PT_Group_Id"
|
|
1296
|
-
},
|
|
1297
|
-
"props": {
|
|
1298
|
-
"label":"Practice Group Id",
|
|
1299
|
-
"fieldType": "string"
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
"id": "ae749c6d-1f39-4750-b79e-f016d50b8a11",
|
|
1305
|
-
"data": {
|
|
1306
|
-
"field_id": "PT_Difficulty"
|
|
1307
|
-
},
|
|
1308
|
-
"props": {
|
|
1309
|
-
"label":"Practice Difficulty",
|
|
1310
|
-
"fieldType": "number"
|
|
1311
|
-
},
|
|
1312
|
-
|
|
1313
|
-
},
|
|
1314
|
-
{
|
|
1315
|
-
"id": "5c5e7cb5-feee-4bc7-9d94-0ccd04a5eb06",
|
|
1316
|
-
"data": {
|
|
1317
|
-
"field_id": "PT_Uid"
|
|
1318
|
-
},
|
|
1319
|
-
"props": {
|
|
1320
|
-
"label":"Practice User Id",
|
|
1321
|
-
"fieldType": "string"
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
]
|
|
1326
|
-
}
|
|
1327
|
-
`;
|
|
1328
|
-
};
|
|
1107
|
+
// Your job is to assist the user with creating a ${user_prompt} that includes all tasks needed.
|
|
1329
1108
|
|
|
1330
|
-
|
|
1331
|
-
return `
|
|
1332
|
-
### context ###
|
|
1333
|
-
uid=${uid}
|
|
1334
|
-
app_id=${app_id}
|
|
1335
|
-
|
|
1336
|
-
### Persona & Role ###
|
|
1337
|
-
- You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1338
|
-
|
|
1339
|
-
### Tasks ###
|
|
1340
|
-
|
|
1341
|
-
Your job is to assist the user with creating a ${user_prompt}.
|
|
1342
|
-
|
|
1343
|
-
- Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1344
|
-
- use uid for "createdByUid" and "checkedInUserId"
|
|
1345
|
-
|
|
1346
|
-
### workflow ###
|
|
1347
|
-
|
|
1348
|
-
Steps:
|
|
1349
|
-
1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1350
|
-
2. Get the ${object_unit} structure example from ### Structure and Examples ### section.
|
|
1351
|
-
3. Build the ${object_unit} and validate against vs_68af4c84631c81919709268c2d0f1687
|
|
1352
|
-
4. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 3 times the throw error, skip **Save Doc** tool if errors exist
|
|
1353
|
-
5. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
### Additional information ###
|
|
1357
|
-
${studio_units[object_unit].short}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
### Output ###
|
|
1361
|
-
if success: {code:1,data:save_result}
|
|
1362
|
-
if fail: {code:-1,data:error}
|
|
1363
|
-
`;
|
|
1364
|
-
};
|
|
1109
|
+
// ### workflow ###
|
|
1365
1110
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
app_id=${app_id}
|
|
1371
|
-
|
|
1372
|
-
### Persona & Role ###
|
|
1373
|
-
- You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1374
|
-
|
|
1375
|
-
### Tasks ###
|
|
1376
|
-
|
|
1377
|
-
Your job is to assist the user with creating a ${user_prompt} that includes modern ui using Tailwind
|
|
1378
|
-
|
|
1379
|
-
- You must include all relevant fields a typical ${user_prompt} would require
|
|
1380
|
-
|
|
1381
|
-
- Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1382
|
-
- use uid for "createdByUid" and "checkedInUserId"
|
|
1383
|
-
|
|
1384
|
-
### workflow ###
|
|
1385
|
-
|
|
1386
|
-
Steps:
|
|
1387
|
-
1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1388
|
-
|
|
1389
|
-
2. use ### Structure and Examples ### section to build the object
|
|
1390
|
-
3. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 10 times the throw error, skip **Save Doc** tool if errors exist
|
|
1391
|
-
4. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
### Additional information ###
|
|
1395
|
-
${studio_units[object_unit].short}
|
|
1396
|
-
|
|
1397
|
-
### Structure and Examples ###
|
|
1398
|
-
|
|
1399
|
-
${get_zod_unit_schema('component')}
|
|
1400
|
-
|
|
1401
|
-
|
|
1111
|
+
// Steps:
|
|
1112
|
+
// 1. list all the tables needed for the task.
|
|
1113
|
+
// 2. prefix each table with the subject of the ${user_prompt} (e.g: CRM - Tasks).
|
|
1114
|
+
// 3. iterate the table list and build tables array using the Table builder tool, add the Table builder tool results and the table name in array RESULTS_ARR.
|
|
1402
1115
|
|
|
1116
|
+
// ### Additional information ###
|
|
1403
1117
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
if fail: {code:-1,data:error}
|
|
1407
|
-
`;
|
|
1408
|
-
};
|
|
1409
|
-
const get_get_data_instructions = function (object_unit) {
|
|
1410
|
-
return `
|
|
1411
|
-
### context ###
|
|
1412
|
-
uid=${uid}
|
|
1413
|
-
app_id=${app_id}
|
|
1414
|
-
|
|
1415
|
-
### Persona & Role ###
|
|
1416
|
-
- You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1417
|
-
|
|
1418
|
-
### Tasks ###
|
|
1419
|
-
|
|
1420
|
-
Your job is to assist the user with creating a ${user_prompt}.
|
|
1421
|
-
|
|
1422
|
-
- You must include all relevant fields a typical ${user_prompt} would require
|
|
1423
|
-
|
|
1424
|
-
- Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1425
|
-
- use uid for "createdByUid" and "checkedInUserId"
|
|
1426
|
-
|
|
1427
|
-
### workflow ###
|
|
1428
|
-
|
|
1429
|
-
Steps:
|
|
1430
|
-
1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1431
|
-
2. Get the ${object_unit} structure example from ### Structure and Examples ### section.
|
|
1432
|
-
3. Build the ${object_unit} and validate against vs_68af4c84631c81919709268c2d0f1687
|
|
1433
|
-
4. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 10 times the throw error, skip **Save Doc** tool if errors exist
|
|
1434
|
-
5. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
### Additional information ###
|
|
1438
|
-
${studio_units[object_unit].short}
|
|
1439
|
-
|
|
1440
|
-
### Output ###
|
|
1441
|
-
if success: {code:1,data:save_result}
|
|
1442
|
-
if fail: {code:-1,data:error}
|
|
1443
|
-
`;
|
|
1444
|
-
};
|
|
1118
|
+
// ### Output ###
|
|
1119
|
+
// return the RESULTS_ARR Array.
|
|
1445
1120
|
|
|
1446
|
-
|
|
1447
|
-
let _tools = [];
|
|
1448
|
-
for (const agent of agent_list) {
|
|
1449
|
-
const _agent = new Agent(studio_agents_obj[agent]);
|
|
1450
|
-
const tool = _agent.asTool({
|
|
1451
|
-
toolName: studio_agents_obj[agent].name,
|
|
1452
|
-
toolDescription: `Generate a ${agent} of the supplied text.`,
|
|
1453
|
-
});
|
|
1121
|
+
// ### Examples ###
|
|
1454
1122
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1123
|
+
// `;
|
|
1124
|
+
// };
|
|
1457
1125
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1126
|
+
// const get_table_instructions = function (object_unit) {
|
|
1127
|
+
// return `
|
|
1128
|
+
// ### context ###
|
|
1129
|
+
// uid=${uid}
|
|
1130
|
+
// app_id=${app_id}
|
|
1131
|
+
|
|
1132
|
+
// ### Persona & Role ###
|
|
1133
|
+
// - You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1134
|
+
|
|
1135
|
+
// ### Tasks ###
|
|
1136
|
+
|
|
1137
|
+
// Your job is to assist the user with creating a ${user_prompt} that includes a full set of fields according to the provided ${object_unit} structure.
|
|
1138
|
+
|
|
1139
|
+
// - You must include all relevant fields a typical ${user_prompt} would require
|
|
1140
|
+
// - Add **multiple entries** in the "tableFields" array as needed to fully represent the structure.
|
|
1141
|
+
// - Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1142
|
+
// - use uid for "createdByUid" and "checkedInUserId"
|
|
1143
|
+
|
|
1144
|
+
// ### workflow ###
|
|
1145
|
+
|
|
1146
|
+
// Steps:
|
|
1147
|
+
// 1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1148
|
+
|
|
1149
|
+
// 3. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 3 times the throw error, skip **Save Doc** tool if errors exist
|
|
1150
|
+
// 4. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1151
|
+
|
|
1152
|
+
// ### Output ###
|
|
1153
|
+
// if success: {code:1,data:save_result}
|
|
1154
|
+
// if fail: {code:-1,data:error}
|
|
1155
|
+
|
|
1156
|
+
// ### EXAMPLE
|
|
1157
|
+
|
|
1158
|
+
// {
|
|
1159
|
+
// "_id": "5b1_tbl_47f0ac6059ca",
|
|
1160
|
+
// "app_id": "prj3937cb6f9a31c8c7dea25055bba845b1",
|
|
1161
|
+
// "stat": 3,
|
|
1162
|
+
// "docType": "studio",
|
|
1163
|
+
// "docDate": 1714916369797,
|
|
1164
|
+
// "ts": 1762953659001,
|
|
1165
|
+
// "order_ts": 1714916369797,
|
|
1166
|
+
// "studio_meta": {
|
|
1167
|
+
// "created": 1714916369797,
|
|
1168
|
+
// "createdByUid": "341cf2d32991a68e4d8aaba6c16e15cc",
|
|
1169
|
+
// "checkedInUserId": "341cf2d32991a68e4d8aaba6c16e15cc",
|
|
1170
|
+
// "checkedInUserName": "Ioshka Media",
|
|
1171
|
+
// "parentId": "database",
|
|
1172
|
+
// "savedByUid": "341cf2d32991a68e4d8aaba6c16e15cc"
|
|
1173
|
+
// },
|
|
1174
|
+
// "properties": {
|
|
1175
|
+
// "menuType": "table",
|
|
1176
|
+
// "menuName": "PT - Practice Table",
|
|
1177
|
+
// "databaseSocket": "@xuda.io/xuda-dbs-plugin-xuda",
|
|
1178
|
+
// "menuTitle": "PT - Practice Table"
|
|
1179
|
+
// },
|
|
1180
|
+
// "tableIndexes": [
|
|
1181
|
+
// {
|
|
1182
|
+
// "id": "76bbf201-997e-402c-b435-0649cc25d117",
|
|
1183
|
+
// "data": {
|
|
1184
|
+
// "name": "Primary_Index",
|
|
1185
|
+
// "unique": true,
|
|
1186
|
+
// "keys": [
|
|
1187
|
+
// "PT_Id"
|
|
1188
|
+
// ]
|
|
1189
|
+
// },
|
|
1190
|
+
// "props": {} <-- must appear even if empty
|
|
1191
|
+
// },
|
|
1192
|
+
// {
|
|
1193
|
+
// "id": "89f1609d-de4e-4b61-9357-284b1261314c",
|
|
1194
|
+
// "data": {
|
|
1195
|
+
// "name": "Index_2",
|
|
1196
|
+
// "unique": false,
|
|
1197
|
+
// "keys": [
|
|
1198
|
+
// "PT_Stat",
|
|
1199
|
+
// "PT_Group_Id"
|
|
1200
|
+
// ]
|
|
1201
|
+
// },
|
|
1202
|
+
// "props": {} <-- must appear even if empty
|
|
1203
|
+
// }
|
|
1204
|
+
// ],
|
|
1205
|
+
// "tableFields": [
|
|
1206
|
+
// {
|
|
1207
|
+
// "id": "b41aa880-56ec-4029-a21b-60c89a52b62e",
|
|
1208
|
+
// "data": {
|
|
1209
|
+
// "field_id": "PT_Id"
|
|
1210
|
+
// },
|
|
1211
|
+
// "props": {
|
|
1212
|
+
// "label":"Practice Id",
|
|
1213
|
+
// "fieldType": "string",
|
|
1214
|
+
// "mandatory": true
|
|
1215
|
+
// }
|
|
1460
1216
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
type: 'array', // or "markdown" if needed
|
|
1473
|
-
},
|
|
1474
|
-
},
|
|
1475
|
-
},
|
|
1476
|
-
outputType: z.array(z.object()),
|
|
1477
|
-
},
|
|
1478
|
-
},
|
|
1479
|
-
table: {
|
|
1480
|
-
name: 'Table builder',
|
|
1481
|
-
instructions: get_table_instructions('table'),
|
|
1482
|
-
tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af473196a88191afc6610fddfe4a62')
|
|
1483
|
-
model,
|
|
1484
|
-
modelSettings: {
|
|
1485
|
-
toolChoice: 'required', // ← this enables tool use
|
|
1486
|
-
responseFormat: {
|
|
1487
|
-
text: {
|
|
1488
|
-
format: {
|
|
1489
|
-
type: 'array', // or "markdown" if needed
|
|
1490
|
-
},
|
|
1491
|
-
},
|
|
1492
|
-
},
|
|
1493
|
-
outputType: z.array(
|
|
1494
|
-
z.object({
|
|
1495
|
-
_id: z.string(),
|
|
1496
|
-
stat: z.number(),
|
|
1497
|
-
docType: z.string(),
|
|
1498
|
-
docDate: z.number(),
|
|
1499
|
-
ts: z.number(),
|
|
1500
|
-
order_ts: z.number(),
|
|
1501
|
-
studio_meta: z.object({
|
|
1502
|
-
created: z.number(),
|
|
1503
|
-
createdByUid: z.string(),
|
|
1504
|
-
checkedInUserId: z.string(),
|
|
1505
|
-
savedByUid: z.string(),
|
|
1506
|
-
checkedInUserName: z.string(),
|
|
1507
|
-
parentId: z.string(),
|
|
1508
|
-
source: z.string(),
|
|
1509
|
-
}),
|
|
1510
|
-
properties: z.object({
|
|
1511
|
-
menuName: z.string(),
|
|
1512
|
-
menuType: z.string(),
|
|
1513
|
-
databaseSocket: z.string(),
|
|
1514
|
-
}),
|
|
1515
|
-
tableIndexes: z.array(
|
|
1516
|
-
z.object({
|
|
1517
|
-
id: z.string(),
|
|
1518
|
-
data: z.object({
|
|
1519
|
-
name: z.string(),
|
|
1520
|
-
unique: z.boolean(),
|
|
1521
|
-
keys: z.array(z.string()),
|
|
1522
|
-
}),
|
|
1523
|
-
props: z.object({}),
|
|
1524
|
-
}),
|
|
1525
|
-
),
|
|
1526
|
-
tableFields: z.array(
|
|
1527
|
-
z.object({
|
|
1528
|
-
id: z.string(),
|
|
1529
|
-
data: z.object({
|
|
1530
|
-
field_id: z.string(),
|
|
1531
|
-
}),
|
|
1532
|
-
props: z.object({
|
|
1533
|
-
label: z.string(),
|
|
1534
|
-
fieldType: z.string(),
|
|
1535
|
-
}),
|
|
1536
|
-
}),
|
|
1537
|
-
),
|
|
1538
|
-
}),
|
|
1539
|
-
),
|
|
1540
|
-
},
|
|
1541
|
-
},
|
|
1542
|
-
folder: {
|
|
1543
|
-
name: 'Folder builder',
|
|
1544
|
-
instructions: get_folder_instructions('folder'),
|
|
1545
|
-
tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af44989e4881918fc8bf8e84c6ce03')
|
|
1546
|
-
model, //: 'gpt-4o'
|
|
1547
|
-
modelSettings: {
|
|
1548
|
-
toolChoice: 'required', // ← this enables tool use
|
|
1549
|
-
responseFormat: {
|
|
1550
|
-
text: {
|
|
1551
|
-
format: {
|
|
1552
|
-
type: 'array', // or "markdown" if needed
|
|
1553
|
-
},
|
|
1554
|
-
},
|
|
1555
|
-
},
|
|
1556
|
-
outputType: z.array(
|
|
1557
|
-
z.object({
|
|
1558
|
-
_id: z.string(),
|
|
1559
|
-
stat: z.number(),
|
|
1560
|
-
docType: z.string(),
|
|
1561
|
-
docDate: z.number(),
|
|
1562
|
-
ts: z.number(),
|
|
1563
|
-
order_ts: z.number(),
|
|
1564
|
-
studio_meta: z.object({
|
|
1565
|
-
created: z.number(),
|
|
1566
|
-
createdByUid: z.string(),
|
|
1567
|
-
checkedInUserId: z.string(),
|
|
1568
|
-
savedByUid: z.string(),
|
|
1569
|
-
checkedInUserName: z.string(),
|
|
1570
|
-
parentId: z.string(),
|
|
1571
|
-
source: z.string(),
|
|
1572
|
-
}),
|
|
1573
|
-
properties: z.object({
|
|
1574
|
-
menuName: z.string(),
|
|
1575
|
-
menuType: z.string(),
|
|
1576
|
-
databaseSocket: z.string(),
|
|
1577
|
-
}),
|
|
1578
|
-
}),
|
|
1579
|
-
),
|
|
1580
|
-
},
|
|
1581
|
-
},
|
|
1582
|
-
component: {
|
|
1583
|
-
name: 'Component builder',
|
|
1584
|
-
instructions: get_component_instructions('component'),
|
|
1585
|
-
tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //, fileSearchTool('vs_68af48a65cf88191a48a0f530d7e3919')
|
|
1586
|
-
model,
|
|
1587
|
-
modelSettings: {
|
|
1588
|
-
toolChoice: 'required', // ← this enables tool use
|
|
1589
|
-
responseFormat: {
|
|
1590
|
-
text: {
|
|
1591
|
-
format: {
|
|
1592
|
-
type: 'array', // or "markdown" if needed
|
|
1593
|
-
},
|
|
1594
|
-
},
|
|
1595
|
-
},
|
|
1596
|
-
outputType: z.array(
|
|
1597
|
-
z.object({
|
|
1598
|
-
_id: z.string(),
|
|
1599
|
-
stat: z.number(),
|
|
1600
|
-
docType: z.string(),
|
|
1601
|
-
docDate: z.number(),
|
|
1602
|
-
ts: z.number(),
|
|
1603
|
-
order_ts: z.number(),
|
|
1604
|
-
studio_meta: z.object({
|
|
1605
|
-
created: z.number(),
|
|
1606
|
-
createdByUid: z.string(),
|
|
1607
|
-
checkedInUserId: z.string(),
|
|
1608
|
-
savedByUid: z.string(),
|
|
1609
|
-
checkedInUserName: z.string(),
|
|
1610
|
-
parentId: z.string(),
|
|
1611
|
-
source: z.string(),
|
|
1612
|
-
}),
|
|
1613
|
-
properties: z.object({
|
|
1614
|
-
menuName: z.string(),
|
|
1615
|
-
menuType: z.string(),
|
|
1616
|
-
databaseSocket: z.string(),
|
|
1617
|
-
}),
|
|
1618
|
-
progDataSource: z.object({}),
|
|
1619
|
-
progFields: z.array(z.object({})),
|
|
1620
|
-
progEvents: z.array(z.object({})),
|
|
1621
|
-
progUi: z.array(z.object({})),
|
|
1622
|
-
}),
|
|
1623
|
-
),
|
|
1624
|
-
},
|
|
1625
|
-
},
|
|
1626
|
-
get_data: {
|
|
1627
|
-
name: 'Get data builder',
|
|
1628
|
-
instructions: get_get_data_instructions('get_data'),
|
|
1629
|
-
tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af530d4ba081919ca57eabb5ae117a')
|
|
1630
|
-
model,
|
|
1631
|
-
modelSettings: {
|
|
1632
|
-
toolChoice: 'required', // ← this enables tool use
|
|
1633
|
-
responseFormat: {
|
|
1634
|
-
text: {
|
|
1635
|
-
format: {
|
|
1636
|
-
type: 'array', // or "markdown" if needed
|
|
1637
|
-
},
|
|
1638
|
-
},
|
|
1639
|
-
},
|
|
1640
|
-
outputType: z.array(
|
|
1641
|
-
z.object({
|
|
1642
|
-
_id: z.string(),
|
|
1643
|
-
stat: z.number(),
|
|
1644
|
-
docType: z.string(),
|
|
1645
|
-
docDate: z.number(),
|
|
1646
|
-
ts: z.number(),
|
|
1647
|
-
order_ts: z.number(),
|
|
1648
|
-
studio_meta: z.object({
|
|
1649
|
-
created: z.number(),
|
|
1650
|
-
createdByUid: z.string(),
|
|
1651
|
-
checkedInUserId: z.string(),
|
|
1652
|
-
savedByUid: z.string(),
|
|
1653
|
-
checkedInUserName: z.string(),
|
|
1654
|
-
parentId: z.string(),
|
|
1655
|
-
source: z.string(),
|
|
1656
|
-
}),
|
|
1657
|
-
properties: z.object({
|
|
1658
|
-
menuName: z.string(),
|
|
1659
|
-
menuType: z.string(),
|
|
1660
|
-
databaseSocket: z.string(),
|
|
1661
|
-
}),
|
|
1662
|
-
progDataSource: z.object({}),
|
|
1663
|
-
progFields: z.array(z.object({})),
|
|
1664
|
-
progEvents: z.array(z.object({})),
|
|
1665
|
-
}),
|
|
1666
|
-
),
|
|
1667
|
-
},
|
|
1668
|
-
},
|
|
1669
|
-
};
|
|
1217
|
+
// },
|
|
1218
|
+
// {
|
|
1219
|
+
// "id": "8aec82db-35d9-4828-9fc7-49373c531cc3",
|
|
1220
|
+
// "data": {
|
|
1221
|
+
// "field_id": "PT_Type"
|
|
1222
|
+
// },
|
|
1223
|
+
// "props": {
|
|
1224
|
+
// "label":"Practice Type",
|
|
1225
|
+
// "fieldType": "string",
|
|
1226
|
+
// "mandatory": true
|
|
1227
|
+
// }
|
|
1670
1228
|
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1229
|
+
// },
|
|
1230
|
+
// {
|
|
1231
|
+
// "id": "d27c56e5-faec-4a0a-ad42-7bf55f8c67b3",
|
|
1232
|
+
// "data": {
|
|
1233
|
+
// "field_id": "PT_Stat"
|
|
1234
|
+
// },
|
|
1235
|
+
// "props": {
|
|
1236
|
+
// "label":"Practice Status",
|
|
1237
|
+
// "fieldType": "number",
|
|
1238
|
+
// "fieldComment": "1 = Draft\n2 = Private\n3 = Public\n4 = Deleted",
|
|
1239
|
+
// "mandatory": true
|
|
1240
|
+
// }
|
|
1675
1241
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1242
|
+
// },
|
|
1243
|
+
// {
|
|
1244
|
+
// "id": "659fbfb3-7dcc-4ea0-b1e9-5dd9553a99fc",
|
|
1245
|
+
// "data": {
|
|
1246
|
+
// "field_id": "PT_Question"
|
|
1247
|
+
// },
|
|
1248
|
+
// "props": {
|
|
1249
|
+
// "label":"Practice Question",
|
|
1250
|
+
// "fieldType": "string"
|
|
1251
|
+
// }
|
|
1679
1252
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1253
|
+
// },
|
|
1254
|
+
// {
|
|
1255
|
+
// "id": "080c8ceb-5a51-437b-8ad1-9fc005c79011",
|
|
1256
|
+
// "data": {
|
|
1257
|
+
// "field_id": "PT_Options"
|
|
1258
|
+
// },
|
|
1259
|
+
// "props": {
|
|
1260
|
+
// "label":"Practice Options",
|
|
1261
|
+
// "fieldType": "array"
|
|
1262
|
+
// }
|
|
1683
1263
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1264
|
+
// },
|
|
1265
|
+
// {
|
|
1266
|
+
// "id": "72c04aac-b3e7-4e7a-8a74-31075de3dbec",
|
|
1267
|
+
// "data": {
|
|
1268
|
+
// "field_id": "PT_Answer"
|
|
1269
|
+
// },
|
|
1270
|
+
// "props": {
|
|
1271
|
+
// "label":"Practice Answer",
|
|
1272
|
+
// "fieldType": "string"
|
|
1273
|
+
// }
|
|
1686
1274
|
|
|
1687
|
-
|
|
1275
|
+
// },
|
|
1276
|
+
// {
|
|
1277
|
+
// "id": "e37b08c6-f340-425a-bf01-809b28a486d3",
|
|
1278
|
+
// "data": {
|
|
1279
|
+
// "field_id": "PT_Matching_Answer"
|
|
1280
|
+
// },
|
|
1281
|
+
// "props": {
|
|
1282
|
+
// "label":"Practice Matching Answer",
|
|
1283
|
+
// "fieldType": "object"
|
|
1284
|
+
// },
|
|
1688
1285
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1286
|
+
// },
|
|
1287
|
+
// {
|
|
1288
|
+
// "id": "8ca4ace1-2010-45be-b7aa-2672ce0e6fea",
|
|
1289
|
+
// "data": {
|
|
1290
|
+
// "field_id": "PT_Group_Id"
|
|
1291
|
+
// },
|
|
1292
|
+
// "props": {
|
|
1293
|
+
// "label":"Practice Group Id",
|
|
1294
|
+
// "fieldType": "string"
|
|
1295
|
+
// }
|
|
1296
|
+
|
|
1297
|
+
// },
|
|
1298
|
+
// {
|
|
1299
|
+
// "id": "ae749c6d-1f39-4750-b79e-f016d50b8a11",
|
|
1300
|
+
// "data": {
|
|
1301
|
+
// "field_id": "PT_Difficulty"
|
|
1302
|
+
// },
|
|
1303
|
+
// "props": {
|
|
1304
|
+
// "label":"Practice Difficulty",
|
|
1305
|
+
// "fieldType": "number"
|
|
1306
|
+
// },
|
|
1307
|
+
|
|
1308
|
+
// },
|
|
1309
|
+
// {
|
|
1310
|
+
// "id": "5c5e7cb5-feee-4bc7-9d94-0ccd04a5eb06",
|
|
1311
|
+
// "data": {
|
|
1312
|
+
// "field_id": "PT_Uid"
|
|
1313
|
+
// },
|
|
1314
|
+
// "props": {
|
|
1315
|
+
// "label":"Practice User Id",
|
|
1316
|
+
// "fieldType": "string"
|
|
1317
|
+
// }
|
|
1318
|
+
|
|
1319
|
+
// }
|
|
1320
|
+
// ]
|
|
1321
|
+
// }
|
|
1322
|
+
// `;
|
|
1323
|
+
// };
|
|
1324
|
+
|
|
1325
|
+
// const get_folder_instructions = function (object_unit) {
|
|
1326
|
+
// return `
|
|
1327
|
+
// ### context ###
|
|
1328
|
+
// uid=${uid}
|
|
1329
|
+
// app_id=${app_id}
|
|
1330
|
+
|
|
1331
|
+
// ### Persona & Role ###
|
|
1332
|
+
// - You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1333
|
+
|
|
1334
|
+
// ### Tasks ###
|
|
1335
|
+
|
|
1336
|
+
// Your job is to assist the user with creating a ${user_prompt}.
|
|
1337
|
+
|
|
1338
|
+
// - Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1339
|
+
// - use uid for "createdByUid" and "checkedInUserId"
|
|
1340
|
+
|
|
1341
|
+
// ### workflow ###
|
|
1342
|
+
|
|
1343
|
+
// Steps:
|
|
1344
|
+
// 1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1345
|
+
// 2. Get the ${object_unit} structure example from ### Structure and Examples ### section.
|
|
1346
|
+
// 3. Build the ${object_unit} and validate against vs_68af4c84631c81919709268c2d0f1687
|
|
1347
|
+
// 4. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 3 times the throw error, skip **Save Doc** tool if errors exist
|
|
1348
|
+
// 5. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1349
|
+
|
|
1350
|
+
// ### Additional information ###
|
|
1351
|
+
// ${studio_units[object_unit].short}
|
|
1352
|
+
|
|
1353
|
+
// ### Output ###
|
|
1354
|
+
// if success: {code:1,data:save_result}
|
|
1355
|
+
// if fail: {code:-1,data:error}
|
|
1356
|
+
// `;
|
|
1357
|
+
// };
|
|
1358
|
+
|
|
1359
|
+
// const get_component_instructions = function (object_unit) {
|
|
1360
|
+
// return `
|
|
1361
|
+
// ### context ###
|
|
1362
|
+
// uid=${uid}
|
|
1363
|
+
// app_id=${app_id}
|
|
1364
|
+
|
|
1365
|
+
// ### Persona & Role ###
|
|
1366
|
+
// - You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1367
|
+
|
|
1368
|
+
// ### Tasks ###
|
|
1369
|
+
|
|
1370
|
+
// Your job is to assist the user with creating a ${user_prompt} that includes modern ui using Tailwind
|
|
1371
|
+
|
|
1372
|
+
// - You must include all relevant fields a typical ${user_prompt} would require
|
|
1373
|
+
|
|
1374
|
+
// - Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1375
|
+
// - use uid for "createdByUid" and "checkedInUserId"
|
|
1376
|
+
|
|
1377
|
+
// ### workflow ###
|
|
1378
|
+
|
|
1379
|
+
// Steps:
|
|
1380
|
+
// 1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1381
|
+
|
|
1382
|
+
// 2. use ### Structure and Examples ### section to build the object
|
|
1383
|
+
// 3. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 10 times the throw error, skip **Save Doc** tool if errors exist
|
|
1384
|
+
// 4. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1385
|
+
|
|
1386
|
+
// ### Additional information ###
|
|
1387
|
+
// ${studio_units[object_unit].short}
|
|
1388
|
+
|
|
1389
|
+
// ### Structure and Examples ###
|
|
1390
|
+
|
|
1391
|
+
// ${get_zod_unit_schema('component')}
|
|
1392
|
+
|
|
1393
|
+
// ### Output ###
|
|
1394
|
+
// if success: {code:1,data:save_result}
|
|
1395
|
+
// if fail: {code:-1,data:error}
|
|
1396
|
+
// `;
|
|
1397
|
+
// };
|
|
1398
|
+
// const get_get_data_instructions = function (object_unit) {
|
|
1399
|
+
// return `
|
|
1400
|
+
// ### context ###
|
|
1401
|
+
// uid=${uid}
|
|
1402
|
+
// app_id=${app_id}
|
|
1403
|
+
|
|
1404
|
+
// ### Persona & Role ###
|
|
1405
|
+
// - You are a helpful and professional technical assistant named ${object_unit} builder.
|
|
1406
|
+
|
|
1407
|
+
// ### Tasks ###
|
|
1408
|
+
|
|
1409
|
+
// Your job is to assist the user with creating a ${user_prompt}.
|
|
1410
|
+
|
|
1411
|
+
// - You must include all relevant fields a typical ${user_prompt} would require
|
|
1412
|
+
|
|
1413
|
+
// - Follow the format and conventions shown in the ${object_unit} structure example.
|
|
1414
|
+
// - use uid for "createdByUid" and "checkedInUserId"
|
|
1415
|
+
|
|
1416
|
+
// ### workflow ###
|
|
1417
|
+
|
|
1418
|
+
// Steps:
|
|
1419
|
+
// 1. Use create_initial_studio_doc_tool to create the initial doc assign the return result in "doc" variable.
|
|
1420
|
+
// 2. Get the ${object_unit} structure example from ### Structure and Examples ### section.
|
|
1421
|
+
// 3. Build the ${object_unit} and validate against vs_68af4c84631c81919709268c2d0f1687
|
|
1422
|
+
// 4. Use check_studio_doc_tool to check the ${object_unit} send the ${object_unit} as the doc, fix the issues if needed. if the check fail for 10 times the throw error, skip **Save Doc** tool if errors exist
|
|
1423
|
+
// 5. Use **Save Doc** tool to save the ${object_unit} doc and update the result in save_result variable,NEVER save if errors exist after check_studio_doc_tool
|
|
1424
|
+
|
|
1425
|
+
// ### Additional information ###
|
|
1426
|
+
// ${studio_units[object_unit].short}
|
|
1427
|
+
|
|
1428
|
+
// ### Output ###
|
|
1429
|
+
// if success: {code:1,data:save_result}
|
|
1430
|
+
// if fail: {code:-1,data:error}
|
|
1431
|
+
// `;
|
|
1432
|
+
// };
|
|
1433
|
+
|
|
1434
|
+
// const get_agents_as_a_tool = function (agent_list = []) {
|
|
1435
|
+
// let _tools = [];
|
|
1436
|
+
// for (const agent of agent_list) {
|
|
1437
|
+
// const _agent = new Agent(studio_agents_obj[agent]);
|
|
1438
|
+
// const tool = _agent.asTool({
|
|
1439
|
+
// toolName: studio_agents_obj[agent].name,
|
|
1440
|
+
// toolDescription: `Generate a ${agent} of the supplied text.`,
|
|
1441
|
+
// });
|
|
1442
|
+
|
|
1443
|
+
// _tools.push(tool);
|
|
1444
|
+
// }
|
|
1445
|
+
|
|
1446
|
+
// return _tools;
|
|
1447
|
+
// };
|
|
1448
|
+
|
|
1449
|
+
// let studio_agents_obj = {
|
|
1450
|
+
// app: {
|
|
1451
|
+
// name: 'App builder',
|
|
1452
|
+
// instructions: get_app_instructions(),
|
|
1453
|
+
// tools: [get_user_name_tool],
|
|
1454
|
+
// model,
|
|
1455
|
+
// modelSettings: {
|
|
1456
|
+
// toolChoice: 'required', // ← this enables tool use
|
|
1457
|
+
// responseFormat: {
|
|
1458
|
+
// text: {
|
|
1459
|
+
// format: {
|
|
1460
|
+
// type: 'array', // or "markdown" if needed
|
|
1461
|
+
// },
|
|
1462
|
+
// },
|
|
1463
|
+
// },
|
|
1464
|
+
// outputType: z.array(z.object()),
|
|
1465
|
+
// },
|
|
1466
|
+
// },
|
|
1467
|
+
// table: {
|
|
1468
|
+
// name: 'Table builder',
|
|
1469
|
+
// instructions: get_table_instructions('table'),
|
|
1470
|
+
// tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af473196a88191afc6610fddfe4a62')
|
|
1471
|
+
// model,
|
|
1472
|
+
// modelSettings: {
|
|
1473
|
+
// toolChoice: 'required', // ← this enables tool use
|
|
1474
|
+
// responseFormat: {
|
|
1475
|
+
// text: {
|
|
1476
|
+
// format: {
|
|
1477
|
+
// type: 'array', // or "markdown" if needed
|
|
1478
|
+
// },
|
|
1479
|
+
// },
|
|
1480
|
+
// },
|
|
1481
|
+
// outputType: z.array(
|
|
1482
|
+
// z.object({
|
|
1483
|
+
// _id: z.string(),
|
|
1484
|
+
// stat: z.number(),
|
|
1485
|
+
// docType: z.string(),
|
|
1486
|
+
// docDate: z.number(),
|
|
1487
|
+
// ts: z.number(),
|
|
1488
|
+
// order_ts: z.number(),
|
|
1489
|
+
// studio_meta: z.object({
|
|
1490
|
+
// created: z.number(),
|
|
1491
|
+
// createdByUid: z.string(),
|
|
1492
|
+
// checkedInUserId: z.string(),
|
|
1493
|
+
// savedByUid: z.string(),
|
|
1494
|
+
// checkedInUserName: z.string(),
|
|
1495
|
+
// parentId: z.string(),
|
|
1496
|
+
// source: z.string(),
|
|
1497
|
+
// }),
|
|
1498
|
+
// properties: z.object({
|
|
1499
|
+
// menuName: z.string(),
|
|
1500
|
+
// menuType: z.string(),
|
|
1501
|
+
// databaseSocket: z.string(),
|
|
1502
|
+
// }),
|
|
1503
|
+
// tableIndexes: z.array(
|
|
1504
|
+
// z.object({
|
|
1505
|
+
// id: z.string(),
|
|
1506
|
+
// data: z.object({
|
|
1507
|
+
// name: z.string(),
|
|
1508
|
+
// unique: z.boolean(),
|
|
1509
|
+
// keys: z.array(z.string()),
|
|
1510
|
+
// }),
|
|
1511
|
+
// props: z.object({}),
|
|
1512
|
+
// }),
|
|
1513
|
+
// ),
|
|
1514
|
+
// tableFields: z.array(
|
|
1515
|
+
// z.object({
|
|
1516
|
+
// id: z.string(),
|
|
1517
|
+
// data: z.object({
|
|
1518
|
+
// field_id: z.string(),
|
|
1519
|
+
// }),
|
|
1520
|
+
// props: z.object({
|
|
1521
|
+
// label: z.string(),
|
|
1522
|
+
// fieldType: z.string(),
|
|
1523
|
+
// }),
|
|
1524
|
+
// }),
|
|
1525
|
+
// ),
|
|
1526
|
+
// }),
|
|
1527
|
+
// ),
|
|
1528
|
+
// },
|
|
1529
|
+
// },
|
|
1530
|
+
// folder: {
|
|
1531
|
+
// name: 'Folder builder',
|
|
1532
|
+
// instructions: get_folder_instructions('folder'),
|
|
1533
|
+
// tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af44989e4881918fc8bf8e84c6ce03')
|
|
1534
|
+
// model, //: 'gpt-4o'
|
|
1535
|
+
// modelSettings: {
|
|
1536
|
+
// toolChoice: 'required', // ← this enables tool use
|
|
1537
|
+
// responseFormat: {
|
|
1538
|
+
// text: {
|
|
1539
|
+
// format: {
|
|
1540
|
+
// type: 'array', // or "markdown" if needed
|
|
1541
|
+
// },
|
|
1542
|
+
// },
|
|
1543
|
+
// },
|
|
1544
|
+
// outputType: z.array(
|
|
1545
|
+
// z.object({
|
|
1546
|
+
// _id: z.string(),
|
|
1547
|
+
// stat: z.number(),
|
|
1548
|
+
// docType: z.string(),
|
|
1549
|
+
// docDate: z.number(),
|
|
1550
|
+
// ts: z.number(),
|
|
1551
|
+
// order_ts: z.number(),
|
|
1552
|
+
// studio_meta: z.object({
|
|
1553
|
+
// created: z.number(),
|
|
1554
|
+
// createdByUid: z.string(),
|
|
1555
|
+
// checkedInUserId: z.string(),
|
|
1556
|
+
// savedByUid: z.string(),
|
|
1557
|
+
// checkedInUserName: z.string(),
|
|
1558
|
+
// parentId: z.string(),
|
|
1559
|
+
// source: z.string(),
|
|
1560
|
+
// }),
|
|
1561
|
+
// properties: z.object({
|
|
1562
|
+
// menuName: z.string(),
|
|
1563
|
+
// menuType: z.string(),
|
|
1564
|
+
// databaseSocket: z.string(),
|
|
1565
|
+
// }),
|
|
1566
|
+
// }),
|
|
1567
|
+
// ),
|
|
1568
|
+
// },
|
|
1569
|
+
// },
|
|
1570
|
+
// component: {
|
|
1571
|
+
// name: 'Component builder',
|
|
1572
|
+
// instructions: get_component_instructions('component'),
|
|
1573
|
+
// tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //, fileSearchTool('vs_68af48a65cf88191a48a0f530d7e3919')
|
|
1574
|
+
// model,
|
|
1575
|
+
// modelSettings: {
|
|
1576
|
+
// toolChoice: 'required', // ← this enables tool use
|
|
1577
|
+
// responseFormat: {
|
|
1578
|
+
// text: {
|
|
1579
|
+
// format: {
|
|
1580
|
+
// type: 'array', // or "markdown" if needed
|
|
1581
|
+
// },
|
|
1582
|
+
// },
|
|
1583
|
+
// },
|
|
1584
|
+
// outputType: z.array(
|
|
1585
|
+
// z.object({
|
|
1586
|
+
// _id: z.string(),
|
|
1587
|
+
// stat: z.number(),
|
|
1588
|
+
// docType: z.string(),
|
|
1589
|
+
// docDate: z.number(),
|
|
1590
|
+
// ts: z.number(),
|
|
1591
|
+
// order_ts: z.number(),
|
|
1592
|
+
// studio_meta: z.object({
|
|
1593
|
+
// created: z.number(),
|
|
1594
|
+
// createdByUid: z.string(),
|
|
1595
|
+
// checkedInUserId: z.string(),
|
|
1596
|
+
// savedByUid: z.string(),
|
|
1597
|
+
// checkedInUserName: z.string(),
|
|
1598
|
+
// parentId: z.string(),
|
|
1599
|
+
// source: z.string(),
|
|
1600
|
+
// }),
|
|
1601
|
+
// properties: z.object({
|
|
1602
|
+
// menuName: z.string(),
|
|
1603
|
+
// menuType: z.string(),
|
|
1604
|
+
// databaseSocket: z.string(),
|
|
1605
|
+
// }),
|
|
1606
|
+
// progDataSource: z.object({}),
|
|
1607
|
+
// progFields: z.array(z.object({})),
|
|
1608
|
+
// progEvents: z.array(z.object({})),
|
|
1609
|
+
// progUi: z.array(z.object({})),
|
|
1610
|
+
// }),
|
|
1611
|
+
// ),
|
|
1612
|
+
// },
|
|
1613
|
+
// },
|
|
1614
|
+
// get_data: {
|
|
1615
|
+
// name: 'Get data builder',
|
|
1616
|
+
// instructions: get_get_data_instructions('get_data'),
|
|
1617
|
+
// tools: [get_user_name_tool, create_initial_studio_doc_tool, check_studio_doc_tool, save_doc_tool], //fileSearchTool('vs_68af4c84631c81919709268c2d0f1687'), fileSearchTool('vs_68af530d4ba081919ca57eabb5ae117a')
|
|
1618
|
+
// model,
|
|
1619
|
+
// modelSettings: {
|
|
1620
|
+
// toolChoice: 'required', // ← this enables tool use
|
|
1621
|
+
// responseFormat: {
|
|
1622
|
+
// text: {
|
|
1623
|
+
// format: {
|
|
1624
|
+
// type: 'array', // or "markdown" if needed
|
|
1625
|
+
// },
|
|
1626
|
+
// },
|
|
1627
|
+
// },
|
|
1628
|
+
// outputType: z.array(
|
|
1629
|
+
// z.object({
|
|
1630
|
+
// _id: z.string(),
|
|
1631
|
+
// stat: z.number(),
|
|
1632
|
+
// docType: z.string(),
|
|
1633
|
+
// docDate: z.number(),
|
|
1634
|
+
// ts: z.number(),
|
|
1635
|
+
// order_ts: z.number(),
|
|
1636
|
+
// studio_meta: z.object({
|
|
1637
|
+
// created: z.number(),
|
|
1638
|
+
// createdByUid: z.string(),
|
|
1639
|
+
// checkedInUserId: z.string(),
|
|
1640
|
+
// savedByUid: z.string(),
|
|
1641
|
+
// checkedInUserName: z.string(),
|
|
1642
|
+
// parentId: z.string(),
|
|
1643
|
+
// source: z.string(),
|
|
1644
|
+
// }),
|
|
1645
|
+
// properties: z.object({
|
|
1646
|
+
// menuName: z.string(),
|
|
1647
|
+
// menuType: z.string(),
|
|
1648
|
+
// databaseSocket: z.string(),
|
|
1649
|
+
// }),
|
|
1650
|
+
// progDataSource: z.object({}),
|
|
1651
|
+
// progFields: z.array(z.object({})),
|
|
1652
|
+
// progEvents: z.array(z.object({})),
|
|
1653
|
+
// }),
|
|
1654
|
+
// ),
|
|
1655
|
+
// },
|
|
1656
|
+
// },
|
|
1657
|
+
// };
|
|
1658
|
+
|
|
1659
|
+
// if (object_unit === 'app') {
|
|
1660
|
+
// const agents_as_a_tool_arr = get_agents_as_a_tool(['table', 'folder', 'component', 'get_data']);
|
|
1661
|
+
// studio_agents_obj.app.tools = [...studio_agents_obj.app.tools, ...agents_as_a_tool_arr];
|
|
1662
|
+
// }
|
|
1663
|
+
|
|
1664
|
+
// const run = async function (user_prompt, object_unit) {
|
|
1665
|
+
// const _agent = new Agent(studio_agents_obj[object_unit]);
|
|
1666
|
+
// const runner = new Runner();
|
|
1667
|
+
|
|
1668
|
+
// const result = await runner.run(_agent, user_prompt, {
|
|
1669
|
+
// context: { uid, app_id, userName },
|
|
1670
|
+
// });
|
|
1671
|
+
|
|
1672
|
+
// return result;
|
|
1673
|
+
// };
|
|
1674
|
+
|
|
1675
|
+
// const result = await run(user_prompt, object_unit);
|
|
1676
|
+
|
|
1677
|
+
// return { code: 100, data: result.finalOutput };
|
|
1678
|
+
// } catch (err) {
|
|
1679
|
+
// debugger;
|
|
1680
|
+
// console.error('>>>>> AI:', err);
|
|
1681
|
+
// console.error('Cause:', err?.cause?.message);
|
|
1682
|
+
// return { code: -100, data: err.message };
|
|
1683
|
+
// }
|
|
1684
|
+
// };
|
|
1697
1685
|
|
|
1698
1686
|
export const get_chat_conversation = async function (req) {
|
|
1699
1687
|
let { conversation_id, order = 'asc', limit, after, _id, uid } = req;
|
|
@@ -1767,7 +1755,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1767
1755
|
|
|
1768
1756
|
if (_id) {
|
|
1769
1757
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
1770
|
-
let data = await db_module.get_app_couch_doc(app_id, _id);
|
|
1758
|
+
let data = await db_module.get_app_couch_doc(account_profile_info.app_id, _id);
|
|
1771
1759
|
return data;
|
|
1772
1760
|
}
|
|
1773
1761
|
|
|
@@ -1921,8 +1909,10 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1921
1909
|
export const delete_ai_chat = async function (req) {
|
|
1922
1910
|
let { conversation_id, uid } = req;
|
|
1923
1911
|
|
|
1912
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
1913
|
+
|
|
1924
1914
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
1925
|
-
let conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_id);
|
|
1915
|
+
let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
1926
1916
|
|
|
1927
1917
|
if (conversation_doc.stat !== 5) {
|
|
1928
1918
|
throw new Error('A document can only be deleted after it has been archived');
|
|
@@ -1937,7 +1927,7 @@ export const delete_ai_chat = async function (req) {
|
|
|
1937
1927
|
} else {
|
|
1938
1928
|
conversation_doc.stat = 4;
|
|
1939
1929
|
conversation_doc.ts = Date.now();
|
|
1940
|
-
save_ret = await db_module.save_app_couch_doc(app_id, conversation_doc);
|
|
1930
|
+
save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
1941
1931
|
|
|
1942
1932
|
client.conversations.delete(conversation_id);
|
|
1943
1933
|
|
|
@@ -1962,12 +1952,14 @@ export const delete_ai_chat = async function (req) {
|
|
|
1962
1952
|
export const archive_ai_chat = async function (req) {
|
|
1963
1953
|
let { conversation_id, uid } = req;
|
|
1964
1954
|
|
|
1955
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
1956
|
+
|
|
1965
1957
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
1966
1958
|
try {
|
|
1967
1959
|
const team_module = await import(`${module_path}/team_module/index.mjs`);
|
|
1968
1960
|
await team_module.validate_share_exist(uid, 'chat', conversation_id);
|
|
1969
1961
|
|
|
1970
|
-
let conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_id);
|
|
1962
|
+
let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
1971
1963
|
debugger;
|
|
1972
1964
|
if (conversation_doc.uid !== uid && conversation_doc?.account_profile_info?.account_profile_obj?.shared_from_uid !== uid) {
|
|
1973
1965
|
throw new Error('Operation not allowed');
|
|
@@ -1975,7 +1967,7 @@ export const archive_ai_chat = async function (req) {
|
|
|
1975
1967
|
|
|
1976
1968
|
conversation_doc.stat = 5;
|
|
1977
1969
|
conversation_doc.ts = Date.now();
|
|
1978
|
-
const save_ret = await db_module.save_app_couch_doc(app_id, conversation_doc);
|
|
1970
|
+
const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
|
|
1979
1971
|
|
|
1980
1972
|
return save_ret;
|
|
1981
1973
|
} catch (err) {
|