Skip to content

Commit

Permalink
Generate AI tags (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
codecalm authored Nov 28, 2024
1 parent e54656d commit 474b256
Show file tree
Hide file tree
Showing 1,447 changed files with 1,540 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .build/import-tags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const data = JSON.parse(fs.readFileSync(join(HOME_DIR, 'new/tags.json'), 'utf-8'

for (const [key, tags] of Object.entries(data)) {

const filename = join(HOME_DIR, `src/_icons/${key}.svg`), tagsInline = tags
const filename = join(HOME_DIR, `icons/outline/${key}.svg`), tagsInline = tags
.join(' ')
.toLowerCase()
.split(' ')
Expand All @@ -17,10 +17,10 @@ for (const [key, tags] of Object.entries(data)) {

if (key && tags.length) {
let data = fs.readFileSync(filename).toString()
data = data.replace(/(---[\s\S]+?---)/, function (m, headerContent) {
data = data.replace(/(\<\!--[\s\S]+?-->)/, function (m, headerContent) {

headerContent = headerContent.replace(/tags: .*\n/, '')
headerContent = headerContent.replace(/---/, `---\ntags: [${tagsInline}]`)
headerContent = headerContent.replace(/\<\!--/, `<!--\ntags: [${tagsInline}]`)

return headerContent
})
Expand Down
36 changes: 36 additions & 0 deletions ai.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import OpenAI from 'openai';
import { getAllIcons } from './.build/helpers.mjs';
import { writeFileSync } from 'fs';

const client = new OpenAI();

const allIcons = getAllIcons();

let withoutTags = [];
for (const icon of allIcons.outline) {
if (icon.tags.length == 0 && withoutTags.length < 30) {
withoutTags.push(icon.name);
}
}

async function main() {
const completion = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{
role: 'user',
content: `generate few tags for icon which represent for each icon: ${withoutTags.join(', ')}. Tags should be one world, lowercase and separated by comma. Generate minimum 10 tags for each icon. Write as json. Use original key. Tag should be different than original key. Tags should be array of strings.`
}],
response_format: {
type: 'json_object',
}
});

console.log(completion.choices[0].message.content);

writeFileSync('./new/tags.json', completion.choices[0].message.content);
}


if (withoutTags.length > 0) {
main();
}
1 change: 1 addition & 0 deletions icons/outline/adjustments-bolt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-cog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-dollar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-exclamation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-pause.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/adjustments-x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/air-traffic-control.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-hexagon-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-hexagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-small-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-square-rounded-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/outline/alert-square-rounded.svg
1 change: 1 addition & 0 deletions icons/outline/alert-square.svg
1 change: 1 addition & 0 deletions icons/outline/align-box-center-bottom.svg
1 change: 1 addition & 0 deletions icons/outline/align-box-center-stretch.svg
1 change: 1 addition & 0 deletions icons/outline/align-box-center-top.svg
1 change: 1 addition & 0 deletions icons/outline/align-box-left-stretch.svg
1 change: 1 addition & 0 deletions icons/outline/align-box-right-stretch.svg
1 change: 1 addition & 0 deletions icons/outline/alphabet-arabic.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-back-up-double.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-bar-both.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-capsule.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-down-from-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-down-to-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-elbow-left.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-elbow-right.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-forward-up-double.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-left-from-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-left-to-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-right-from-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-right-to-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-up-from-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrow-up-to-arc.svg
1 change: 1 addition & 0 deletions icons/outline/arrows-transfer-up-down.svg
1 change: 1 addition & 0 deletions icons/outline/automatic-gearbox.svg
1 change: 1 addition & 0 deletions icons/outline/automation.svg
1 change: 1 addition & 0 deletions icons/outline/avocado.svg
1 change: 1 addition & 0 deletions icons/outline/backslash.svg
1 change: 1 addition & 0 deletions icons/outline/basket-bolt.svg
1 change: 1 addition & 0 deletions icons/outline/basket-cancel.svg
1 change: 1 addition & 0 deletions icons/outline/basket-check.svg
1 change: 1 addition & 0 deletions icons/outline/basket-code.svg
Loading

0 comments on commit 474b256

Please sign in to comment.