(prompts)
| 1557 | } |
| 1558 | |
| 1559 | function getPromptsNumber(prompts) { |
| 1560 | if (typeof prompts === "undefined") { |
| 1561 | prompts = promptField.value |
| 1562 | } |
| 1563 | if (prompts.trim() === "" && activeTags.length === 0) { |
| 1564 | return [""] |
| 1565 | } |
| 1566 | |
| 1567 | let promptsToMake = [] |
| 1568 | let numberOfPrompts = 0 |
| 1569 | if (prompts.trim() !== "") { |
| 1570 | // this needs to stay sort of the same, as the prompts have to be passed through to the other functions |
| 1571 | prompts = prompts.split("\n") |
| 1572 | prompts = prompts.map((prompt) => prompt.trim()) |
| 1573 | prompts = prompts.filter((prompt) => prompt !== "") |
| 1574 | |
| 1575 | // estimate number of prompts |
| 1576 | let estimatedNumberOfPrompts = 0 |
| 1577 | prompts.forEach((prompt) => { |
| 1578 | estimatedNumberOfPrompts += |
| 1579 | (prompt.match(/{[^}]*}/g) || []) |
| 1580 | .map((e) => (e.match(/,/g) || []).length + 1) |
| 1581 | .reduce((p, a) => p * a, 1) * |
| 1582 | 2 ** (prompt.match(/\|/g) || []).length |
| 1583 | }) |
| 1584 | |
| 1585 | if (estimatedNumberOfPrompts >= 10000) { |
| 1586 | return 10000 |
| 1587 | } |
| 1588 | |
| 1589 | promptsToMake = applySetOperator(prompts) // switched those around as Set grows in a linear fashion and permute in 2^n, and one has to be computed for the other to be calculated |
| 1590 | numberOfPrompts = applyPermuteOperatorNumber(promptsToMake) |
| 1591 | } |
| 1592 | const newTags = activeTags.filter((tag) => tag.inactive === undefined || tag.inactive === false) |
| 1593 | if (newTags.length > 0) { |
| 1594 | const promptTags = newTags.map((x) => x.name).join(", ") |
| 1595 | if (numberOfPrompts > 0) { |
| 1596 | // promptsToMake = promptsToMake.map((prompt) => `${prompt}, ${promptTags}`) |
| 1597 | // nothing changes, as all prompts just get modified |
| 1598 | } else { |
| 1599 | // promptsToMake.push(promptTags) |
| 1600 | numberOfPrompts = 1 |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | // Why is this applied twice? It does not do anything here, as everything should have already been done earlier |
| 1605 | // promptsToMake = applyPermuteOperator(promptsToMake) |
| 1606 | // promptsToMake = applySetOperator(promptsToMake) |
| 1607 | |
| 1608 | return numberOfPrompts |
| 1609 | } |
| 1610 | |
| 1611 | function applySetOperator(prompts) { |
| 1612 | let promptsToMake = [] |
no test coverage detected