generated from nhcarrigan/template
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9fe720b6a7
|
|||
|
f3c2e8fa40
|
+16
-113
@@ -25,118 +25,15 @@ import type {
|
|||||||
Thread,
|
Thread,
|
||||||
} from "./types/index.ts";
|
} from "./types/index.ts";
|
||||||
|
|
||||||
const adjectives = [
|
const generateThreadName = (mode: Mode, text?: string): string => {
|
||||||
"Amber",
|
if (
|
||||||
"Ancient",
|
mode === "replace"
|
||||||
"Arctic",
|
|| text === undefined
|
||||||
"Azure",
|
|| text.trim().length === 0
|
||||||
"Blazing",
|
) {
|
||||||
"Celestial",
|
return `Replace - ${new Date().toLocaleString()}`;
|
||||||
"Cobalt",
|
}
|
||||||
"Crimson",
|
return text.trim().slice(0, 40);
|
||||||
"Crystal",
|
|
||||||
"Dark",
|
|
||||||
"Distant",
|
|
||||||
"Ember",
|
|
||||||
"Emerald",
|
|
||||||
"Eternal",
|
|
||||||
"Ethereal",
|
|
||||||
"Fleeting",
|
|
||||||
"Frosted",
|
|
||||||
"Gilded",
|
|
||||||
"Golden",
|
|
||||||
"Hidden",
|
|
||||||
"Hollow",
|
|
||||||
"Indigo",
|
|
||||||
"Ivory",
|
|
||||||
"Jade",
|
|
||||||
"Lunar",
|
|
||||||
"Midnight",
|
|
||||||
"Mystic",
|
|
||||||
"Neon",
|
|
||||||
"Obsidian",
|
|
||||||
"Onyx",
|
|
||||||
"Opal",
|
|
||||||
"Pale",
|
|
||||||
"Pearl",
|
|
||||||
"Radiant",
|
|
||||||
"Rusted",
|
|
||||||
"Sapphire",
|
|
||||||
"Scarlet",
|
|
||||||
"Shattered",
|
|
||||||
"Silent",
|
|
||||||
"Silver",
|
|
||||||
"Spectral",
|
|
||||||
"Twilight",
|
|
||||||
"Velvet",
|
|
||||||
"Verdant",
|
|
||||||
"Veiled",
|
|
||||||
"Violet",
|
|
||||||
"Wandering",
|
|
||||||
"Wild",
|
|
||||||
"Woven",
|
|
||||||
"Arcane",
|
|
||||||
];
|
|
||||||
|
|
||||||
const nouns = [
|
|
||||||
"Abyss",
|
|
||||||
"Archive",
|
|
||||||
"Aria",
|
|
||||||
"Bloom",
|
|
||||||
"Cascade",
|
|
||||||
"Chronicle",
|
|
||||||
"Cipher",
|
|
||||||
"Compass",
|
|
||||||
"Crown",
|
|
||||||
"Dawn",
|
|
||||||
"Dream",
|
|
||||||
"Echo",
|
|
||||||
"Elegy",
|
|
||||||
"Ember",
|
|
||||||
"Equinox",
|
|
||||||
"Flame",
|
|
||||||
"Fragment",
|
|
||||||
"Garden",
|
|
||||||
"Horizon",
|
|
||||||
"Labyrinth",
|
|
||||||
"Lantern",
|
|
||||||
"Mirage",
|
|
||||||
"Mist",
|
|
||||||
"Murmur",
|
|
||||||
"Nexus",
|
|
||||||
"Nocturne",
|
|
||||||
"Oracle",
|
|
||||||
"Phantom",
|
|
||||||
"Prism",
|
|
||||||
"Requiem",
|
|
||||||
"Reverie",
|
|
||||||
"Ruin",
|
|
||||||
"Shadow",
|
|
||||||
"Shard",
|
|
||||||
"Silence",
|
|
||||||
"Solstice",
|
|
||||||
"Sonata",
|
|
||||||
"Specter",
|
|
||||||
"Storm",
|
|
||||||
"Tempest",
|
|
||||||
"Throne",
|
|
||||||
"Tide",
|
|
||||||
"Veil",
|
|
||||||
"Vortex",
|
|
||||||
"Whisper",
|
|
||||||
"Zenith",
|
|
||||||
"Sigil",
|
|
||||||
"Glyph",
|
|
||||||
"Dusk",
|
|
||||||
"Omen",
|
|
||||||
];
|
|
||||||
|
|
||||||
const generateThreadName = (): string => {
|
|
||||||
const adjectiveIndex = Math.floor(Math.random() * adjectives.length);
|
|
||||||
const nounIndex = Math.floor(Math.random() * nouns.length);
|
|
||||||
const adjective = adjectives[adjectiveIndex] ?? "Arcane";
|
|
||||||
const noun = nouns[nounIndex] ?? "Reverie";
|
|
||||||
return `${adjective} ${noun}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateId = (): string => {
|
const generateId = (): string => {
|
||||||
@@ -177,7 +74,13 @@ const resolveUpdatedThread = (updatedThread: Thread): Thread => {
|
|||||||
return updatedThread;
|
return updatedThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = generateThreadName();
|
const firstTextPart = firstMessage.parts.find((part) => {
|
||||||
|
return part.type === "text";
|
||||||
|
});
|
||||||
|
const name = generateThreadName(
|
||||||
|
updatedThread.mode,
|
||||||
|
firstTextPart?.text,
|
||||||
|
);
|
||||||
return { ...updatedThread, name };
|
return { ...updatedThread, name };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user