( hardCodedProperties: Properties, propertiesForAi: Properties, openAiResponse: string, transformed: Properties, )
| 349 | } |
| 350 | |
| 351 | function rebuildPropertiesArray( |
| 352 | hardCodedProperties: Properties, |
| 353 | propertiesForAi: Properties, |
| 354 | openAiResponse: string, |
| 355 | transformed: Properties, |
| 356 | ) { |
| 357 | const arrayResponse = []; |
| 358 | // Loop through each array element |
| 359 | for (let idx = 0; idx < 3; idx++) { |
| 360 | // Stick the result from the gpt call back on |
| 361 | const readded = addGPTdataToProperties( |
| 362 | propertiesForAi, |
| 363 | openAiResponse, |
| 364 | idx, |
| 365 | ); |
| 366 | |
| 367 | // hardcoded properties are a whole array, so we need to index |
| 368 | let hardcodedProperiesIdx: Properties = {}; |
| 369 | for (let [key, value] of Object.entries(hardCodedProperties)) { |
| 370 | hardcodedProperiesIdx[key] = { |
| 371 | ...value, |
| 372 | data: value.data[idx], |
| 373 | }; |
| 374 | } |
| 375 | |
| 376 | const newChunks = propertiesToChunks( |
| 377 | Object.assign({}, transformed, { ...readded, ...hardcodedProperiesIdx }), |
| 378 | ); |
| 379 | arrayResponse.push(jsonReconstruct(newChunks)); |
| 380 | } |
| 381 | return removePropertiesItems(arrayResponse); |
| 382 | } |
| 383 | |
| 384 | function propertiesFromSchema(schema: OpenAPIV3_1.SchemaObject) { |
| 385 | if (schema.properties) return schema.properties; |
no test coverage detected