Introduce highlights option
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as z from "zod";
|
||||
import {
|
||||
availableHighlights,
|
||||
availableLanguages,
|
||||
availableTones,
|
||||
availableUnits,
|
||||
@@ -10,6 +11,7 @@ const bodySchema = z.strictObject({
|
||||
language: z.enum(availableLanguages),
|
||||
units: z.enum(availableUnits),
|
||||
tone: z.array(z.enum(availableTones)),
|
||||
highlights: z.array(z.enum(availableHighlights)),
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -26,6 +28,7 @@ export default defineEventHandler(async (event) => {
|
||||
language: body.language,
|
||||
units: body.units,
|
||||
tone: body.tone,
|
||||
highlights: body.highlights,
|
||||
},
|
||||
})
|
||||
.where(eq(tables.preferences.userId, session.user.id))
|
||||
|
||||
@@ -34,12 +34,14 @@ export const preferences = pgTable("preferences", {
|
||||
language: string;
|
||||
units: "Imperial" | "Metric";
|
||||
tone?: string[];
|
||||
highlights?: string[];
|
||||
}>()
|
||||
.$defaultFn(() => ({
|
||||
enabled: true,
|
||||
language: "English",
|
||||
units: "Metric",
|
||||
tone: [],
|
||||
highlights: [],
|
||||
})),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { chain, draw, get, isEmpty, omit, pick, tryit } from "radash";
|
||||
import { safeDestr } from "destr";
|
||||
import { User } from "./drizzle";
|
||||
import { availableTones } from "~/shared/constants";
|
||||
import { availableHighlights, availableTones } from "~/shared/constants";
|
||||
|
||||
const promo = "Written by https://ghostwriter.rocks 👻";
|
||||
|
||||
@@ -120,21 +120,19 @@ export const createActivityContent = async ({
|
||||
? (draw(availableTones) as string)
|
||||
: draw(user.preferences.data!.tone!);
|
||||
|
||||
const length = draw([
|
||||
"short",
|
||||
"short",
|
||||
"short",
|
||||
"medium",
|
||||
"a-little-more-than-medium",
|
||||
]);
|
||||
const highlight = isEmpty(user.preferences.data?.highlights)
|
||||
? (draw(availableHighlights) as string)
|
||||
: draw(user.preferences.data!.highlights!);
|
||||
|
||||
const length = draw(["short", "medium", "a-little-more-than-medium"]);
|
||||
|
||||
const prompt = `
|
||||
Generate a short title and a ${length}-lengthed description for my strava activity. Use my preferred language and unit system.
|
||||
Try to not exaggerate as I am using Strava often and I want my activites to be unique and easy to read. Don't say things like nothing too fancy or wild.
|
||||
Use a little bit of ${tone} tone to make things less boring. Highlight any PR only if available, do not mention them if no PRs.
|
||||
Use a little bit of ${tone} tone to make things less boring. Highlight ${highlight} properties if available.
|
||||
Maybe comment if any interesting fact in comparison to previous activities.
|
||||
|
||||
Add #${tone} at the end of the description. Depending the length of the description, maybe add more hashtags.
|
||||
Add #${tone} and #${highlight} at the end of the description. Depending the length of the description, maybe add more hashtags.
|
||||
|
||||
Language: ${user?.preferences.data.language}
|
||||
Unit system: ${user?.preferences.data.units}
|
||||
|
||||
Reference in New Issue
Block a user